get-block-children
Retrieve child blocks from a Notion block to access nested content and structure within your workspace.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| block_id | Yes | The ID of the block to get children from | |
| page_size | No | Number of results to return (max 100) | |
| start_cursor | No | Pagination cursor |
Implementation Reference
- src/lib/mcp-server.ts:457-486 (handler)The MCP tool handler for 'get-block-children' that calls NotionService.retrieveBlockChildren and handles response/error formatting.async ({ block_id, page_size, start_cursor }) => { try { const blocks = await this.notionService.retrieveBlockChildren({ block_id, page_size, start_cursor, }); return { content: [ { type: "text", text: JSON.stringify(blocks, null, 2), }, ], }; } catch (error) { console.error("Error in get-block-children tool:", error); return { content: [ { type: "text", text: `Error: Failed to retrieve block children - ${ (error as Error).message }`, }, ], isError: true, }; } }
- src/lib/mcp-server.ts:445-456 (schema)Zod input schema for the 'get-block-children' tool parameters.{ block_id: z .string() .describe("The ID of the block to get children from"), page_size: z .number() .min(1) .max(100) .optional() .describe("Number of results to return (max 100)"), start_cursor: z.string().optional().describe("Pagination cursor"), },
- src/lib/mcp-server.ts:443-487 (registration)Registration of the 'get-block-children' tool on the MCP server within registerBlockTools().this.server.tool( "get-block-children", { block_id: z .string() .describe("The ID of the block to get children from"), page_size: z .number() .min(1) .max(100) .optional() .describe("Number of results to return (max 100)"), start_cursor: z.string().optional().describe("Pagination cursor"), }, async ({ block_id, page_size, start_cursor }) => { try { const blocks = await this.notionService.retrieveBlockChildren({ block_id, page_size, start_cursor, }); return { content: [ { type: "text", text: JSON.stringify(blocks, null, 2), }, ], }; } catch (error) { console.error("Error in get-block-children tool:", error); return { content: [ { type: "text", text: `Error: Failed to retrieve block children - ${ (error as Error).message }`, }, ], isError: true, }; } } );
- src/lib/notion.ts:239-249 (helper)Supporting method in NotionService that wraps the Notion Client API call for retrieving block children.async retrieveBlockChildren(params: BlockChildrenQuery) { try { return await this.client.blocks.children.list({ block_id: params.block_id, start_cursor: params.start_cursor, page_size: params.page_size, }); } catch (error) { this.handleError(error); } }