Skip to main content
Glama
awkoy

notion-mcp-server

batch_update_blocks

Update multiple Notion blocks simultaneously by specifying an array of operations, streamlining bulk modifications for improved workflow efficiency.

Instructions

Update multiple blocks in a single operation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
operationsYesArray of update operations to perform in a single batch

Implementation Reference

  • The core handler function for the "batch_update_blocks" tool. It processes an array of update operations on Notion blocks, calling the Notion API for each, collecting results, and returning a success message with JSON details or handling errors.
    export const batchUpdateBlocks = async (
      params: BatchUpdateBlocksParams
    ): Promise<CallToolResult> => {
      try {
        const results = [];
    
        for (const operation of params.operations) {
          const response = await notion.blocks.update({
            block_id: operation.blockId,
            ...operation.data,
          });
    
          results.push({
            blockId: operation.blockId,
            success: true,
            response,
          });
        }
    
        return {
          content: [
            {
              type: "text",
              text: `Successfully updated ${params.operations.length} blocks`,
            },
            {
              type: "text",
              text: JSON.stringify(results, null, 2),
            },
          ],
        };
      } catch (error) {
        return handleNotionError(error);
      }
    };
  • Zod schema defining the input parameters for batch_update_blocks: an array of objects each containing blockId (string) and data (TEXT_BLOCK_REQUEST_SCHEMA).
    export const BATCH_UPDATE_BLOCKS_SCHEMA = {
      operations: z
        .array(
          z.object({
            blockId: z.string().describe("The ID of the block to update"),
            data: TEXT_BLOCK_REQUEST_SCHEMA.describe("The block data to update"),
          })
        )
        .describe("Array of update operations to perform in a single batch"),
    };
  • Tool registration/dispatch logic within the blocks operation handler. Matches the "batch_update_blocks" action and delegates to the batchUpdateBlocks function.
    case "batch_update_blocks":
      return batchUpdateBlocks(params.payload.params);
  • Part of the BLOCKS_OPERATION_SCHEMA discriminated union defining the "batch_update_blocks" action variant, including description and params schema reference.
    z.object({
      action: z
        .literal("batch_update_blocks")
        .describe(
          "Use this action to perform batch update operations on blocks."
        ),
      params: z.object(BATCH_UPDATE_BLOCKS_SCHEMA),
  • TypeScript type definition and schema wrapper for BatchUpdateBlocksParams, inferred from the schema.
    export const batchUpdateBlocksSchema = z.object(BATCH_UPDATE_BLOCKS_SCHEMA);
    export type BatchUpdateBlocksParams = z.infer<typeof batchUpdateBlocksSchema>;

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