MCPTool Interface

Version 3.1 by Vincent Massol on 2026/09/04 15:35

Content

Reference

The MCPTool interface (org.xwiki.contrib.llm.mcp.MCPTool) is the extension point for contributing tools to the XWiki MCP server.

MCP Server 0.9+ ​Annotations: @Role, @Unstable.

Methods

getToolDefinition

McpSchema.Tool getToolDefinition()

Returns the MCP tool definition: name, description, and input JSON schema. The description is sent to the LLM on every call — keep it lean.

execute

McpSchema.CallToolResult execute(McpSchema.CallToolRequest request)

Executes the tool call. Runs as the authenticated user on the request thread. Return errors as isError results with actionable messages.

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()

Category for the man catalog grouping. Default: "General".

getSummary

default String getSummary()

One-line summary for the man catalog listing. Default: null.

getManPage

default String getManPage()

Long-form documentation prose for the man tool. Include EXAMPLES section. Default: null.

Conventions

  • The component hint (@Named) is the stable tool id — used in configuration and logs.
  • The description in getToolDefinition() must never duplicate parameter descriptions (they ship in the same payload).
  • Parameter descriptions state defaults explicitly: "(default 10)."
  • Every error message ends with the corrective next action when one exists.
  • Use "Error: " prefix only for malformed parameters. State outcomes (not found, not authorized) have no prefix.

Bundled tool metadata

Tool ID Category Write Summary
man Help No Show documentation for the available MCP tools.
get_attachment Search & Navigation No Read an attachment's content or metadata from a document.
get_document Search & Navigation No Read an XWiki document's content (full, by line range, or outline).
get_history Search & Navigation No Read a document's revision history, one revision's content, or a diff.
get_links Search & Navigation No List the pages linking to a document (backlinks), or its own outgoing links.
get_tree Search & Navigation No Survey a wiki or explore a subtree as an indented page tree.
list_wikis Search & Navigation No List the wikis reachable from this MCP endpoint.
query_documents Search & Navigation No Search and browse XWiki documents via the wiki's Solr index.
get_schema Structured Data No Describe an XWiki class: its fields and their types, or list all classes with instance counts.
query_objects Structured Data No Find structured objects (XObjects) by class and field filters.
write_object Structured Data Yes Create a structured object or set fields on an existing one (schema-validated).
write_schema Structured Data Yes Create or change an XClass definition (add, modify or remove a field).
delete_object Structured Data Yes Remove one structured object from a document.
edit_document Authoring Yes Edit a document's content and title by exact string replacement.
write_document Authoring Yes Create a document or replace its entire content.
write_attachment Authoring Yes Attach a file to a document, or overwrite an existing attachment.
delete_document Authoring Yes Delete a document (moves it to the recycle bin).
delete_attachment Authoring Yes Delete an attachment from a document.

The AI-LLM indexing module contributes two more when it is installed, both in the Semantic Search category and neither a write tool: search_collections and list_collections.

Get Connected