Backend API. Server-side code: this runs in a Codename One backend, not in the app on the device.

@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.

Methods

public abstract String name() default ""The tool’s name.
public abstract String description()What the tool does.

Method details

name

public abstract String name() default ""
The tool’s name. Empty means the method’s name.

description

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