Skip to main content
Glama

convert_markdown

Read-onlyIdempotent

Converts markdown to HTML and plain text for Slack, Google Docs, Word, and more. Returns JSON with html and plain_text fields. For Slack, use plain_text; for other apps, visit unmarkdown.com for paste-ready format.

Instructions

Convert markdown to destination-specific HTML and plain text. Returns JSON with 'html' and 'plain_text' fields. For Slack, present the plain_text to the user. For Google Docs/Word/OneNote, direct users to unmarkdown.com to use the copy button (raw HTML cannot be pasted into these apps). Does not render Chart.js, Mermaid, Graphviz, or KaTeX; use publish_document for documents with diagrams or math.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
markdownYesMarkdown content to convert
destinationNoTarget format (default: "generic")
template_idNoVisual template ID (default: "swiss")
theme_modeNoColor theme (default: "light")

Implementation Reference

  • src/tools.ts:34-80 (registration)
    The convert_markdown tool is registered via server.tool() with its schema and handler. The handler calls client.request('POST', '/v1/convert', body).
    server.tool(
      "convert_markdown",
      "Convert markdown to destination-specific HTML and plain text. Returns JSON with 'html' and 'plain_text' fields. For Slack, present the plain_text to the user. For Google Docs/Word/OneNote, direct users to unmarkdown.com to use the copy button (raw HTML cannot be pasted into these apps). Does not render Chart.js, Mermaid, Graphviz, or KaTeX; use publish_document for documents with diagrams or math.",
      {
        markdown: z.string().describe("Markdown content to convert"),
        destination: z
          .enum([
            "google-docs",
            "word",
            "slack",
            "onenote",
            "email",
            "plain-text",
            "generic",
            "html",
          ])
          .optional()
          .describe('Target format (default: "generic")'),
        template_id: z
          .string()
          .optional()
          .describe('Visual template ID (default: "swiss")'),
        theme_mode: z
          .enum(["light", "dark"])
          .optional()
          .describe('Color theme (default: "light")'),
      },
      {
        title: "Convert Markdown",
        readOnlyHint: true,
        destructiveHint: false,
        idempotentHint: true,
        openWorldHint: true,
      },
      async ({ markdown, destination, template_id, theme_mode }) => {
        try {
          const body: Record<string, unknown> = { markdown };
          if (destination) body.destination = destination;
          if (template_id) body.template_id = template_id;
          if (theme_mode) body.theme_mode = theme_mode;
          const result = await client.request("POST", "/v1/convert", body);
          return jsonResult(result);
        } catch (err) {
          return errorResult(err);
        }
      },
    );
  • Zod schema defining input parameters: markdown (required), destination (optional enum), template_id (optional), theme_mode (optional).
    {
      markdown: z.string().describe("Markdown content to convert"),
      destination: z
        .enum([
          "google-docs",
          "word",
          "slack",
          "onenote",
          "email",
          "plain-text",
          "generic",
          "html",
        ])
        .optional()
        .describe('Target format (default: "generic")'),
      template_id: z
        .string()
        .optional()
        .describe('Visual template ID (default: "swiss")'),
      theme_mode: z
        .enum(["light", "dark"])
        .optional()
        .describe('Color theme (default: "light")'),
    },
    {
      title: "Convert Markdown",
      readOnlyHint: true,
      destructiveHint: false,
      idempotentHint: true,
      openWorldHint: true,
    },
  • The handler function that executes the tool logic: sends markdown and optional params to the /v1/convert API endpoint.
    async ({ markdown, destination, template_id, theme_mode }) => {
      try {
        const body: Record<string, unknown> = { markdown };
        if (destination) body.destination = destination;
        if (template_id) body.template_id = template_id;
        if (theme_mode) body.theme_mode = theme_mode;
        const result = await client.request("POST", "/v1/convert", body);
        return jsonResult(result);
      } catch (err) {
        return errorResult(err);
      }
    },
  • Helper function that wraps the API response in a JSON text MCP content result.
    function jsonResult(data: unknown) {
      return {
        content: [
          { type: "text" as const, text: JSON.stringify(data, null, 2) },
        ],
      };
  • Helper function that formats errors into MCP error content results.
    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,
      };
    }
Behavior5/5

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

Annotations already indicate read-only, idempotent, non-destructive; description adds key behavioral details: output format (JSON with html/plain_text), paste limitations for certain apps, and unsupported rendering features.

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?

Very concise, well-structured: purpose, output format, destination-specific instructions, limitations, and alternative. Every sentence adds value.

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

Completeness5/5

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

The tool is simple (4 params, no output schema) and the description covers output, usage constraints, and alternatives, making it fully actionable.

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?

With 100% schema description coverage, the schema already explains all parameters adequately; the description does not add significant new meaning beyond what schema provides.

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 it converts markdown to destination-specific HTML and plain text, and explicitly distinguishes from sibling publish_document by noting limitations (no diagram/math rendering).

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

Usage Guidelines5/5

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

Provides explicit instructions for different destinations (e.g., Slack: use plain_text; Google Docs/Word/OneNote: use unmarkdown.com) and directly says when to use publish_document instead.

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