coda_create_page
Add a new page to a Coda document by specifying the document ID, page name, and optional content or parent page ID for organized structuring.
Instructions
Create a page in the current document
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | No | The markdown content of the page to create - optional | |
| docId | Yes | The ID of the document to create the page in | |
| name | Yes | The name of the page to create | |
| parentPageId | No | The ID of the parent page to create this page under - optional |
Implementation Reference
- src/server.ts:78-99 (handler)Handler function that executes the tool logic: calls createPage from the SDK with provided parameters, handles errors, and returns JSON response or error message.async ({ docId, name, content, parentPageId }): Promise<CallToolResult> => { try { const resp = await createPage({ path: { docId }, body: { name, parentPageId: parentPageId ?? undefined, pageContent: { type: "canvas", canvasContent: { format: "markdown", content: content ?? " " }, }, }, throwOnError: true, }); return { content: [{ type: "text", text: JSON.stringify(resp.data) }], }; } catch (error) { return { content: [{ type: "text", text: `Failed to create page: ${error}` }], isError: true }; } },
- src/server.ts:72-77 (schema)Zod input schema defining parameters for the tool: docId, name (required), content and parentPageId (optional).{ docId: z.string().describe("The ID of the document to create the page in"), name: z.string().describe("The name of the page to create"), content: z.string().optional().describe("The markdown content of the page to create - optional"), parentPageId: z.string().optional().describe("The ID of the parent page to create this page under - optional"), },
- src/server.ts:69-100 (registration)Registration of the coda_create_page tool with the MCP server, including name, description, input schema, and handler function.server.tool( "coda_create_page", "Create a page in the current document", { docId: z.string().describe("The ID of the document to create the page in"), name: z.string().describe("The name of the page to create"), content: z.string().optional().describe("The markdown content of the page to create - optional"), parentPageId: z.string().optional().describe("The ID of the parent page to create this page under - optional"), }, async ({ docId, name, content, parentPageId }): Promise<CallToolResult> => { try { const resp = await createPage({ path: { docId }, body: { name, parentPageId: parentPageId ?? undefined, pageContent: { type: "canvas", canvasContent: { format: "markdown", content: content ?? " " }, }, }, throwOnError: true, }); return { content: [{ type: "text", text: JSON.stringify(resp.data) }], }; } catch (error) { return { content: [{ type: "text", text: `Failed to create page: ${error}` }], isError: true }; } }, );