Class GetMibFileTool

java.lang.Object
org.snmp4j.mcp.tool.mib.text.GetMibFileTool
All Implemented Interfaces:
McpTool

public class GetMibFileTool extends Object implements 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 fileName is given, it is resolved as a path relative to the configured MIB source directory and the text content of that file is returned.
  • When zipFileName is also given, zipFileName is resolved as a ZIP archive (relative to the source directory) and fileName is 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 Details

  • Constructor Details

    • GetMibFileTool

      public GetMibFileTool(String mibSourcePath)
      Creates a GetMibFileTool.
      Parameters:
      mibSourcePath - the directory (from the MIB.mibSourcePath server configuration setting) that holds the MIB source files this tool may read. A blank or null value falls back to the current working directory.
  • Method Details

    • getId

      public String getId()
      Description copied from interface: McpTool
      Gets the unique identifier for this tool.
      Specified by:
      getId in interface McpTool
      Returns:
      the tool ID
    • getName

      public String getName()
      Description copied from interface: McpTool
      Gets the display name for this tool.
      Specified by:
      getName in interface McpTool
      Returns:
      the tool name
    • getTitle

      public String getTitle()
      Description copied from interface: McpTool
      Gets the title associated with this tool.
      Specified by:
      getTitle in interface McpTool
      Returns:
      the tool title
    • getDescription

      public String getDescription()
      Description copied from interface: McpTool
      Gets the description for this tool.
      Specified by:
      getDescription in interface McpTool
      Returns:
      the tool description
    • getVersion

      public String getVersion()
      Description copied from interface: McpTool
      Gets the version of this tool.
      Specified by:
      getVersion in interface McpTool
      Returns:
      the tool version
    • getParameters

      public List<ToolParameter> getParameters()
      Description copied from interface: McpTool
      Gets the supported parameters for this tool.
      Specified by:
      getParameters in interface McpTool
      Returns:
      a list of parameter descriptions
    • execute

      public ToolResult execute(Map<String,Object> params) throws McpToolException
      Description copied from interface: McpTool
      Executes the tool with the provided parameters.
      Specified by:
      execute in interface McpTool
      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: McpTool
      Checks if the tool is available in the current environment.
      Specified by:
      isAvailable in interface McpTool
      Returns:
      true if the tool is available, false otherwise
    • getRequiredContexts

      public List<String> getRequiredContexts()
      Description copied from interface: McpTool
      Gets the contexts that this tool requires.
      Specified by:
      getRequiredContexts in interface McpTool
      Returns:
      a list of required context IDs
    • getAnnotation

      public io.modelcontextprotocol.spec.McpSchema.ToolAnnotations getAnnotation()
      Description copied from interface: McpTool
      Gets the tool annotations. By default, readOnly, hidden, idempotent, openWorld are true while destructive and returnDirect are false.
      Specified by:
      getAnnotation in interface McpTool
      Returns:
      McpSchema.ToolAnnotations