Skip to main content
Glama

update-block

Modify existing Notion blocks by updating their properties using JSON data to keep content current and organized.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
block_idYesThe ID of the block to update
propertiesYesJSON string of block properties to update

Implementation Reference

  • The MCP tool registration, schema, and handler for 'update-block'. Defines input schema using Zod, handles execution by parsing properties JSON and calling NotionService.updateBlock, formats response or error.
    this.server.tool(
      "update-block",
      {
        block_id: z.string().describe("The ID of the block to update"),
        properties: z
          .string()
          .describe("JSON string of block properties to update"),
      },
      async ({ block_id, properties }) => {
        try {
          const block = await this.notionService.updateBlock(
            block_id,
            JSON.parse(properties)
          );
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify(block, null, 2),
              },
            ],
          };
        } catch (error) {
          console.error("Error in update-block tool:", error);
          return {
            content: [
              {
                type: "text",
                text: `Error: Failed to update block - ${
                  (error as Error).message
                }`,
              },
            ],
            isError: true,
          };
        }
      }
    );
  • Zod input schema for the update-block tool: block_id (string) and properties (JSON string).
    {
      block_id: z.string().describe("The ID of the block to update"),
      properties: z
        .string()
        .describe("JSON string of block properties to update"),
    },
  • NotionService helper method that performs the actual block update by calling the Notion Client's blocks.update API with the provided block_id and properties.
    async updateBlock(blockId: string, properties: Record<string, any>) {
      try {
        return await this.client.blocks.update({
          block_id: blockId,
          ...properties,
        });
      } 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