Skip to main content
Glama
KS-GEN-AI

Confluence Communication Server

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
NameRequiredDescriptionDefault
pageIdYesConfluence Page ID
contentYesHTML content to update the page with
titleNoPage title (optional, if you want to change it)

Implementation Reference

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

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/KS-GEN-AI/confluence-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server