Skip to main content
Glama
awkoy

notion-mcp-server

retrieve_block

Fetch a specific block from Notion by its unique ID, enabling integration with AI assistants and efficient data retrieval for automation workflows.

Instructions

Retrieve a block from Notion by ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
blockIdYesThe ID of the block to retrieve

Implementation Reference

  • The main handler function for the 'retrieve_block' tool. It retrieves a specific Notion block by its ID using the Notion API and returns the block data as a formatted text response.
    export const retrieveBlock = async (
      params: RetrieveBlockParams
    ): Promise<CallToolResult> => {
      try {
        const response = await notion.blocks.retrieve({
          block_id: params.blockId,
        });
    
        return {
          content: [
            {
              type: "text",
              text: "Block retrieved successfully! Note: If this block has children, use the retrieve_block_children endpoint to get the list of child blocks.",
            },
            {
              type: "text",
              text: JSON.stringify(response, null, 2),
            },
          ],
        };
      } catch (error) {
        return handleNotionError(error);
      }
    };
  • Zod schema defining the input parameters for the retrieve_block action: requires a blockId string.
    export const RETRIEVE_BLOCK_SCHEMA = {
      blockId: z.string().describe("The ID of the block to retrieve"),
    };
  • Dispatch registration in the blocks operation handler: maps the 'retrieve_block' action to the retrieveBlock function.
    case "retrieve_block":
      return retrieveBlock(params.payload.params);
  • MCP tool registration for 'notion_blocks', which includes the 'retrieve_block' action via BLOCKS_OPERATION_SCHEMA and registerBlocksOperationTool handler.
    // Register combined blocks operation tool
    server.tool(
      "notion_blocks",
      "Perform various block operations (retrieve, update, delete, append children, batch operations)",
      BLOCKS_OPERATION_SCHEMA,
      registerBlocksOperationTool
    );
  • Definition of the 'retrieve_block' action within the BLOCKS_OPERATION_SCHEMA discriminated union.
    z.object({
      action: z
        .literal("retrieve_block")
        .describe("Use this action to retrieve a block."),
      params: z.object(RETRIEVE_BLOCK_SCHEMA),
    }),
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