Class SpaceSearchMcpTool

java.lang.Object
io.meeds.mcp.server.tool.SpaceSearchMcpTool
All Implemented Interfaces:
io.meeds.mcp.server.plugin.McpToolPlugin

@Service public class SpaceSearchMcpTool extends Object implements io.meeds.mcp.server.plugin.McpToolPlugin
Finds a space by the words of its name or description, so that an assistant resolves the space a user names with one call instead of listing every space.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The length past which a hit's description is shortened
    static final int
    The most hits one search returns
    static final String
    The message of a search without a word to look for

    Fields inherited from interface io.meeds.mcp.server.plugin.McpToolPlugin

    DEFAULT_LIMIT, DEFAULT_OFFSET
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    searchSpaces(String query, Integer limit)
    Searches the spaces the current user may see in the spaces directory, by the words of their name or description, the best match first: among the first 50 the search engine returns, a space whose name has a word starting with each word of the query comes before one that only mentions them.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface io.meeds.mcp.server.plugin.McpToolPlugin

    getCurrentUserAclIdentity, getCurrentUserLocale, getCurrentUserLocale, getCurrentUserName, getLocale
  • Field Details

    • MAX_LIMIT

      public static final int MAX_LIMIT
      The most hits one search returns
      See Also:
    • DESCRIPTION_MAX_LENGTH

      public static final int DESCRIPTION_MAX_LENGTH
      The length past which a hit's description is shortened
      See Also:
    • MSG_QUERY_REQUIRED

      public static final String MSG_QUERY_REQUIRED
      The message of a search without a word to look for
      See Also:
  • Constructor Details

    • SpaceSearchMcpTool

      public SpaceSearchMcpTool()
  • Method Details

    • searchSpaces

      public List<SpaceSearchHitModel> searchSpaces(String query, Integer limit)
      Searches the spaces the current user may see in the spaces directory, by the words of their name or description, the best match first: among the first 50 the search engine returns, a space whose name has a word starting with each word of the query comes before one that only mentions them. The spaces are those of the spaces directory's search, where a hidden space reaches its members and the users who manage its space template (template administrators included), with Elasticsearch and on the database fallback alike; a user only invited to it doesn't get it (XSpaceFilter#setSpaceFilter drops the invited status on the fallback).
      Parameters:
      query - the words to look for, ignoring case and accents; required
      limit - the most hits to return, 10 when absent, at most 50
      Returns:
      the matching spaces, the best match first
      Throws:
      IllegalArgumentException - when the query holds no word, or when the search condition SpaceFilter derives from it (its unified search syntax around ~) holds none