get-page-history
Retrieve detailed revision history of a wiki page in segments of 20 revisions. Fetch API routes for next oldest, newest, and latest revision segments to navigate page changes efficiently.
Instructions
Returns information about the latest revisions to a wiki page, in segments of 20 revisions, starting with the latest revision. The response includes API routes for the next oldest, next newest, and latest revision segments.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filter | No | Filter that returns only revisions with certain tags. Only support one filter per request. | |
| newerThan | No | The ID of the newest revision to return | |
| olderThan | No | The ID of the oldest revision to return | |
| title | Yes | Wiki page title |
Implementation Reference
- src/tools/get-page-history.ts:30-73 (handler)Core handler function that constructs API parameters from inputs, makes a REST GET request to the MediaWiki API for page history, handles errors and empty results, and maps revisions to formatted text content using a helper function.async function handleGetPageHistoryTool( title: string, olderThan?: number, newerThan?: number, filter?: string ): Promise< CallToolResult > { const params: Record<string, string> = {}; if ( olderThan ) { params.olderThan = olderThan.toString(); } if ( newerThan ) { params.newerThan = newerThan.toString(); } if ( filter ) { params.filter = filter; } let data: MwRestApiGetPageHistoryResponse; try { data = await makeRestGetRequest<MwRestApiGetPageHistoryResponse>( `/v1/page/${ encodeURIComponent( title ) }/history`, params ); } catch ( error ) { return { content: [ { type: 'text', text: `Failed to retrieve page history: ${ ( error as Error ).message }` } as TextContent ], isError: true }; } if ( data.revisions.length === 0 ) { return { content: [ { type: 'text', text: 'No revisions found for page' } as TextContent ] }; } return { content: data.revisions.map( getPageHistoryToolResult ) }; }
- src/tools/get-page-history.ts:9-28 (registration)Tool registration function called by the index to register 'get-page-history' with the MCP server. Includes tool name, description, Zod input schema, annotations, and delegates to the handler function.export function getPageHistoryTool( server: McpServer ): RegisteredTool { return server.tool( 'get-page-history', 'Returns information about the latest revisions to a wiki page, in segments of 20 revisions, starting with the latest revision. The response includes API routes for the next oldest, next newest, and latest revision segments.', { title: z.string().describe( 'Wiki page title' ), olderThan: z.number().int().positive().optional().describe( 'Revision ID of the oldest revision to return' ), newerThan: z.number().int().positive().optional().describe( 'Revision ID of the newest revision to return' ), filter: z.string().optional().describe( 'Filter that returns only revisions with certain tags. Only support one filter per request.' ) }, { title: 'Get page history', readOnlyHint: true, destructiveHint: false } as ToolAnnotations, async ( { title, olderThan, newerThan, filter } ) => handleGetPageHistoryTool( title, olderThan, newerThan, filter ) ); }
- src/tools/get-page-history.ts:13-17 (schema)Zod schema defining the input parameters for the get-page-history tool: required title (string), optional olderThan/newerThan (positive integers), optional filter (string).{ title: z.string().describe( 'Wiki page title' ), olderThan: z.number().int().positive().optional().describe( 'Revision ID of the oldest revision to return' ), newerThan: z.number().int().positive().optional().describe( 'Revision ID of the newest revision to return' ), filter: z.string().optional().describe( 'Filter that returns only revisions with certain tags. Only support one filter per request.' )
- src/tools/get-page-history.ts:75-87 (helper)Helper function that transforms a MediaWiki revision object into a formatted text content block for the tool response.function getPageHistoryToolResult( result: MwRestApiRevisionObject ): TextContent { return { type: 'text', text: [ `Revision ID: ${ result.id }`, `Timestamp: ${ result.timestamp }`, `User: ${ result.user.name } (ID: ${ result.user.id })`, `Comment: ${ result.comment }`, `Size: ${ result.size }`, `Delta: ${ result.delta }` ].join( '\n' ) }; }
- src/tools/index.ts:41-51 (registration)Central registration function that invokes all individual tool registrars (including getPageHistoryTool) on the MCP server instance, collecting and returning the registered 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; }