publish_document
Publish a document as a shareable web page. Customize slug, description, visibility, and page width. Content with charts, diagrams, and math renders fully.
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
| 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-261 (registration)Tool 'publish_document' is registered via server.tool() call at line 260. The name string is 'publish_document'.
server.tool( "publish_document", - src/tools.ts:263-281 (schema)Input schema for publish_document: requires 'id' (string UUID), optional 'slug', 'description', 'visibility' (enum public/link), and 'page_width' (enum full/wide/standard).
{ 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"), }, - src/tools.ts:289-306 (handler)Handler function for publish_document: constructs a body object from optional parameters, then calls client.request('POST', '/v1/documents/{id}/publish', body) and returns the JSON result.
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); } }, ); - src/tools.ts:24-30 (helper)Helper function jsonResult() used by the handler to format the response.
function jsonResult(data: unknown) { return { content: [ { type: "text" as const, text: JSON.stringify(data, null, 2) }, ], }; } - src/tools.ts:5-22 (helper)Helper function errorResult() used by the handler to format error responses.
function errorResult(err: unknown) { if (err instanceof ApiError) { return { content: [ { type: "text" as const, text: `Error ${err.status} (${err.code}): ${err.message}`, }, ], isError: true, }; } const message = err instanceof Error ? err.message : String(err); return { content: [{ type: "text" as const, text: `Error: ${message}` }], isError: true, }; }