MCP Tool API

Version 7.1 by Vincent Massol on 2026/09/04 19:19

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.

Methods

getToolDefinition

McpSchema.Tool getToolDefinition()

Returns the MCP tool definition: name, description, and input JSON schema. It is sent to the model on every call, so it stays lean. Build the schema with MCPToolSupport rather than by hand.

execute

McpSchema.CallToolResult execute(McpSchema.CallToolRequest request)

Executes the tool call. Runs as the authenticated user on the request thread. Return failures as isError results whose message names the corrective action.

isEnabled

default boolean isEnabled()

Global kill switch. Disabled tools are not registered on any wiki. Default: true.

isWrite

default boolean isWrite()

Whether the tool modifies wiki content. Write tools are off by default per wiki. Default: false.

getCategory

default String getCategory()

The group the tool appears under in the man catalog. Default: "General".

getSummary

default String getSummary()

One-line summary, used as the catalog tagline and the NAME line. Default: null, in which case man falls back to the first sentence of the definition's description.

getManPage

default String getManPage()

The long-form prose man appends below the generated sections, kept out of the tool definition so it is not shipped on every call. Default: null.

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 Agent-Facing Text: 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