MCP Tool API

Last modified by Vincent Massol on 2026/09/04 20:04

Reference

The MCPTool interface (org.xwiki.contrib.llm.mcp.MCPTool), annotated @Role and @Unstable, is the extension point for contributing tools to the XWiki MCP server. The component hint is the tool's stable id: it is what the configuration stores, and what the man catalog and the logs print.

Each tool's id, category, write flag and one-line summary come from the component itself, so the list a wiki actually serves is the one man prints, and the tools shipped with the server are named on MCP Tools. The AI-LLM indexing module contributes two more when it is installed, both in the Semantic Search category and neither a write tool.

getToolDefinition and execute are the two members a tool must implement. The other five have defaults, and a tool overrides only the ones whose default does not describe it.

Member Returns Default What it does
getToolDefinition() McpSchema.Tool required The name, description and input JSON schema advertised to the model.
execute(CallToolRequest) McpSchema.CallToolResult required Runs one tool call and returns its result.
isEnabled() boolean true Global kill switch: a disabled tool is registered on no wiki.
isWrite() boolean false Whether the tool modifies wiki content. Write tools are off by default on every wiki.
getCategory() String "General" The group the tool appears under in the man catalog.
getSummary() String null The catalog tagline and the NAME line. When null, man falls back to the first sentence of the definition's description.
getManPage() String null The long-form prose man appends below the generated sections, kept out of the definition so it is not shipped on every call.

Both required members carry a contract their signature does not show: the definition is sent to the model on every call, so it stays lean, and execute runs as the authenticated user on the request thread, reporting failure as an isError result whose message names the corrective action. Create a New MCP Tool shows the component skeleton those two go in.

FAQ

How does a tool declare its parameters?

Through MCPToolSupport, which produces the advertised input schema and the typed accessors from one declaration. A hand-written schema is what lets the advertised parameters drift from the ones the tool reads.

Where are the rules for the text these methods return?

On Tool Man Pages: what man renders from each member, and the wording rules the bundled tools follow for descriptions and error messages.

Does a new tool need a server change?

No. The server has no compile-time knowledge of its tools: register the component, and it is discovered on the next request.

Related

Get Connected