notion_retrieve_database
Retrieve Notion database content in JSON or Markdown format for reading, writing, or modifying data within Claude Desktop.
Instructions
Retrieve a database in Notion
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| database_id | Yes | The ID of the database to retrieve.It should be a 32-character string (excluding hyphens) formatted as 8-4-4-4-12 with hyphens (-). | |
| format | No | Specify the response format. 'json' returns the original data structure, 'markdown' returns a more readable format. Use 'markdown' when the user only needs to read the page and isn't planning to write or modify it. Use 'json' when the user needs to read the page with the intention of writing to or modifying it. | markdown |
Implementation Reference
- src/client/index.ts:202-209 (handler)Core handler function that executes the tool logic by performing a GET request to the Notion API endpoint /databases/{database_id} to retrieve the database.async retrieveDatabase(database_id: string): Promise<DatabaseResponse> { const response = await fetch(`${this.baseUrl}/databases/${database_id}`, { method: "GET", headers: this.headers, }); return response.json(); }
- src/server/index.ts:190-194 (handler)MCP server handler switch case that processes the CallToolRequest for notion_retrieve_database, validates args, and delegates to NotionClientWrapper.case "notion_retrieve_database": { const args = request.params .arguments as unknown as args.RetrieveDatabaseArgs; response = await notionClient.retrieveDatabase(args.database_id); break;
- src/types/schemas.ts:288-303 (schema)JSON schema definition for the tool's input parameters, metadata, and description.export const retrieveDatabaseTool: Tool = { name: "notion_retrieve_database", description: "Retrieve a database in Notion", inputSchema: { type: "object", properties: { database_id: { type: "string", description: "The ID of the database to retrieve." + commonIdDescription, }, format: formatParameter, }, required: ["database_id"], }, };
- src/server/index.ts:302-325 (registration)Registers the tool in the MCP server's ListToolsRequestHandler by including it in the list of available tools.server.setRequestHandler(ListToolsRequestSchema, async () => { const allTools = [ schemas.appendBlockChildrenTool, schemas.retrieveBlockTool, schemas.retrieveBlockChildrenTool, schemas.deleteBlockTool, schemas.updateBlockTool, schemas.retrievePageTool, schemas.updatePagePropertiesTool, schemas.listAllUsersTool, schemas.retrieveUserTool, schemas.retrieveBotUserTool, schemas.createDatabaseTool, schemas.queryDatabaseTool, schemas.retrieveDatabaseTool, schemas.updateDatabaseTool, schemas.createDatabaseItemTool, schemas.createCommentTool, schemas.retrieveCommentsTool, schemas.searchTool, ]; return { tools: filterTools(allTools, enabledToolsSet), };
- src/types/args.ts:93-96 (schema)TypeScript type definition for the tool's input arguments used in the server handler.export interface RetrieveDatabaseArgs { database_id: string; format?: "json" | "markdown"; }