Class GetMibFileTool
java.lang.Object
org.snmp4j.mcp.tool.mib.text.GetMibFileTool
- All Implemented Interfaces:
McpTool
An MCP tool that returns the raw text of a MIB source file located under the server's configured
MIB source directory (
MIB.mibSourcePath, default "mibs").
The tool operates in one of two modes, selected by its parameters:
- When only
fileNameis given, it is resolved as a path relative to the configured MIB source directory and the text content of that file is returned. - When
zipFileNameis also given,zipFileNameis resolved as a ZIP archive (relative to the source directory) andfileNameis read as the name of an entry inside that archive.
Both relative paths must resolve to a location inside the configured source directory; values that
escape it (absolute paths or .. segments) are rejected. If the configured source directory does
not exist or is not a directory, an error is logged and no file is processed.
- Since:
- 0.1.0
- Version:
- 0.1.0
- Author:
- SNMP4J.org
-
Field Summary
Fields -
Constructor Summary
Constructors -
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.
-
Field Details
-
TOOL_ID
-
-
Constructor Details
-
GetMibFileTool
Creates aGetMibFileTool.- Parameters:
mibSourcePath- the directory (from theMIB.mibSourcePathserver configuration setting) that holds the MIB source files this tool may read. A blank ornullvalue falls back to the current working directory.
-
-
Method Details
-
getId
-
getName
-
getTitle
-
getDescription
Description copied from interface:McpToolGets the description for this tool.- Specified by:
getDescriptionin interfaceMcpTool- Returns:
- the tool description
-
getVersion
Description copied from interface:McpToolGets the version of this tool.- Specified by:
getVersionin interfaceMcpTool- Returns:
- the tool version
-
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
-
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
-
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
-