notion_create_database_item
Add new pages to Notion databases by specifying database ID and property values that match the existing schema.
Instructions
Create a new item (page) in a Notion database
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| database_id | Yes | The ID of the database to add the item to.It should be a 32-character string (excluding hyphens) formatted as 8-4-4-4-12 with hyphens (-). | |
| properties | Yes | Properties of the new database item. These should match the database schema. | |
| 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:231-247 (handler)Core handler function that executes the tool logic by making a POST request to the Notion API `/pages` endpoint to create a new item (page) in the specified database.async createDatabaseItem( database_id: string, properties: Record<string, any> ): Promise<PageResponse> { const body = { parent: { database_id }, properties, }; const response = await fetch(`${this.baseUrl}/pages`, { method: "POST", headers: this.headers, body: JSON.stringify(body), }); return response.json(); }
- src/server/index.ts:209-216 (handler)Server-side dispatcher that handles incoming CallToolRequest for this tool and delegates to the NotionClientWrapper.case "notion_create_database_item": { const args = request.params .arguments as unknown as args.CreateDatabaseItemArgs; response = await notionClient.createDatabaseItem( args.database_id, args.properties ); break;
- src/types/schemas.ts:338-358 (schema)Defines the tool schema including name, description, and input validation schema.export const createDatabaseItemTool: Tool = { name: "notion_create_database_item", description: "Create a new item (page) in a Notion database", inputSchema: { type: "object", properties: { database_id: { type: "string", description: "The ID of the database to add the item to." + commonIdDescription, }, properties: { type: "object", description: "Properties of the new database item. These should match the database schema.", }, format: formatParameter, }, required: ["database_id", "properties"], }, };
- src/server/index.ts:302-326 (registration)Registers the tool in the ListToolsRequest handler by including it in the array 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), }; });