Annotation Interface McpTool


@Retention(RUNTIME) @Target(METHOD) public @interface McpTool
Marks a method as an MCP (Model Context Protocol) tool.

MCP tools are exposed to the LLM and can be called during completion. They replace the legacy AgentTool annotation with a more structured approach compatible with the Model Context Protocol.

Example:


   @McpTool(
       name = "get_weather",
       description = "Get current weather for a location",
       parameters = "{\"type\":\"object\",\"properties\":{\"location\":{\"type\":\"string\"}}}"
   )
   public String getWeather(AgentToolContext ctx, String location) {
       return "Weather in " + location + ": Sunny, 25°C";
   }

Use this instead of the legacy @AgentTool for new tools. The old @AgentTool is kept for backward compatibility.
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    Human-readable description of what the tool does.
    The tool name used by the LLM to invoke it.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    boolean
    Whether this tool only works in DMs.
    boolean
    Whether this tool only works in guild channels.
    Keywords for tool discovery.
    JSON Schema describing the tool's parameters.
    Required permission level.
    int
    Tool priority (higher = more important).
  • Element Details

    • name

      String name
      The tool name used by the LLM to invoke it.
    • description

      String description
      Human-readable description of what the tool does.
    • parameters

      String parameters
      JSON Schema describing the tool's parameters. Should be a valid JSON Schema object string.
      Default:
      ""
    • keywords

      String[] keywords
      Keywords for tool discovery.
      Default:
      {}
    • guildOnly

      boolean guildOnly
      Whether this tool only works in guild channels.
      Default:
      false
    • dmOnly

      boolean dmOnly
      Whether this tool only works in DMs.
      Default:
      false
    • permission

      Required permission level.
      Default:
      EVERYONE
    • priority

      int priority
      Tool priority (higher = more important).
      Default:
      0