Skip to main content
Glama
ProfessionalWiki

mediawiki-mcp-server

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
NameRequiredDescriptionDefault
wikiUrlYesAny URL from the target wiki (e.g. https://en.wikipedia.org/wiki/Main_Page)

Implementation Reference

  • 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
    		};
    	}
    }
  • 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 )
    	);
    }
  • 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)' )
    },
  • 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';

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ProfessionalWiki/MediaWiki-MCP-Server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server