Wiki source code of MCP Server
Last modified by gabrielc on 2026/05/12 10:32
Show last authors
| author | version | line-number | content |
|---|---|---|---|
| 1 | The MCP server can be used to give an LLM-based agent access to data that is indexed in the [[index for the LLM application>>doc:extensions:Extension.LLM.Index for the LLM Application.WebHome]]. For example, a coding agent could use this to access technical documentation in the wiki. | ||
| 2 | |||
| 3 | == Authentication == | ||
| 4 | |||
| 5 | The MCP uses XWiki's configured authentication method(s). By default, it doesn't ask for authentication which makes it possible to also query collections that are available to guests. An authentication header, e.g., for basic auth can be used to authenticate the user using the configured authentication method in XWiki. | ||
| 6 | |||
| 7 | When the [[OpenID Connect Provider extension>>doc:extensions:Extension.OpenID Connect.OpenID Connect Provider.WebHome]] is installed: | ||
| 8 | |||
| 9 | * Access for guest users is denied. | ||
| 10 | * The OpenID connect provider is indicated as the authentication method. | ||
| 11 | * The MCP client should trigger an authentication flow to obtain an authentication token. | ||
| 12 | |||
| 13 | For the OpenID Connect Provider to work properly, "Set authentication service" must be changed to "Token based authenticator" (see "[[Choose the authenticator>>path:/xwiki/bin/get/documentation/extensions/user/llm/mcp-server/?sheet=CKEditor.ResourceDispatcher&outputSyntax=plain&language=en&type=doc&reference=Documentation.AdminGuide.Authentication.WebHome&typed=true¶meters%5Banchor%5D=HChoosetheauthenticator]]") in Administer Wiki > Users & Rights > Authentication. You can set up a fallback authenticator by following the instructions on the [[OpenID Connect Provider>>path:/xwiki/bin/get/documentation/extensions/user/llm/mcp-server/?sheet=CKEditor.ResourceDispatcher&outputSyntax=plain&language=en&type=doc&reference=extensions%3AExtension.OpenID%20Connect.OpenID%20Connect%20Provider.WebHome&typed=true¶meters%5Banchor%5D=HToken-basedaccess]] page. | ||
| 14 | |||
| 15 | == Authorization == | ||
| 16 | |||
| 17 | The MCP server exposes all collections that are enabled for queries for the current user. The collection settings allow controlling access by enabling/disabling guest access and configuring user groups that can query the collection. Inaccessible collections are ignored. Results are filtered based on the right checking method that is configured in the respective collection. | ||
| 18 | |||
| 19 | == Client Configuration == | ||
| 20 | |||
| 21 | The MCP server needs to be configured as "HTTP" or [[streamable HTTP>>https://modelcontextprotocol.io/specification/2025-11-25/basic/transports#streamable-http]] (without SSE) server, the URL is at ##https:~/~/<server>/<context>/rest/wikis/<wiki>/aiLLM/mcp## where ##<server>## is the domain and possibly port of the XWiki installation, ##<context>## is usually either empty or ##xwiki## (check if other URLs have the ##xwiki## prefix) and ##<wiki>## is the wiki where the collections are configured, ##xwiki## for the main wiki. | ||
| 22 | |||
| 23 | == Tools == | ||
| 24 | |||
| 25 | The MCP server currently supports the following tools: | ||
| 26 | |||
| 27 | === search_wiki === | ||
| 28 | |||
| 29 | Search the wiki using semantic and keyword similarity. Returns the most relevant content chunks from indexed pages. | ||
| 30 | |||
| 31 | ==== Parameters ==== | ||
| 32 | |||
| 33 | |=Parameter|=Type|=Required|=Description | ||
| 34 | |query|string|required|The text to search for. | ||
| 35 | |collections|array[string]|optional|Optional list of collection IDs to search in. Omit to search all accessible collections. | ||
| 36 | |limitKeywordResults|integer|optional|Maximum number of keyword search results (default: 10). | ||
| 37 | |limitSemanticResults|integer|optional|Maximum number of semantic similarity results (default: 10). | ||
| 38 | |||
| 39 | ==== Return format ==== | ||
| 40 | |||
| 41 | Text containing XML-like results; each result uses ##<result>##, with optional ##<url>##, ##<documentId>## and ##<content>## elements**.** | ||
| 42 | |||
| 43 | === list_collections === | ||
| 44 | |||
| 45 | List all collections available for searching. | ||
| 46 | |||
| 47 | ==== Parameters ==== | ||
| 48 | |||
| 49 | None (empty object) | ||
| 50 | |||
| 51 | ==== Return format ==== | ||
| 52 | |||
| 53 | Text with one collection id per line (newline-separated). |