Skip to main content
Glama

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
NameRequiredDescriptionDefault
uriYesMCP resource URI of the wiki to use (e.g. mcp://wikis/en.wikipedia.org)

Implementation Reference

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

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