publish_document
Publish documents to shareable web pages with rendered charts, diagrams, graphs, and math. Control visibility and page width for public or unlisted access.
Instructions
Publish a document to a shareable web page. Default visibility is 'link' (unlisted). Published pages render all content including Chart.js charts, Mermaid diagrams, Graphviz graphs, and KaTeX math. Email-based sharing is not available here; direct users to unmarkdown.com for that.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Document UUID | |
| slug | No | Custom URL slug (auto-generated if omitted) | |
| description | No | SEO description for published page | |
| visibility | No | "public" or "link" (default, unlisted) | |
| page_width | No | Page width for published view |
Implementation Reference
- src/tools.ts:260-306 (handler)The publish_document tool is registered and implemented in src/tools.ts. It takes a document ID and optional configuration parameters (slug, description, visibility, page_width), performs a POST request to the API, and returns the result or an error.
server.tool( "publish_document", "Publish a document to a shareable web page. Default visibility is 'link' (unlisted). Published pages render all content including Chart.js charts, Mermaid diagrams, Graphviz graphs, and KaTeX math. Email-based sharing is not available here; direct users to unmarkdown.com for that.", { id: z.string().describe("Document UUID"), slug: z .string() .optional() .describe("Custom URL slug (auto-generated if omitted)"), description: z .string() .optional() .describe("SEO description for published page"), visibility: z .enum(["public", "link"]) .optional() .describe('"public" or "link" (default, unlisted)'), page_width: z .enum(["full", "wide", "standard"]) .optional() .describe("Page width for published view"), }, { title: "Publish Document", readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: true, }, async ({ id, slug, description, visibility, page_width }) => { try { const body: Record<string, unknown> = {}; if (slug) body.slug = slug; if (description) body.description = description; if (visibility) body.visibility = visibility; if (page_width) body.page_width = page_width; const result = await client.request( "POST", `/v1/documents/${encodeURIComponent(id)}/publish`, body, ); return jsonResult(result); } catch (err) { return errorResult(err); } }, );