Skip to main content
Glama
awkoy

notion-mcp-server

batch_mixed_operations

Execute multiple append, update, and delete operations on Notion blocks in a single request to streamline content management and reduce API calls.

Instructions

Perform a mix of append, update, and delete operations in a single request

Input Schema

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

Implementation Reference

  • The primary handler function for the batch_mixed_operations tool. It processes an array of mixed operations (append, update, delete) on Notion blocks, executes them sequentially using the Notion API, collects results, and returns a formatted response.
    export const batchMixedOperations = async (
      params: BatchMixedOperationsParams
    ): Promise<CallToolResult> => {
      try {
        const results = [];
        const operationCounts = {
          append: 0,
          update: 0,
          delete: 0,
        };
    
        for (const op of params.operations) {
          let response;
    
          switch (op.operation) {
            case "append":
              response = await notion.blocks.children.append({
                block_id: op.blockId,
                children: op.children,
              });
              operationCounts.append++;
              break;
    
            case "update":
              response = await notion.blocks.update({
                block_id: op.blockId,
                ...op.data,
              });
              operationCounts.update++;
              break;
    
            case "delete":
              response = await notion.blocks.delete({
                block_id: op.blockId,
              });
              operationCounts.delete++;
              break;
          }
    
          results.push({
            operation: op.operation,
            blockId: op.blockId,
            success: true,
            response,
          });
        }
    
        return {
          content: [
            {
              type: "text",
              text: `Successfully performed ${params.operations.length} operations (${operationCounts.append} append, ${operationCounts.update} update, ${operationCounts.delete} delete)`,
            },
            {
              type: "text",
              text: JSON.stringify(results, null, 2),
            },
          ],
        };
      } catch (error) {
        return handleNotionError(error);
      }
    };
  • Zod schema defining the input parameters for batch_mixed_operations: an array of discriminated union operations supporting append (with blockId and children), update (with blockId and data), or delete (with blockId).
    export const BATCH_MIXED_OPERATIONS_SCHEMA = {
      operations: z
        .array(
          z.discriminatedUnion("operation", [
            z.object({
              operation: z.literal("append"),
              blockId: z
                .string()
                .describe("The ID of the block to append children to"),
              children: z
                .array(TEXT_BLOCK_REQUEST_SCHEMA)
                .describe("Array of blocks to append as children"),
            }),
            z.object({
              operation: z.literal("update"),
              blockId: z.string().describe("The ID of the block to update"),
              data: TEXT_BLOCK_REQUEST_SCHEMA.describe("The block data to update"),
            }),
            z.object({
              operation: z.literal("delete"),
              blockId: z.string().describe("The ID of the block to delete/archive"),
            }),
          ])
        )
        .describe("Array of mixed operations to perform in a single batch"),
    };
  • Registration/dispatch logic within the 'notion_blocks' tool handler (registerBlocksOperationTool). Routes requests with action 'batch_mixed_operations' to the batchMixedOperations handler function.
    case "batch_mixed_operations":
      return batchMixedOperations(params.payload.params);
  • Inclusion of batch_mixed_operations as an action in the overarching BLOCKS_OPERATION_SCHEMA for the 'notion_blocks' MCP tool.
    z.object({
      action: z
        .literal("batch_mixed_operations")
        .describe(
          "Use this action to perform batch mixed operations on blocks."
        ),
      params: z.object(BATCH_MIXED_OPERATIONS_SCHEMA),
    }),
  • MCP tool registration for 'notion_blocks', which encompasses batch_mixed_operations as one of its dispatched actions via BLOCKS_OPERATION_SCHEMA and registerBlocksOperationTool.
    // Register combined blocks operation tool
    server.tool(
      "notion_blocks",
      "Perform various block operations (retrieve, update, delete, append children, batch operations)",
      BLOCKS_OPERATION_SCHEMA,
      registerBlocksOperationTool
    );
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It mentions 'append, update, and delete operations' which implies mutation, but doesn't disclose critical behavioral traits like whether operations are atomic, what happens on partial failures, permission requirements, rate limits, or what the response contains. For a complex batch mutation tool, this is a significant gap.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose. Every word earns its place with no redundancy or unnecessary elaboration, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a complex batch mutation tool with no annotations and no output schema, the description is inadequate. It doesn't explain the atomicity, error handling, response format, or performance implications of batch operations. Given the rich input schema and sibling tools, more context is needed to guide proper usage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents the single 'operations' parameter thoroughly. The description adds no specific parameter information beyond implying the parameter contains mixed operations. Baseline 3 is appropriate when the schema does the heavy lifting, though the description could have explained the structure or constraints of the operations array.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool performs a mix of append, update, and delete operations in a single request, specifying the verb 'perform' and resource 'operations'. It distinguishes from siblings by mentioning 'mixed operations' and 'single request', but doesn't explicitly contrast with individual operation tools like append_block_children or delete_block.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when batch operations are preferable to individual operations, nor does it reference any of the sibling tools like batch_append_block_children or batch_delete_blocks that might serve similar purposes.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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