Wiki source code of MCP Tool API

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

Hide last authors
Vincent Massol 6.1 1 The {{code}}MCPTool{{/code}} interface ({{code}}org.xwiki.contrib.llm.mcp.MCPTool{{/code}}), annotated {{code}}@Role{{/code}} and {{code}}@Unstable{{/code}}, 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 {{code}}man{{/code}} catalog and the logs print.
gabrielc 1.1 2
Vincent Massol 6.1 3 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 {{code}}man{{/code}} prints, and the tools shipped with the server are named on [[MCP Tools>>doc:documentation.extensions.user.llm.mcp-server.tools.WebHome]]. The AI-LLM indexing module contributes two more when it is installed, both in the {{code}}Semantic Search{{/code}} category and neither a write tool.
4
Vincent Massol 11.1 5 {{code}}getToolDefinition{{/code}} and {{code}}execute{{/code}} 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.
gabrielc 1.1 6
Vincent Massol 11.1 7 |=Member |=Returns |=Default |=What it does
8 |{{code}}getToolDefinition(){{/code}} |{{code}}McpSchema.Tool{{/code}} |//required// |The name, description and input JSON schema advertised to the model.
9 |{{code}}execute(CallToolRequest){{/code}} |{{code}}McpSchema.CallToolResult{{/code}} |//required// |Runs one tool call and returns its result.
10 |{{code}}isEnabled(){{/code}} |{{code}}boolean{{/code}} |{{code}}true{{/code}} |Global kill switch: a disabled tool is registered on no wiki.
11 |{{code}}isWrite(){{/code}} |{{code}}boolean{{/code}} |{{code}}false{{/code}} |Whether the tool modifies wiki content. Write tools are off by default on every wiki.
12 |{{code}}getCategory(){{/code}} |{{code}}String{{/code}} |{{code}}"General"{{/code}} |The group the tool appears under in the {{code}}man{{/code}} catalog.
13 |{{code}}getSummary(){{/code}} |{{code}}String{{/code}} |{{code}}null{{/code}} |The catalog tagline and the {{code}}NAME{{/code}} line. When {{code}}null{{/code}}, {{code}}man{{/code}} falls back to the first sentence of the definition's description.
14 |{{code}}getManPage(){{/code}} |{{code}}String{{/code}} |{{code}}null{{/code}} |The long-form prose {{code}}man{{/code}} appends below the generated sections, kept out of the definition so it is not shipped on every call.
gabrielc 1.1 15
Vincent Massol 11.1 16 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 {{code}}execute{{/code}} runs as the authenticated user on the request thread, reporting failure as an {{code}}isError{{/code}} result whose message names the corrective action. [[Create a New MCP Tool>>doc:documentation.extensions.dev.llm.mcp-server.create-mcp-tool.WebHome]] shows the component skeleton those two go in.

Get Connected