set-wiki
Define the target wiki for the current session by specifying its URL, enabling direct interaction with the chosen MediaWiki instance.
Instructions
Set the wiki to use for the current session.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| wikiUrl | Yes | Any URL from the target wiki (e.g. https://en.wikipedia.org/wiki/Main_Page). |
Implementation Reference
- src/tools/set-wiki.ts:25-61 (handler)Implements the core logic of the 'set-wiki' tool: parses the provided URI to extract wikiKey, checks if the wiki exists in resources, sets it as the current wiki, clears the MW cache, and returns a success message with wiki details or an appropriate error.async function handleSetWikiTool( uri: string ): Promise<CallToolResult> { try { const { wikiKey } = parseWikiResourceUri( uri ); if ( !wikiService.get( wikiKey ) ) { return { content: [ { type: 'text', text: `mcp://wikis/${ wikiKey } not found in MCP resources.` } as TextContent ], isError: true }; } wikiService.setCurrent( wikiKey ); clearMwnCache(); const newConfig = wikiService.getCurrent().config; return { content: [ { type: 'text', text: `Wiki set to ${ newConfig.sitename } (${ newConfig.server })` } as TextContent ] }; } catch ( error ) { if ( error instanceof InvalidWikiResourceUriError ) { return { content: [ { type: 'text', text: error.message } as TextContent ], isError: true }; } throw error; } }
- src/tools/set-wiki.ts:10-23 (registration)Specific registrar function for the 'set-wiki' tool, called by the general registerAllTools. Defines tool name, description, input schema (uri: string), annotations, and links to the handler.export function setWikiTool( server: McpServer ): RegisteredTool { return server.tool( 'set-wiki', 'Sets the wiki to use for the current session. You MUST call this tool when interacting with a new wiki.', { uri: z.string().describe( 'MCP resource URI of the wiki to use (e.g. mcp://wikis/en.wikipedia.org)' ) }, { title: 'Set wiki', destructiveHint: true } as ToolAnnotations, ( { uri } ) => handleSetWikiTool( uri ) ); }
- src/tools/index.ts:22-39 (registration)The setWikiTool registrar (line 26) is listed here among all tool registrars. This array is iterated in registerAllTools(server) to register every tool including 'set-wiki'.const toolRegistrars = [ getPageTool, getPageHistoryTool, searchPageTool, setWikiTool, addWikiTool, removeWikiTool, updatePageTool, getFileTool, createPageTool, uploadFileTool, uploadFileFromUrlTool, deletePageTool, getRevisionTool, undeletePageTool, getCategoryMembersTool, searchPageByPrefixTool ];
- src/server.ts:29-29 (registration)Top-level call to registerAllTools on the MCP server instance, which triggers registration of 'set-wiki' via the chain.registerAllTools( server );