undelete-page
Restores a deleted wiki page with full revision history. Requires deleted state and undelete permission.
Instructions
Restores a previously deleted wiki page, including its full revision history, and returns the restored title. The page must currently be in a deleted state (from delete-page); fails if no deleted revisions exist for the title or the authenticated user lacks the undelete permission.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| title | Yes | Wiki page title | |
| comment | No | Reason for undeleting the page |
Implementation Reference
- src/tools/undelete-page.ts:29-45 (handler)The handle function that executes the undelete-page tool logic. Calls mwn.undelete() with the title, formatted comment, and edit options. Returns the restored title and revision count.
async handle({ title, comment }, ctx: ToolContext): Promise<CallToolResult> { const mwn = await ctx.mwn(); const options = ctx.edit.applyTags<ApiUndeleteParams>({}); const data: ApiUndeleteResponse & { revisions?: number } = await mwn.undelete( title, formatEditComment('undelete-page', comment), options, ); return ctx.format.ok({ // oxlint-disable-next-line typescript/no-unsafe-type-assertion -- mwn API response shape; trusted at this boundary title: data.title as string, restored: true as const, revisionCount: data.revisions, }); }, }; - src/tools/undelete-page.ts:9-12 (schema)Zod input schema for the undelete-page tool: requires 'title' (string) and optional 'comment' (string) for the undeletion reason.
const inputSchema = { title: z.string().describe('Wiki page title'), comment: z.string().optional().describe('Reason for undeleting the page'), } as const; - src/tools/index.ts:57-64 (registration)Registration of undeletePage in the standardTools array, which gets registered with the MCP server via the registerAllTools function.
undeletePage, uploadFile, uploadFileFromUrl, updateFile, updateFileFromUrl, oauthStatus, oauthLogout, ]; - src/wikis/utils.ts:12-18 (helper)Helper function formatEditComment used to format the edit summary for the undelete action, appending '(via undelete-page on MediaWiki MCP Server)'.
export function formatEditComment(tool: string, comment?: string): string { const suffix = `(via ${tool} on MediaWiki MCP Server)`; if (!comment) { return `Automated edit ${suffix}`; } return `${comment} ${suffix}`; } - src/runtime/reconcile.ts:33-42 (registration)Tool gating: 'undelete-page' is listed in WRITE_TOOL_NAMES to conditionally hide it when the wiki is in read-only mode.
const WRITE_TOOL_NAMES: readonly string[] = [ 'create-page', 'update-page', 'delete-page', 'undelete-page', 'upload-file', 'upload-file-from-url', 'update-file', 'update-file-from-url', ];