Skip to main content
Glama
zcag
by zcag

convert_html

Convert HTML content to clean Markdown optimized for LLM processing, extracting main content and resolving links for better AI analysis.

Instructions

Convert an HTML string to clean, LLM-optimized Markdown. Use this when you already have HTML content and need it as Markdown.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
htmlYesThe HTML content to convert
urlNoBase URL for resolving relative links and images
include_headerNoInclude title/source/author header in output
rawNoUse full HTML content instead of extracting main article

Implementation Reference

  • Handler function for 'convert_html' tool - takes HTML string and converts it to Markdown using the readdown library. Accepts optional url, include_header, and raw parameters, then returns the markdown content.
    async ({ html, url, include_header, raw }) => {
      const result = readdown(html, {
        url,
        includeHeader: include_header,
        raw,
      });
    
      return {
        content: [
          {
            type: "text" as const,
            text: result.markdown,
          },
        ],
      };
    }
  • Zod schema definition for 'convert_html' tool inputs: html (required string), url (optional URL string for resolving relative links), include_header (optional boolean, default true), and raw (optional boolean, default false).
      html: z.string().describe("The HTML content to convert"),
      url: z
        .string()
        .url()
        .optional()
        .describe("Base URL for resolving relative links and images"),
      include_header: z
        .boolean()
        .optional()
        .default(true)
        .describe("Include title/source/author header in output"),
      raw: z
        .boolean()
        .optional()
        .default(false)
        .describe("Use full HTML content instead of extracting main article"),
    },
  • src/index.ts:91-129 (registration)
    Tool registration for 'convert_html' using server.tool() - registers the tool name, description, input schema, and handler function with the MCP server.
    server.tool(
      "convert_html",
      "Convert an HTML string to clean, LLM-optimized Markdown. " +
        "Use this when you already have HTML content and need it as Markdown.",
      {
        html: z.string().describe("The HTML content to convert"),
        url: z
          .string()
          .url()
          .optional()
          .describe("Base URL for resolving relative links and images"),
        include_header: z
          .boolean()
          .optional()
          .default(true)
          .describe("Include title/source/author header in output"),
        raw: z
          .boolean()
          .optional()
          .default(false)
          .describe("Use full HTML content instead of extracting main article"),
      },
      async ({ html, url, include_header, raw }) => {
        const result = readdown(html, {
          url,
          includeHeader: include_header,
          raw,
        });
    
        return {
          content: [
            {
              type: "text" as const,
              text: result.markdown,
            },
          ],
        };
      }
    );
Behavior3/5

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

No annotations are provided, so the description carries the full burden. It mentions the tool's purpose and context but lacks details on behavioral traits like error handling, performance, or output characteristics (e.g., formatting specifics, limitations).

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?

The description is front-loaded with the core purpose in the first sentence and adds a usage guideline in the second, with no wasted words. Every sentence contributes directly to understanding the tool.

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

Completeness3/5

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

Given no annotations and no output schema, the description is adequate for basic understanding but lacks details on behavioral aspects and output format. It covers purpose and usage but does not fully compensate for the missing structured information.

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 description coverage is 100%, so the schema fully documents all parameters. The description does not add any parameter-specific details beyond what the schema provides, meeting the baseline for high coverage.

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 specific action ('convert'), resource ('HTML string'), and outcome ('clean, LLM-optimized Markdown'), distinguishing it from the sibling 'fetch_markdown' which likely fetches content rather than converting existing HTML.

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 explicit context for when to use ('when you already have HTML content and need it as Markdown'), which helps differentiate from 'fetch_markdown', but does not specify when not to use or mention alternative tools beyond the sibling.

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/zcag/readdown-mcp'

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