notion_create_database
Create a structured database in Notion to organize and manage information with customizable properties and rich text titles.
Instructions
Create a database in Notion
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| parent | Yes | Parent object of the database | |
| title | No | Title of database as it appears in Notion. An array of rich text objects. | |
| properties | Yes | Property schema of database. The keys are the names of properties as they appear in Notion and the values are property schema objects. | |
| 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:193-207 (handler)The actual handler implementation - createDatabase method in NotionClientWrapper class that makes a POST request to the Notion API /databases endpointasync createDatabase( parent: CreateDatabaseArgs["parent"], properties: Record<string, any>, title?: RichTextItemResponse[] ): Promise<DatabaseResponse> { const body = { parent, title, properties }; const response = await fetch(`${this.baseUrl}/databases`, { method: "POST", headers: this.headers, body: JSON.stringify(body), }); return response.json(); }
- src/server/index.ts:194-203 (registration)Tool registration in the switch statement - handles the 'notion_create_database' case by extracting arguments and calling notionClient.createDatabasecase "notion_create_database": { const args = request.params .arguments as unknown as args.CreateDatabaseArgs; response = await notionClient.createDatabase( args.parent, args.properties, args.title ); break; }
- src/types/schemas.ts:252-277 (schema)Tool schema definition - defines the input schema with parent, title, properties, and format parameters for the MCP tool registrationexport const createDatabaseTool: Tool = { name: "notion_create_database", description: "Create a database in Notion", inputSchema: { type: "object", properties: { parent: { type: "object", description: "Parent object of the database", }, title: { type: "array", description: "Title of database as it appears in Notion. An array of rich text objects.", items: richTextObjectSchema, }, properties: { type: "object", description: "Property schema of database. The keys are the names of properties as they appear in Notion and the values are property schema objects.", }, format: formatParameter, }, required: ["parent", "properties"], }, };
- src/types/args.ts:75-85 (schema)Type definition for CreateDatabaseArgs - defines the TypeScript interface for the arguments expected by the createDatabase handlerexport interface CreateDatabaseArgs { parent: { type: string; page_id?: string; database_id?: string; workspace?: boolean; }; title?: RichTextItemResponse[]; properties: Record<string, any>; format?: "json" | "markdown"; }