add-wiki
Adds a new MediaWiki instance to the MCP server by providing any URL from the target wiki, enabling integration with MediaWiki resources.
Instructions
Adds a new wiki to the MCP resources from a URL.
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/add-wiki.ts:24-71 (handler)The core handler function that implements the 'add-wiki' tool logic: discovers wiki from URL, adds it to wikiService, sends resource list change notification, with proper error handling.async function handleAddWikiTool( server: McpServer, wikiUrl: string ): Promise<CallToolResult> { const wikiInfo = await discoverWiki( wikiUrl ); if ( wikiInfo === null ) { return { content: [ { type: 'text', text: 'Failed to determine wiki info. Please ensure the URL is correct and the wiki is accessible.' } as TextContent ], isError: true }; } try { const newConfig = { sitename: wikiInfo.sitename, server: wikiInfo.server, articlepath: wikiInfo.articlepath, scriptpath: wikiInfo.scriptpath, token: null, private: false }; wikiService.add( wikiInfo.servername, newConfig ); server.sendResourceListChanged(); return { content: [ { type: 'text', text: `${ wikiInfo.sitename } (mcp://wikis/${ wikiInfo.servername }) has been added to MCP resources.` } as TextContent ] }; } catch ( error ) { return { content: [ { type: 'text', text: `Failed to add wiki: ${ ( error as Error ).message }` } as TextContent ], isError: true }; } }
- src/tools/add-wiki.ts:9-22 (registration)Registers the 'add-wiki' tool on the MCP server, defining its name, description, input schema (wikiUrl), annotations, and handler function.export function addWikiTool( server: McpServer ): RegisteredTool { return server.tool( 'add-wiki', 'Adds a new wiki to the MCP resources from a URL.', { wikiUrl: z.string().url().describe( 'Any URL from the target wiki (e.g. https://en.wikipedia.org/wiki/Main_Page)' ) }, { title: 'Add wiki', destructiveHint: true } as ToolAnnotations, ( { wikiUrl } ) => handleAddWikiTool( server, wikiUrl ) ); }
- src/tools/add-wiki.ts:14-15 (schema)Zod schema for the tool input: wikiUrl as a valid URL string.wikiUrl: z.string().url().describe( 'Any URL from the target wiki (e.g. https://en.wikipedia.org/wiki/Main_Page)' ) },
- src/tools/index.ts:41-51 (registration)Central registration function that invokes all tool registrars, including addWikiTool, to register 'add-wiki' among other tools.export function registerAllTools( server: McpServer ): RegisteredTool[] { const registeredTools: RegisteredTool[] = []; for ( const registrar of toolRegistrars ) { try { registeredTools.push( registrar( server ) ); } catch ( error ) { console.error( `Error registering tool: ${ ( error as Error ).message }` ); } } return registeredTools; }
- src/tools/index.ts:9-9 (registration)Import of the addWikiTool registrar from its implementation file.import { addWikiTool } from './add-wiki.js';