update_document
Update a document's content, title, folder, template, theme, description, or page width by providing its UUID.
Instructions
Update a document's content or metadata
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Document UUID | |
| title | No | New title | |
| content | No | New markdown content | |
| folder | No | Move to folder by name (case-insensitive) or folder ID. Set to null to move to Unfiled. | |
| template_id | No | New template ID | |
| theme_mode | No | New color theme | |
| description | No | Document description (null to clear) | |
| page_width | No | Page width for published view |
Implementation Reference
- src/tools.ts:237-257 (handler)Handler function for update_document tool. Accepts id (required), and optional title, content, folder, template_id, theme_mode, description, page_width. Builds a request body with only defined fields and sends a PATCH request to /v1/documents/:id.
async ({ id, title, content, folder, template_id, theme_mode, description, page_width }) => { try { const body: Record<string, unknown> = {}; if (title !== undefined) body.title = title; if (content !== undefined) body.content = content; if (folder !== undefined) body.folder = folder; if (template_id !== undefined) body.template_id = template_id; if (theme_mode !== undefined) body.theme_mode = theme_mode; if (description !== undefined) body.description = description; if (page_width !== undefined) body.page_width = page_width; const result = await client.request( "PATCH", `/v1/documents/${encodeURIComponent(id)}`, body, ); return jsonResult(result); } catch (err) { return errorResult(err); } }, ); - src/tools.ts:206-229 (schema)Zod schema for update_document input parameters: id (required UUID string), title, content, folder (nullable string), template_id, theme_mode (light/dark), description (nullable string), page_width (full/wide/standard).
{ id: z.string().describe("Document UUID"), title: z.string().optional().describe("New title"), content: z.string().optional().describe("New markdown content"), folder: z .string() .nullable() .optional() .describe("Move to folder by name (case-insensitive) or folder ID. Set to null to move to Unfiled."), template_id: z.string().optional().describe("New template ID"), theme_mode: z .enum(["light", "dark"]) .optional() .describe("New color theme"), description: z .string() .nullable() .optional() .describe("Document description (null to clear)"), page_width: z .enum(["full", "wide", "standard"]) .optional() .describe("Page width for published view"), }, - src/tools.ts:203-257 (registration)Registration of the 'update_document' tool on the MCP server via server.tool(), with name, description, schema, metadata hints (title, readOnlyHint, destructiveHint, idempotentHint, openWorldHint), and the handler callback.
server.tool( "update_document", "Update a document's content or metadata", { id: z.string().describe("Document UUID"), title: z.string().optional().describe("New title"), content: z.string().optional().describe("New markdown content"), folder: z .string() .nullable() .optional() .describe("Move to folder by name (case-insensitive) or folder ID. Set to null to move to Unfiled."), template_id: z.string().optional().describe("New template ID"), theme_mode: z .enum(["light", "dark"]) .optional() .describe("New color theme"), description: z .string() .nullable() .optional() .describe("Document description (null to clear)"), page_width: z .enum(["full", "wide", "standard"]) .optional() .describe("Page width for published view"), }, { title: "Update Document", readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: true, }, async ({ id, title, content, folder, template_id, theme_mode, description, page_width }) => { try { const body: Record<string, unknown> = {}; if (title !== undefined) body.title = title; if (content !== undefined) body.content = content; if (folder !== undefined) body.folder = folder; if (template_id !== undefined) body.template_id = template_id; if (theme_mode !== undefined) body.theme_mode = theme_mode; if (description !== undefined) body.description = description; if (page_width !== undefined) body.page_width = page_width; const result = await client.request( "PATCH", `/v1/documents/${encodeURIComponent(id)}`, body, ); return jsonResult(result); } catch (err) { return errorResult(err); } }, );