update_page_content
Modify Confluence page content and optionally change the title by providing HTML content and page ID.
Instructions
Update the content of a Confluence page
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pageId | Yes | Confluence Page ID | |
| content | Yes | HTML content to update the page with | |
| title | No | Page title (optional, if you want to change it) |
Implementation Reference
- src/index.ts:158-208 (handler)The core handler function that updates the Confluence page content. It fetches the current page to get the version, constructs the update payload, and performs a PUT request to the Confluence API.async function updatePageContent( pageId: string, content: string, title?: string, ): Promise<any> { try { // First, get the current page to retrieve its version and other details const currentPage = await getPageContent(pageId); if (currentPage.error) { return { error: `Failed to get current page: ${currentPage.error}`, }; } // Create update payload const updatePayload = { id: pageId, type: currentPage.type, title: title || currentPage.title, space: currentPage.space, body: { storage: { value: content, representation: 'storage', }, }, version: { number: currentPage.version.number + 1, }, }; // Update the page const response = await axios.put( `${CONFLUENCE_URL}/wiki/rest/api/content/${pageId}`, updatePayload, { headers: { ...getAuthHeaders().headers, 'Content-Type': 'application/json', }, }, ); return response.data; } catch (error: any) { return { error: error.response ? error.response.data : error.message, }; } }
- src/index.ts:73-94 (registration)Registers the 'update_page_content' tool in the ListTools response, including name, description, and input schema.{ name: 'update_page_content', description: 'Update the content of a Confluence page', inputSchema: { type: 'object', properties: { pageId: { type: 'string', description: 'Confluence Page ID', }, content: { type: 'string', description: 'HTML content to update the page with', }, title: { type: 'string', description: 'Page title (optional, if you want to change it)', }, }, required: ['pageId', 'content'], }, },
- src/index.ts:76-93 (schema)Defines the input schema for the 'update_page_content' tool, specifying required pageId and content, optional title.inputSchema: { type: 'object', properties: { pageId: { type: 'string', description: 'Confluence Page ID', }, content: { type: 'string', description: 'HTML content to update the page with', }, title: { type: 'string', description: 'Page title (optional, if you want to change it)', }, }, required: ['pageId', 'content'], },
- src/index.ts:270-294 (handler)Dispatches the tool call within the CallToolRequestHandler, validates arguments, calls the updatePageContent function, and formats the response.case 'update_page_content': { const pageId = String(request.params.arguments?.pageId); const content = String(request.params.arguments?.content); const title = request.params.arguments?.title ? String(request.params.arguments?.title) : undefined; if (!pageId) { throw new Error('Page ID is required'); } if (!content) { throw new Error('Content is required'); } const response = await updatePageContent(pageId, content, title); return { content: [ { type: 'text', text: JSON.stringify(response, null, 2), }, ], }; }