set-wiki
Configure the MediaWiki instance for your current session. Call this tool when switching to a different wiki to ensure proper interaction with the selected platform.
Instructions
Sets the wiki to use for the current session. You MUST call this tool when interacting with a new wiki.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| uri | Yes | MCP resource URI of the wiki to use (e.g. mcp://wikis/en.wikipedia.org) |
Implementation Reference
- src/tools/set-wiki.ts:25-61 (handler)The handler function for the set-wiki tool. Parses the provided URI to extract wikiKey, checks if the wiki exists, sets it as current using wikiService, clears MWN cache, and returns a success message with wiki details or an error if invalid.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)Registers the set-wiki tool with the MCP server, specifying name, description, input schema (uri as string), tool annotations, and references the handleSetWikiTool 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/set-wiki.ts:15-16 (schema)Zod schema for the set-wiki tool input parameters: uri as a string describing the MCP resource URI of the wiki.uri: z.string().describe( 'MCP resource URI of the wiki to use (e.g. mcp://wikis/en.wikipedia.org)' ) },
- src/tools/index.ts:22-39 (registration)Includes the setWikiTool registrar in the array of all tool registrars used by registerAllTools to register all wiki tools with the MCP server.const toolRegistrars = [ getPageTool, getPageHistoryTool, searchPageTool, setWikiTool, addWikiTool, removeWikiTool, updatePageTool, getFileTool, createPageTool, uploadFileTool, uploadFileFromUrlTool, deletePageTool, getRevisionTool, undeletePageTool, getCategoryMembersTool, searchPageByPrefixTool ];
- src/tools/index.ts:8-8 (registration)Imports the setWikiTool function from set-wiki for inclusion in the tools registry.import { setWikiTool } from './set-wiki.js';