retrieve_block_children
Retrieve child elements of a specific block in Notion using the block ID. Supports pagination for handling large datasets. Integrates with the Notion MCP Server for API interactions.
Instructions
Retrieve the children of a block from Notion
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| blockId | Yes | The ID of the block to retrieve children for | |
| page_size | No | Number of results to return (1-100) | |
| start_cursor | No | Cursor for pagination |
Implementation Reference
- src/tools/retrieveBlockChildren.ts:6-39 (handler)The core handler function that executes the retrieve_block_children tool logic by calling the Notion API to list children blocks.export const retrieveBlockChildren = async ( params: RetrieveBlockChildrenParams ): Promise<CallToolResult> => { try { const response = await notion.blocks.children.list({ block_id: params.blockId, start_cursor: params.start_cursor, page_size: params.page_size, }); return { content: [ { type: "text", text: `Successfully retrieved ${response.results.length} children of block ${params.blockId}`, }, { type: "text", text: `Has more: ${response.has_more ? "Yes" : "No"}${ response.has_more && response.next_cursor ? `, Next cursor: ${response.next_cursor}` : "" }`, }, { type: "text", text: JSON.stringify(response.results, null, 2), }, ], }; } catch (error) { return handleNotionError(error); } };
- src/tools/blocks.ts:22-23 (registration)Dispatches the retrieve_block_children action by calling the handler function within the blocks operation tool.case "retrieve_block_children": return retrieveBlockChildren(params.payload.params);
- src/schema/blocks.ts:170-179 (schema)Defines the input schema (parameters) for the retrieve_block_children tool.export const RETRIEVE_BLOCK_CHILDREN_SCHEMA = { blockId: z.string().describe("The ID of the block to retrieve children for"), start_cursor: z.string().optional().describe("Cursor for pagination"), page_size: z .number() .min(1) .max(100) .optional() .describe("Number of results to return (1-100)"), };
- src/types/blocks.ts:23-28 (schema)TypeScript type and schema wrapper for retrieve_block_children parameters.export const retrieveBlockChildrenSchema = z.object( RETRIEVE_BLOCK_CHILDREN_SCHEMA ); export type RetrieveBlockChildrenParams = z.infer< typeof retrieveBlockChildrenSchema >;
- src/tools/blocks.ts:6-6 (registration)Imports the retrieveBlockChildren handler for use in the blocks dispatcher.import { retrieveBlockChildren } from "./retrieveBlockChildren.js";