Class McpSnmpTree
java.lang.Object
org.snmp4j.mcp.tool.snmp.tree.McpSnmpTree
- All Implemented Interfaces:
McpTool
MCP Tool that walks an SNMP subtree from a named
SnmpMcpServer.ServerConfiguration.SnmpTargetConfig and returns all
variable bindings as JSON.
Uses TreeUtils.getSubtree(Target, OID, Object, TreeListener) with an
async TreeListener identical in structure to the McpSnmpTable
implementation. Progress (cumulative variable-binding count) is pushed to the
MCP client via McpSyncServerExchange.progressNotification(McpSchema.ProgressNotification) after each
batch returned by the agent.
Register this tool using toSyncToolSpec() rather than the generic
SnmpMcpServer.registerTool() so that the exchange is passed through.
- Since:
- 0.1.0
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMcpSnmpTree(Supplier<List<SnmpMcpServer.ServerConfiguration.SnmpTargetConfig>> snmpTargetsSupplier, com.snmp4j.smi.SmiManager smiManager) Creates a new SNMP subtree walk tool. -
Method Summary
Modifier and TypeMethodDescriptionio.modelcontextprotocol.spec.McpSchema.CallToolResultcallTool(io.modelcontextprotocol.server.McpSyncServerExchange exchange, io.modelcontextprotocol.spec.McpSchema.CallToolRequest request) Executes the tool within an active MCP server exchange, enabling progress notifications.Executes the tool with the provided parameters.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.static StringReturns the JSON Schema (Draft 2020-12) for the JSON object returned by this tool.Gets the version of this tool.booleanChecks if the tool is available in the current environment.io.modelcontextprotocol.server.McpServerFeatures.SyncToolSpecificationReturns aMcpServerFeatures.SyncToolSpecificationfor direct server registration.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface McpTool
getAnnotation
-
Field Details
-
TOOL_ID
Tool ID registered with the MCP server ("snmp_walk_subtree").- See Also:
-
TREE_RESULT_SCHEMA_RESOURCE_URI
MCP resource URI for the tree result JSON schema.- See Also:
-
-
Constructor Details
-
McpSnmpTree
public McpSnmpTree(Supplier<List<SnmpMcpServer.ServerConfiguration.SnmpTargetConfig>> snmpTargetsSupplier, com.snmp4j.smi.SmiManager smiManager) Creates a new SNMP subtree walk tool.- Parameters:
snmpTargetsSupplier- supplies the list of configured SNMP targetssmiManager- used for OID and type resolution; may benull
-
-
Method Details
-
getId
-
getName
-
getVersion
Description copied from interface:McpToolGets the version of this tool.- Specified by:
getVersionin interfaceMcpTool- Returns:
- the tool version
-
getTitle
-
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
-
callTool
public io.modelcontextprotocol.spec.McpSchema.CallToolResult callTool(io.modelcontextprotocol.server.McpSyncServerExchange exchange, io.modelcontextprotocol.spec.McpSchema.CallToolRequest request) Executes the tool within an active MCP server exchange, enabling progress notifications.- Parameters:
exchange- the active server exchange for sending notificationsrequest- the MCP tool call request containing arguments- Returns:
- the MCP call tool result
-
toSyncToolSpec
public io.modelcontextprotocol.server.McpServerFeatures.SyncToolSpecification toSyncToolSpec()Returns aMcpServerFeatures.SyncToolSpecificationfor direct server registration. This variant passes the MCP exchange through tocallTool(McpSyncServerExchange, McpSchema.CallToolRequest), enabling progress notifications during the subtree walk.Usage:
syncServer.addTool(mcpSnmpTree.toSyncToolSpec());- Returns:
- sync tool specification ready to pass to
McpSyncServer.addTool()
-
getTreeResultSchemaJson
Returns the JSON Schema (Draft 2020-12) for the JSON object returned by this tool.- Returns:
- JSON Schema string for
TREE_RESULT_SCHEMA_RESOURCE_URI
-