remove-wiki
Remove a wiki from MCP resources using its URI. Clears cached credentials and license metadata; requires the wiki to be inactive.
Instructions
Removes a wiki from the MCP resources. Clears any cached credentials and license metadata for the wiki. Fails if the specified wiki is currently active; call set-wiki to switch to a different wiki first.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| uri | Yes | MCP resource URI of the wiki to remove (e.g. mcp://wikis/en.wikipedia.org) |
Implementation Reference
- src/tools/remove-wiki.ts:28-60 (handler)The handle() function that executes the remove-wiki tool logic. Parses the wiki resource URI, validates the wiki exists and is not currently active, then removes it from the registry, invalidates caches, and triggers reconciliation.
async handle({ uri }, ctx: ManagementContext): Promise<CallToolResult> { let wikiKey: string; try { ({ wikiKey } = parseWikiResourceUri(uri)); } catch (error) { if (error instanceof InvalidWikiResourceUriError) { return ctx.format.invalidInput(error.message); } throw error; } const wikiToRemove = ctx.wikis.get(wikiKey); if (!wikiToRemove) { return ctx.format.invalidInput(`mcp://wikis/${wikiKey} not found in MCP resources`); } if (ctx.selection.getCurrent().key === wikiKey) { return ctx.format.conflict( 'Cannot remove the currently active wiki. Please set a different wiki as the active wiki before removing this one.', ); } ctx.wikis.remove(wikiKey); ctx.wikiCache.invalidate(wikiKey); await ctx.reconcile(); return ctx.format.ok({ wikiKey, sitename: wikiToRemove.sitename, removed: true as const, }); }, }; - src/tools/remove-wiki.ts:7-11 (schema)Input schema for remove-wiki: requires a 'uri' string (MCP resource URI of the wiki to remove, e.g. mcp://wikis/en.wikipedia.org).
const inputSchema = { uri: z .string() .describe('MCP resource URI of the wiki to remove (e.g. mcp://wikis/en.wikipedia.org)'), } as const; - src/tools/index.ts:32-67 (registration)The removeWiki tool is imported from ./remove-wiki.js and added to the managementTools array (line 67) alongside addWiki and setWiki. It is registered in registerAllTools via dispatch with ManagementContext.
import { removeWiki } from './remove-wiki.js'; import { setWiki } from './set-wiki.js'; import { oauthStatus } from './oauth-status.js'; import { oauthLogout } from './oauth-logout.js'; // `Tool<any>` widens the heterogeneous-schema array; `inputSchema: TSchema` // is invariant in `TSchema`, so `Tool<never>` and `Tool<ZodRawShape>` both // fail this assignment. The dispatcher's own generic re-narrows TSchema // when each tool's handler is wrapped. // oxlint-disable-next-line typescript/no-explicit-any const standardTools: Tool<any>[] = [ getPage, getPages, getPageHistory, getRecentChanges, searchPage, searchPageByPrefix, parseWikitext, comparePages, getFile, getRevision, getCategoryMembers, createPage, updatePage, deletePage, undeletePage, uploadFile, uploadFileFromUrl, updateFile, updateFileFromUrl, oauthStatus, oauthLogout, ]; // oxlint-disable-next-line typescript/no-explicit-any const managementTools: Tool<any, ManagementContext>[] = [addWiki, removeWiki, setWiki]; - src/runtime/reconcile.ts:62-66 (helper)Reconciliation gating rule: remove-wiki tool is only allowed when allowManagement is true AND there are at least 2 wikis configured (wikiCount >= 2).
{ name: 'remove-wiki', affects: ['remove-wiki'], isAllowed: (c) => c.allowManagement && c.wikiCount >= 2, }, - src/wikis/wikiCache.ts:9-28 (helper)WikiCache interface and WikiCacheImpl implementation used by remove-wiki's handler to invalidate cached wiki state (mwn provider, license cache, extension detector) when a wiki is removed.
export interface WikiCache { /** Drops every cache entry keyed by `wikiKey`. */ invalidate(wikiKey: string): void; } export class WikiCacheImpl implements WikiCache { public constructor( private readonly mwnProvider: Pick<MwnProvider, 'invalidate'>, private readonly licenseCache: Pick<LicenseCache, 'delete'>, private readonly extensionDetector: Pick<ExtensionDetector, 'invalidate'>, ) {} public invalidate(wikiKey: string): void { this.mwnProvider.invalidate(wikiKey); this.licenseCache.delete(wikiKey); this.extensionDetector.invalidate(wikiKey); } }