Skip to main content
Glama
awkoy

notion-mcp-server

update_block

Modify or refresh the content of a specific block in Notion using its block ID. Adjust text, formatting, or metadata to keep your workspace up to date.

Instructions

Update a block's content in Notion

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
blockIdYesThe ID of the block to update
dataYesThe block data to update

Implementation Reference

  • Executes the core logic for the update_block tool by updating the Notion block via API.
    export const updateBlock = async (
      params: UpdateBlockParams
    ): Promise<CallToolResult> => {
      try {
        const response = await notion.blocks.update({
          block_id: params.blockId,
          ...params.data,
        });
    
        return {
          content: [
            {
              type: "text",
              text: `Block ${response.id} updated successfully`,
            },
            {
              type: "text",
              text: JSON.stringify(response, null, 2),
            },
          ],
        };
      } catch (error) {
        return handleNotionError(error);
      }
    };
  • Zod schema for input parameters of update_block: blockId and data.
    export const UPDATE_BLOCK_SCHEMA = {
      blockId: z.string().describe("The ID of the block to update"),
      data: TEXT_BLOCK_REQUEST_SCHEMA.describe("The block data to update"),
    };
  • Schema definition for the 'update_block' action within BLOCKS_OPERATION_SCHEMA.
      action: z
        .literal("update_block")
        .describe("Use this action to update a block."),
      params: z.object(UPDATE_BLOCK_SCHEMA),
    }),
  • Dispatches 'update_block' action to the specific handler in the blocks operation tool.
    case "update_block":
      return updateBlock(params.payload.params);
  • Registers the 'notion_blocks' MCP tool that includes the 'update_block' action.
    // Register combined blocks operation tool
    server.tool(
      "notion_blocks",
      "Perform various block operations (retrieve, update, delete, append children, batch operations)",
      BLOCKS_OPERATION_SCHEMA,
      registerBlocksOperationTool
    );

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

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