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,
            },
          ],
        };
      }
    );
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