Skip to main content
Glama
ProfessionalWiki

mediawiki-mcp-server

update-page

Destructive

Update MediaWiki page content by replacing existing text with new source material using revision IDs to maintain edit history.

Instructions

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

Input Schema

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

Implementation Reference

  • The handler function that executes the tool logic: makes a REST PUT request to update the wiki page with new source, using the provided latest revision ID as base, handles errors, and returns formatted result.
    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 )
    	};
    }
  • Registers the 'update-page' tool with the MCP server, defines input schema using Zod, tool annotations, and links to the handler function.
    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 )
    	);
    }
  • Helper function to format the successful update result into TextContent array with page details.
    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 registration: includes updatePageTool in the list of registrars and calls them all to register tools with the MCP server.
    const toolRegistrars = [
    	getPageTool,
    	getPageHistoryTool,
    	searchPageTool,
    	setWikiTool,
    	addWikiTool,
    	removeWikiTool,
    	updatePageTool,
    	getFileTool,
    	createPageTool,
    	uploadFileTool,
    	uploadFileFromUrlTool,
    	deletePageTool,
    	getRevisionTool,
    	undeletePageTool,
    	getCategoryMembersTool,
    	searchPageByPrefixTool
    ];
    
    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;
    }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations indicate destructiveHint=true and readOnlyHint=false, which the description aligns with by stating it 'replaces the existing content.' However, the description adds minimal behavioral context beyond this, such as not explaining potential side effects like versioning or permissions required. No contradiction with annotations exists.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise with two sentences that directly state the tool's function and key behavior. It's front-loaded with the main action, though it could be slightly more structured by explicitly mentioning parameters or usage context.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the destructive nature (annotations) and lack of output schema, the description adequately covers the basic update operation but lacks details on error handling, response format, or integration with sibling tools. It's minimal but sufficient for a straightforward update tool with good schema coverage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents parameters like 'title', 'source', 'latestId', and 'comment'. The description implies 'source' is for new content and 'latestId' for version control but doesn't add significant meaning beyond what the schema provides, meeting the baseline for high coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Updates') and resource ('a wiki page'), specifying that it replaces existing content with provided content. It distinguishes from siblings like 'create-page' by focusing on updates rather than creation, though it doesn't explicitly contrast with all similar tools like 'undelete-page'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives such as 'create-page' for new pages or 'undelete-page' for restoring deleted content. It mentions replacing existing content but doesn't clarify prerequisites like needing the page to already exist or when to use other update-related tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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