Class SnmpSet

java.lang.Object
org.snmp4j.mcp.tool.snmp.set.SnmpSet
All Implemented Interfaces:
McpTool

public class SnmpSet extends Object implements McpTool
MCP Tool that issues an SNMP GET (default, read-only) or SET request against a configured target. The variable bindings are supplied as a single plain-text string — one entry per line or per comma, auto-detected by the separator that appears first in the input.

Input format:

  • Read-only mode (default): each entry is an OID, e.g. 1.3.6.1.2.1.1.1.0, 1.3.6.1.2.1.1.5.0. If an entry contains an =, the part after it is ignored.
  • Write mode (set=true): each entry is OID=value; the value string follows the SNMP4J inline syntax (e.g. 1.3.6.1.2.1.1.5.0=string:newName). When no type: prefix is present and a SmiManager is configured, the type is resolved from the MIB; otherwise the value falls back to OctetString.

The Target, Snmp session, and PduBuilder are obtained via McpSnmpBuilder — following the same pattern as McpSnmpTree.

Since:
0.1.0
  • Field Details

  • Constructor Details

    • SnmpSet

      public SnmpSet(Supplier<List<SnmpMcpServer.ServerConfiguration.SnmpTargetConfig>> snmpTargetsSupplier, com.snmp4j.smi.SmiManager smiManager)
      Creates a new SNMP GET/SET tool.
      Parameters:
      snmpTargetsSupplier - supplies the list of configured SNMP targets
      smiManager - used for value parsing and MIB-aware response formatting; may be null
  • 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
    • 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
    • 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
    • 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
    • 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
    • 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
    • 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