Class McpMibSemanticSearch
java.lang.Object
org.snmp4j.mcp.tool.mib.semantic.McpMibSemanticSearch
- All Implemented Interfaces:
McpTool
MCP tool that performs semantic (vector-similarity) search over all MIB objects
currently loaded in the server's
SmiManager.
How it works
- On first call (or after a module reload), the tool builds a vector index by
embedding every loaded MIB object using the configured
EmbeddingClient. - The index is persisted as a GZIP'd JSON file next to the MIB repository so it can be reloaded on server restart without re-embedding.
- Subsequent queries embed the natural-language
querystring and rank all indexed objects by cosine similarity.
Configuration
Set theOPENAI_API_KEY environment variable (or the
openai.api.key JVM system property) before starting the server.
If neither is set, the tool is registered, but every call returns an error
explaining what is missing.- Since:
- 0.1.0
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMcpMibSemanticSearch(com.snmp4j.smi.SmiManager smiManager, EmbeddingClient embeddingClient, Path repositoryDir) Creates a new semantic search tool. -
Method Summary
Modifier and TypeMethodDescriptionExecutes the tool with the provided parameters.io.modelcontextprotocol.spec.McpSchema.ToolAnnotationsGets the tool annotations.Gets the description for this tool.getId()Gets the unique identifier for this tool.getName()Gets the display name for this tool.Gets the supported parameters for this tool.Gets the contexts that this tool requires.getTitle()Gets the title associated with this tool.Gets the version of this tool.booleanChecks if the tool is available in the current environment.voidTriggers an asynchronous (re-)build of the embedding index.
-
Field Details
-
TOOL_ID
Tool ID registered with the MCP server ("semantic_search_mib").- See Also:
-
-
Constructor Details
-
McpMibSemanticSearch
public McpMibSemanticSearch(com.snmp4j.smi.SmiManager smiManager, EmbeddingClient embeddingClient, Path repositoryDir) Creates a new semantic search tool.- Parameters:
smiManager- provides access to loaded MIB objects for index buildingembeddingClient- embedding backend; may benull(tool will report an error on use)repositoryDir- directory where the index cache file is stored; usenullto write it in the current working directory
-
-
Method Details
-
getId
-
getName
-
getVersion
Description copied from interface:McpToolGets the version of this tool.- Specified by:
getVersionin interfaceMcpTool- Returns:
- the tool version
-
getTitle
-
getAnnotation
public io.modelcontextprotocol.spec.McpSchema.ToolAnnotations getAnnotation()Description copied from interface:McpToolGets the tool annotations. By default, readOnly, hidden, idempotent, openWorld are true while destructive and returnDirect are false.- Specified by:
getAnnotationin interfaceMcpTool- Returns:
McpSchema.ToolAnnotations
-
getDescription
Description copied from interface:McpToolGets the description for this tool.- Specified by:
getDescriptionin interfaceMcpTool- Returns:
- the tool description
-
isAvailable
public boolean isAvailable()Description copied from interface:McpToolChecks if the tool is available in the current environment.- Specified by:
isAvailablein interfaceMcpTool- Returns:
- true if the tool is available, false otherwise
-
getRequiredContexts
Description copied from interface:McpToolGets the contexts that this tool requires.- Specified by:
getRequiredContextsin interfaceMcpTool- Returns:
- a list of required context IDs
-
getParameters
Description copied from interface:McpToolGets the supported parameters for this tool.- Specified by:
getParametersin interfaceMcpTool- Returns:
- a list of parameter descriptions
-
execute
Description copied from interface:McpToolExecutes the tool with the provided parameters.- Specified by:
executein interfaceMcpTool- Parameters:
params- the parameters to use- Returns:
- the result of the execution
- Throws:
McpToolException- if the tool execution fails
-
rebuildAsync
public void rebuildAsync()Triggers an asynchronous (re-)build of the embedding index. Safe to call concurrently; only one build runs at a time.
-