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
FieldsModifier and TypeFieldDescriptionstatic final intThe length past which a hit's description is shortenedstatic final intThe most hits one search returnsstatic final StringThe message of a search without a word to look forFields inherited from interface io.meeds.mcp.server.plugin.McpToolPlugin
DEFAULT_LIMIT, DEFAULT_OFFSET -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionsearchSpaces(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, waitMethods inherited from interface io.meeds.mcp.server.plugin.McpToolPlugin
getCurrentUserAclIdentity, getCurrentUserLocale, getCurrentUserLocale, getCurrentUserName, getLocale
-
Field Details
-
MAX_LIMIT
public static final int MAX_LIMITThe most hits one search returns- See Also:
-
DESCRIPTION_MAX_LENGTH
public static final int DESCRIPTION_MAX_LENGTHThe length past which a hit's description is shortened- See Also:
-
MSG_QUERY_REQUIRED
The message of a search without a word to look for- See Also:
-
-
Constructor Details
-
SpaceSearchMcpTool
public SpaceSearchMcpTool()
-
-
Method Details
-
searchSpaces
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#setSpaceFilterdrops the invited status on the fallback).- Parameters:
query- the words to look for, ignoring case and accents; requiredlimit- 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 conditionSpaceFilterderives from it (its unified search syntax around~) holds none
-