Skip to main content
Glama
awkoy

notion-mcp-server

batch_append_block_children

Add multiple child blocks to several parent blocks in a single batch operation, simplifying content organization and updates in Notion workflows.

Instructions

Append children to multiple blocks in a single operation

Input Schema

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

Implementation Reference

  • The main handler function for the batch_append_block_children tool. It loops through the provided operations, appends children to each specified block using the Notion API, collects results, and returns a formatted response or handles errors.
    export const batchAppendBlockChildren = async (
      params: BatchAppendBlockChildrenParams
    ): Promise<CallToolResult> => {
      try {
        const results = [];
    
        for (const operation of params.operations) {
          const response = await notion.blocks.children.append({
            block_id: operation.blockId,
            children: operation.children,
          });
    
          results.push({
            blockId: operation.blockId,
            success: true,
            response,
          });
        }
    
        return {
          content: [
            {
              type: "text",
              text: `Successfully completed ${params.operations.length} append operations`,
            },
            {
              type: "text",
              text: JSON.stringify(results, null, 2),
            },
          ],
        };
      } catch (error) {
        return handleNotionError(error);
      }
    };
  • Zod schema defining the input parameters for batch_append_block_children, consisting of an array of operations each with blockId and children.
    export const BATCH_APPEND_BLOCK_CHILDREN_SCHEMA = {
      operations: z
        .array(
          z.object({
            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"),
          })
        )
        .describe("Array of append operations to perform in a single batch"),
    };
  • Registration/dispatch case in the blocks operation tool that calls the batchAppendBlockChildren handler when the action is 'batch_append_block_children'.
    case "batch_append_block_children":
      return batchAppendBlockChildren(params.payload.params);
  • Part of the BLOCKS_OPERATION_SCHEMA discriminated union that defines the structure for the batch_append_block_children action including its literal action name and params schema.
    z.object({
      action: z
        .literal("batch_append_block_children")
        .describe(
          "Use this action to perform batch append operations on blocks."
        ),
      params: z.object(BATCH_APPEND_BLOCK_CHILDREN_SCHEMA),
    }),
  • TypeScript type definition and schema wrapper for BatchAppendBlockChildrenParams inferred from the schema.
    export const batchAppendBlockChildrenSchema = z.object(
      BATCH_APPEND_BLOCK_CHILDREN_SCHEMA
    );
    export type BatchAppendBlockChildrenParams = z.infer<
      typeof batchAppendBlockChildrenSchema
    >;

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