Annotation Type McpTool


@Retention(CLASS) @Target(METHOD) public @interface McpTool

Publishes this method of a bean as a tool on the server's MCP endpoint, so an agent can call it.

The build writes the tool's JSON Schema from the parameter types and a dispatcher that converts the call's arguments and invokes the method directly. The parameters may be strings, numbers, booleans, or maps and lists of those; each needs McpParam to name it, because a Java parameter name does not survive compilation. The result is written with Json.

The endpoint is at cn1.mcp.path (default /mcp). Outside a development profile it requires cn1.mcp.token and refuses to start without one, because a tool reachable by anyone is a vulnerability rather than a feature.

  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    What the tool does.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    The tool's name.
  • Element Details

    • name

      String name
      The tool's name. Empty means the method's name.
      Default:
      ""
    • description

      String description
      What the tool does. Agents choose tools by this text, so say when to use it, not only what it is.