Skip to main content
Glama

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
NameRequiredDescriptionDefault
filterNoFilter that returns only revisions with certain tags. Only support one filter per request.
newerThanNoThe ID of the newest revision to return
olderThanNoThe ID of the oldest revision to return
titleYesWiki page title

Implementation Reference

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

Other Tools

Related Tools

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