create-page
Add a new page to a Notion database or existing page by specifying parent type, ID, properties, and optional content blocks.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| parent_type | Yes | Type of parent (database or page) | |
| parent_id | Yes | ID of the parent database or page | |
| properties | Yes | JSON string of page properties | |
| children | No | JSON string of page content blocks |
Implementation Reference
- src/lib/mcp-server.ts:228-279 (handler)MCP tool registration for 'create-page', defining the input schema with Zod, the handler function that processes parameters, calls NotionService.createPage, and returns the result or formatted error.this.server.tool( "create-page", { parent_type: z .enum(["database_id", "page_id"]) .describe("Type of parent (database or page)"), parent_id: z.string().describe("ID of the parent database or page"), properties: z.string().describe("JSON string of page properties"), children: z .string() .optional() .describe("JSON string of page content blocks"), }, async ({ parent_type, parent_id, properties, children }) => { const params: any = { parent: { type: parent_type, [parent_type]: parent_id, }, properties: JSON.parse(properties), }; if (children) { params.children = JSON.parse(children); } try { const page = await this.notionService.createPage(params); return { content: [ { type: "text", text: JSON.stringify(page, null, 2), }, ], }; } catch (error) { console.error("Error in create-page tool:", error); return { content: [ { type: "text", text: `Error: Failed to create page - ${ (error as Error).message }`, }, ], isError: true, }; } } );
- src/lib/notion.ts:148-163 (helper)Helper method in NotionService that executes the actual Notion API call to create a page using the client.pages.create method.async createPage(params: CreatePage) { try { return await this.client.pages.create({ parent: params.parent.type === "database_id" ? { database_id: params.parent.database_id! } : { page_id: params.parent.page_id! }, properties: params.properties, children: params.children, icon: params.icon, cover: params.cover, }); } catch (error) { this.handleError(error); } }
- src/types/notion.ts:35-47 (schema)Zod schema (CreatePageSchema) and TypeScript type (CreatePage) defining the structure for page creation parameters used in NotionService.createPage.export const CreatePageSchema = z.object({ parent: z.object({ database_id: z.string().optional(), page_id: z.string().optional(), type: z.enum(["database_id", "page_id"]), }), properties: z.record(z.any()), children: z.array(z.any()).optional(), icon: z.any().optional(), cover: z.any().optional(), }); export type CreatePage = z.infer<typeof CreatePageSchema>;