Annotation Interface Tool


@Retention(RUNTIME) @Target(TYPE) public @interface Tool
Marks a McpTool subclass as an MCP tool and declares its metadata, discovered by
invalid reference
McpConfig#toolsPackage(String)
.

 @Tool(
     name = "get_weather",
     description = "Get current weather for a city",
     args = @ToolArg(name = "city", description = "City name", required = true)
 )
 public class GetWeatherTool extends McpTool {
     @Override
     public ToolResponse call(ToolArguments args) {
         return ToolResponse.success(new TextContent(weatherService.fetch(args.getString("city"))));
     }
 }
 
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    Unique tool name (used by clients in tools/call).
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Input arguments — assembled into the tool's JSON Schema inputSchema once at boot.
    Human/model-readable description of what the tool does.
    Optional display title, distinct from name().
  • Element Details

    • name

      String name
      Unique tool name (used by clients in tools/call).
    • description

      String description
      Human/model-readable description of what the tool does.
      Default:
      ""
    • title

      String title
      Optional display title, distinct from name().
      Default:
      ""
    • args

      ToolArg[] args
      Input arguments — assembled into the tool's JSON Schema inputSchema once at boot.
      Default:
      {}