coda_replace_page_content
Replace existing page content in a Coda document with new markdown content by specifying the document ID, page ID or name, and updated content.
Instructions
Replace the content of a page with new markdown content
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | The markdown content to replace the page with | |
| docId | Yes | The ID of the document that contains the page to replace the content of | |
| pageIdOrName | Yes | The ID or name of the page to replace the content of |
Implementation Reference
- src/server.ts:164-185 (handler)The handler function that implements the core logic of the tool by calling the updatePage SDK function with insertionMode 'replace' to update the page content with the provided markdown.
async ({ docId, pageIdOrName, content }): Promise<CallToolResult> => { try { const resp = await updatePage({ path: { docId, pageIdOrName, }, body: { // @ts-expect-error auto-generated client types contentUpdate: { insertionMode: "replace", canvasContent: { format: "markdown", content }, }, }, throwOnError: true, }); return { content: [{ type: "text", text: JSON.stringify(resp.data) }] }; } catch (error) { return { content: [{ type: "text", text: `Failed to replace page content: ${error}` }], isError: true }; } }, - src/server.ts:159-163 (schema)Zod input schema defining the parameters for the tool: docId, pageIdOrName, and content.
{ docId: z.string().describe("The ID of the document that contains the page to replace the content of"), pageIdOrName: z.string().describe("The ID or name of the page to replace the content of"), content: z.string().describe("The markdown content to replace the page with"), }, - src/server.ts:156-186 (registration)The server.tool call that registers the coda_replace_page_content tool with its description, schema, and handler.
server.tool( "coda_replace_page_content", "Replace the content of a page with new markdown content", { docId: z.string().describe("The ID of the document that contains the page to replace the content of"), pageIdOrName: z.string().describe("The ID or name of the page to replace the content of"), content: z.string().describe("The markdown content to replace the page with"), }, async ({ docId, pageIdOrName, content }): Promise<CallToolResult> => { try { const resp = await updatePage({ path: { docId, pageIdOrName, }, body: { // @ts-expect-error auto-generated client types contentUpdate: { insertionMode: "replace", canvasContent: { format: "markdown", content }, }, }, throwOnError: true, }); return { content: [{ type: "text", text: JSON.stringify(resp.data) }] }; } catch (error) { return { content: [{ type: "text", text: `Failed to replace page content: ${error}` }], isError: true }; } }, );