Class MibCompilerTool
java.lang.Object
org.snmp4j.mcp.tool.mib.compiler.MibCompilerTool
- All Implemented Interfaces:
McpTool
An MCP Tool that compiles SMIv1 or SMIv2 MIB specifications using the underlying
SmiManager and returns compilation results as a JSON string.
Three instances of this tool are intended to be registered with the MCP server,
one per applicable SmiCompiler.TargetMode:
check_mib— dry-run syntax check, no repository changes.check_mib_completely— dry-run without error count limit.compile_mib— compile and persist into the repository (no cache load).
Compilation progress is reported via the server's logging infrastructure using
a CompilationMonitor implementation. If the MCP framework supports client-side
progress notifications in a future version, the monitor can be extended accordingly.
The MIB specification to compile can be supplied in one of two ways:
- Inline via the
mibContentparameter (the raw SMIv1/v2 text), or - By reference via the
mibFileparameter, a filename (text or ZIP archive) relative to the server's configured MIB source directory (MIB.mibSourcePath, default"mibs"). ZIP archives (recognized by a.zipextension) are expanded into their individual module entries. AmibFilethat resolves to a location outside the configured source directory is rejected. WhenmibFileis provided it takes precedence overmibContent. The file and ZIP names reported in the returnedCompilationResults are kept relative to the configured source directory and never expose the server's absolute file-system paths.
- Since:
- 0.1.0
- Version:
- 0.1.0
- Author:
- SNMP4J.org
-
Constructor Summary
ConstructorsConstructorDescriptionMibCompilerTool(com.snmp4j.smi.SmiManager smiManager, com.snmp4j.smi.SmiCompiler.TargetMode targetMode, String mibSourcePath) Creates aMibCompilerToolfor the specified target mode. -
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.
-
Constructor Details
-
MibCompilerTool
public MibCompilerTool(com.snmp4j.smi.SmiManager smiManager, com.snmp4j.smi.SmiCompiler.TargetMode targetMode, String mibSourcePath) Creates aMibCompilerToolfor the specified target mode. The tool ID, title, and description are determined by the giventargetMode.- Parameters:
smiManager- theSmiManagerused to compile MIB specifications.targetMode- the compilation target mode; must be one ofSmiCompiler.TargetMode.dryRun,SmiCompiler.TargetMode.dryRunWithoutErrorLimit, orSmiCompiler.TargetMode.storeIntoRepositoryNoLoad.mibSourcePath- the directory (from theMIB.mibSourcePathserver configuration setting) against which themibFileparameter is resolved. A blank ornullvalue falls back to the current working directory.- Throws:
IllegalArgumentException- iftargetModeis not supported by this tool.
-
-
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
-