Skip to main content
Glama

publish_document

Idempotent

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

TableJSON Schema
NameRequiredDescriptionDefault
idYesDocument UUID
slugNoCustom URL slug (auto-generated if omitted)
descriptionNoSEO description for published page
visibilityNo"public" or "link" (default, unlisted)
page_widthNoPage 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",
  • 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"),
    },
  • 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);
        }
      },
    );
  • 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) },
        ],
      };
    }
  • 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,
      };
    }
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already indicate non-destructive, idempotent, open-world. The description adds that published pages render specific chart/diagram content and default visibility, which is beyond annotations and helpful. No contradictions.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences, no fluff, front-loaded with verb and resource. Every sentence earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given annotations and schema, the description covers purpose, defaults, rendering, and an exclusion. No output schema, but the description implies what to expect (published page with content). Could mention the response, but overall complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema has 100% coverage for parameters; description adds minimal new info (e.g., default visibility already in schema, rendering details not parameter-specific). Does not enhance parameter meaning beyond schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool publishes a document to a shareable web page, specifies default visibility, and lists supported content types, distinguishing it from siblings like create_document or update_document.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It provides context on when to use (publishing to web) and explicitly says email-based sharing is not available here, directing users elsewhere. However, it does not explicitly contrast with all siblings or state prerequisites.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/UnMarkdown/mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server