Skip to main content
Glama

update-page

Update Notion page properties and content using the Notion MCP Server to modify existing pages in your workspace.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
page_idYesThe ID of the page to update
propertiesYesJSON string of page properties to update
archivedNoWhether to archive the page

Implementation Reference

  • The handler function for the 'update-page' MCP tool. It parses the JSON properties input, optionally handles archiving, calls the NotionService.updatePage method, and returns the result as a formatted text content block or an error.
    async ({ page_id, properties, archived }) => {
      const params: any = {
        page_id,
        properties: JSON.parse(properties),
      };
    
      if (archived !== undefined) {
        params.archived = archived;
      }
    
      try {
        const page = await this.notionService.updatePage(params);
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(page, null, 2),
            },
          ],
        };
      } catch (error) {
        console.error("Error in update-page tool:", error);
        return {
          content: [
            {
              type: "text",
              text: `Error: Failed to update page - ${
                (error as Error).message
              }`,
            },
          ],
          isError: true,
        };
      }
  • Zod schema defining the input parameters for the 'update-page' tool: page_id (required string), properties (required JSON string), archived (optional boolean).
    {
      page_id: z.string().describe("The ID of the page to update"),
      properties: z
        .string()
        .describe("JSON string of page properties to update"),
      archived: z
        .boolean()
        .optional()
        .describe("Whether to archive the page"),
    },
  • The registration of the 'update-page' tool on the McpServer instance within the registerPageTools method, including schema and handler.
    this.server.tool(
      "update-page",
      {
        page_id: z.string().describe("The ID of the page to update"),
        properties: z
          .string()
          .describe("JSON string of page properties to update"),
        archived: z
          .boolean()
          .optional()
          .describe("Whether to archive the page"),
      },
      async ({ page_id, properties, archived }) => {
        const params: any = {
          page_id,
          properties: JSON.parse(properties),
        };
    
        if (archived !== undefined) {
          params.archived = archived;
        }
    
        try {
          const page = await this.notionService.updatePage(params);
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify(page, null, 2),
              },
            ],
          };
        } catch (error) {
          console.error("Error in update-page tool:", error);
          return {
            content: [
              {
                type: "text",
                text: `Error: Failed to update page - ${
                  (error as Error).message
                }`,
              },
            ],
            isError: true,
          };
        }
      }
    );
  • The NotionService.updatePage helper method invoked by the MCP tool handler. It calls the underlying Notion Client pages.update API with additional optional parameters like icon and cover.
    async updatePage(params: UpdatePage) {
      try {
        return await this.client.pages.update({
          page_id: params.page_id,
          properties: params.properties,
          archived: params.archived,
          icon: params.icon,
          cover: params.cover,
        });
      } catch (error) {
        this.handleError(error);
      }
    }

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/ramidecodes/mcp-server-notion'

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