create-database
Generate structured databases in Notion by specifying a parent page ID, title, and properties to organize and manage data effectively within your workspace.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| parentPageId | Yes | ||
| properties | Yes | ||
| title | Yes |
Implementation Reference
- src/index.ts:288-321 (handler)The handler function that creates a new Notion database under the specified parent page using the Notion client. It takes parentPageId, title, and properties as input and returns success/error messages.async ({ parentPageId, title, properties }) => { try { const response = await notion.databases.create({ parent: { type: "page_id", page_id: parentPageId }, title: [ { type: "text", text: { content: title } } ], properties: properties }); return { content: [{ type: "text", text: `Database created successfully!\nTitle: ${title}\nID: ${response.id}` }] }; } catch (error: any) { return { content: [{ type: "text", text: `Error creating database: ${error.message}` }], isError: true }; } }
- src/index.ts:283-287 (schema)Zod schema defining the input parameters for the create-database tool: parentPageId (string), title (string), and properties (record of any).{ parentPageId: z.string(), title: z.string(), properties: z.record(z.any()) },
- src/index.ts:281-322 (registration)Registration of the 'create-database' tool on the MCP server using server.tool(), including schema and handler.server.tool( "create-database", { parentPageId: z.string(), title: z.string(), properties: z.record(z.any()) }, async ({ parentPageId, title, properties }) => { try { const response = await notion.databases.create({ parent: { type: "page_id", page_id: parentPageId }, title: [ { type: "text", text: { content: title } } ], properties: properties }); return { content: [{ type: "text", text: `Database created successfully!\nTitle: ${title}\nID: ${response.id}` }] }; } catch (error: any) { return { content: [{ type: "text", text: `Error creating database: ${error.message}` }], isError: true }; } } );