Skip to main content
Glama

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
NameRequiredDescriptionDefault
parent_typeYesType of parent (database or page)
parent_idYesID of the parent database or page
propertiesYesJSON string of page properties
childrenNoJSON string of page content blocks

Implementation Reference

  • 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, }; } } );
  • 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); } }
  • 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>;

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ramidecodes/mcp-server-notion'

If you have feedback or need assistance with the MCP directory API, please join our Discord server