Skip to main content
Glama

update-page

Modify wiki pages by replacing existing content with updated text. Requires a page title, new source content, and a base revision ID for accurate updates.

Instructions

Updates a wiki page. Replaces the existing content of a page with the provided content

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
commentNoSummary of the edit
latestIdYesIdentifier for the revision used as the base for the new source
sourceYesPage content in the same content model of the existing page
titleYesWiki page title

Implementation Reference

  • Registers the 'update-page' tool (includes schema and handler reference) with the MCP server using server.tool().
    export function updatePageTool( server: McpServer ): RegisteredTool { return server.tool( 'update-page', 'Updates a wiki page. Replaces the existing content of a page with the provided content', { title: z.string().describe( 'Wiki page title' ), source: z.string().describe( 'Page content in the same content model of the existing page' ), latestId: z.number().int().positive().describe( 'Revision ID used as the base for the new source' ), comment: z.string().optional().describe( 'Summary of the edit' ) }, { title: 'Update page', readOnlyHint: false, destructiveHint: true } as ToolAnnotations, async ( { title, source, latestId, comment } ) => handleUpdatePageTool( title, source, latestId, comment ) ); }
  • The core handler logic that performs the REST PUT request to update the wiki page, handles errors, and returns success or error results.
    async function handleUpdatePageTool( title: string, source: string, latestId: number, comment?: string ): Promise<CallToolResult> { let data: MwRestApiPageObject; try { data = await makeRestPutRequest<MwRestApiPageObject>( `/v1/page/${ encodeURIComponent( title ) }`, { source: source, comment: formatEditComment( 'update-page', comment ), latest: { id: latestId } }, true ); } catch ( error ) { return { content: [ { type: 'text', text: `Failed to update page: ${ ( error as Error ).message }` } as TextContent ], isError: true }; } return { content: updatePageToolResult( data ) }; }
  • Helper function to format the API response into user-friendly text content blocks.
    function updatePageToolResult( result: MwRestApiPageObject ): TextContent[] { return [ { type: 'text', text: `Page updated successfully: ${ getPageUrl( result.title ) }` }, { type: 'text', text: [ 'Page object:', `Page ID: ${ result.id }`, `Title: ${ result.title }`, `Latest revision ID: ${ result.latest.id }`, `Latest revision timestamp: ${ result.latest.timestamp }`, `Content model: ${ result.content_model }`, `License: ${ result.license.url } ${ result.license.title }`, `HTML URL: ${ result.html_url }` ].join( '\n' ) } ]; }
  • Top-level function that registers all tools, including updatePageTool via its inclusion in toolRegistrars array (lines 22-39). Note: import at line 11.
    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