update_confluence_page
Modify existing Confluence pages by updating titles, content, and version numbers to maintain current documentation.
Instructions
Update an existing page
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pageId | Yes | ID of the page to update | |
| title | Yes | New title of the page | |
| content | Yes | New content in Confluence storage format | |
| version | Yes | Current version number of the page |
Implementation Reference
- src/handlers/page-handlers.ts:235-280 (handler)MCP tool handler: validates parameters, calls ConfluenceClient.updateConfluencePage, formats and returns the updated page metadata as JSON.export async function handleUpdateConfluencePage( client: ConfluenceClient, args: { pageId: string; title: string; content: string; version: number } ): Promise<{ content: Array<{ type: "text"; text: string }>; }> { try { if (!args.pageId || !args.title || !args.content || args.version === undefined) { throw new McpError( ErrorCode.InvalidParams, "pageId, title, content, and version are required" ); } const page = await client.updateConfluencePage( args.pageId, args.title, args.content, args.version ); const simplified = { id: page.id, version: page.version.number, url: page._links.webui }; return { content: [ { type: "text", text: JSON.stringify(simplified), }, ], }; } catch (error) { console.error("Error updating page:", error instanceof Error ? error.message : String(error)); if (error instanceof McpError) { throw error; } throw new McpError( ErrorCode.InternalError, `Failed to update page: ${error instanceof Error ? error.message : String(error)}` ); } }
- src/schemas/tool-schemas.ts:113-137 (schema)Input schema definition for the update_confluence_page tool, specifying parameters pageId, title, content, version as required.update_confluence_page: { description: "Update an existing page", inputSchema: { type: "object", properties: { pageId: { type: "string", description: "ID of the page to update", }, title: { type: "string", description: "New title of the page", }, content: { type: "string", description: "New content in Confluence storage format", }, version: { type: "number", description: "Current version number of the page", }, }, required: ["pageId", "title", "content", "version"], }, },
- src/index.ts:236-247 (registration)Tool registration in MCP server's CallToolRequestHandler switch statement, dispatching to handleUpdateConfluencePage.case "update_confluence_page": { const { pageId, title, content, version } = (args || {}) as { pageId: string; title: string; content: string; version: number; }; if (!pageId || !title || !content || version === undefined) { throw new McpError(ErrorCode.InvalidParams, "pageId, title, content, and version are required"); } return await handleUpdateConfluencePage(this.confluenceClient, { pageId, title, content, version }); }
- ConfluenceClient helper: constructs PUT request body and calls Confluence v2 API to update the specified page.async updateConfluencePage(pageId: string, title: string, content: string, version: number): Promise<Page> { const body = { id: pageId, status: 'current', title, body: { representation: 'storage', value: content }, version: { number: version + 1, message: `Updated via MCP at ${new Date().toISOString()}` } }; const response = await this.v2Client.put(`/pages/${pageId}`, body); return response.data; }