Skip to main content
Glama
zcag
by zcag

fetch_markdown

Convert web pages to clean Markdown with metadata and token counts for LLM processing. Use this tool to extract article content from URLs with a lightweight, browserless approach.

Instructions

Fetch a web page and convert it to clean, LLM-optimized Markdown. Returns the article content with metadata (title, author, date) and token count. Much faster and lighter than browser-based solutions.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesThe URL of the web page to fetch and convert
include_headerNoInclude title/source/author header in output
rawNoExtract full page content instead of just the main article

Implementation Reference

  • The async handler function that executes the fetch_markdown tool logic. It fetches the URL, converts HTML to Markdown using the readdown library, and returns the content with metadata (tokens, characters, title, author, date).
    async ({ url, include_header, raw }) => {
      try {
        const response = await fetch(url, {
          headers: {
            "User-Agent":
              "Mozilla/5.0 (compatible; readdown/0.1; +https://github.com/zcag/readdown)",
            Accept: "text/html,application/xhtml+xml",
          },
          signal: AbortSignal.timeout(15000),
        });
    
        if (!response.ok) {
          return {
            content: [
              {
                type: "text" as const,
                text: `Failed to fetch ${url}: HTTP ${response.status} ${response.statusText}`,
              },
            ],
            isError: true,
          };
        }
    
        const html = await response.text();
        const result = readdown(html, {
          url,
          includeHeader: include_header,
          raw,
        });
    
        const summary = [
          `Tokens: ~${result.tokens}`,
          `Characters: ${result.chars}`,
          result.metadata.title ? `Title: ${result.metadata.title}` : null,
          result.metadata.author ? `Author: ${result.metadata.author}` : null,
          result.metadata.date ? `Date: ${result.metadata.date}` : null,
        ]
          .filter(Boolean)
          .join(" | ");
    
        return {
          content: [
            { type: "text" as const, text: `[${summary}]\n\n${result.markdown}` },
          ],
        };
      } catch (err) {
        const message = err instanceof Error ? err.message : String(err);
        return {
          content: [
            {
              type: "text" as const,
              text: `Error fetching ${url}: ${message}`,
            },
          ],
          isError: true,
        };
      }
    }
  • Input schema definition using Zod. Defines three parameters: url (required string URL), include_header (optional boolean, default true), and raw (optional boolean, default false).
    {
      url: z.string().url().describe("The URL of the web page to fetch and convert"),
      include_header: z
        .boolean()
        .optional()
        .default(true)
        .describe("Include title/source/author header in output"),
      raw: z
        .boolean()
        .optional()
        .default(false)
        .describe("Extract full page content instead of just the main article"),
    },
  • src/index.ts:13-89 (registration)
    Tool registration using server.tool(). Registers the 'fetch_markdown' tool with its name, description, schema, and handler function.
    server.tool(
      "fetch_markdown",
      "Fetch a web page and convert it to clean, LLM-optimized Markdown. " +
        "Returns the article content with metadata (title, author, date) and token count. " +
        "Much faster and lighter than browser-based solutions.",
      {
        url: z.string().url().describe("The URL of the web page to fetch and convert"),
        include_header: z
          .boolean()
          .optional()
          .default(true)
          .describe("Include title/source/author header in output"),
        raw: z
          .boolean()
          .optional()
          .default(false)
          .describe("Extract full page content instead of just the main article"),
      },
      async ({ url, include_header, raw }) => {
        try {
          const response = await fetch(url, {
            headers: {
              "User-Agent":
                "Mozilla/5.0 (compatible; readdown/0.1; +https://github.com/zcag/readdown)",
              Accept: "text/html,application/xhtml+xml",
            },
            signal: AbortSignal.timeout(15000),
          });
    
          if (!response.ok) {
            return {
              content: [
                {
                  type: "text" as const,
                  text: `Failed to fetch ${url}: HTTP ${response.status} ${response.statusText}`,
                },
              ],
              isError: true,
            };
          }
    
          const html = await response.text();
          const result = readdown(html, {
            url,
            includeHeader: include_header,
            raw,
          });
    
          const summary = [
            `Tokens: ~${result.tokens}`,
            `Characters: ${result.chars}`,
            result.metadata.title ? `Title: ${result.metadata.title}` : null,
            result.metadata.author ? `Author: ${result.metadata.author}` : null,
            result.metadata.date ? `Date: ${result.metadata.date}` : null,
          ]
            .filter(Boolean)
            .join(" | ");
    
          return {
            content: [
              { type: "text" as const, text: `[${summary}]\n\n${result.markdown}` },
            ],
          };
        } catch (err) {
          const message = err instanceof Error ? err.message : String(err);
          return {
            content: [
              {
                type: "text" as const,
                text: `Error fetching ${url}: ${message}`,
              },
            ],
            isError: true,
          };
        }
      }
    );
Behavior3/5

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

With no annotations provided, the description carries the full burden. It discloses key behavioral traits: it returns article content with metadata and token count, and is 'much faster and lighter than browser-based solutions.' However, it lacks details on error handling, rate limits, authentication needs, or what 'clean, LLM-optimized' specifically entails.

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 appropriately sized and front-loaded, with two sentences that efficiently convey purpose, output, and key benefits. Every sentence adds value without redundancy, making it easy to scan and understand quickly.

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 the tool's moderate complexity (3 parameters, no annotations, no output schema), the description is somewhat complete but has gaps. It explains the output includes metadata and token count, but without an output schema, it doesn't detail the return structure. For a tool performing web fetching and conversion, more behavioral context would be helpful.

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 already documents all parameters. The description adds no additional meaning beyond what the schema provides, such as explaining the implications of 'raw' mode or 'include_header' in more detail. Baseline 3 is appropriate when schema does the heavy lifting.

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 ('fetch a web page and convert it to clean, LLM-optimized Markdown') and distinguishes it from the sibling tool 'convert_html' by emphasizing web fetching and LLM optimization. It explicitly mentions the resource (web page) and output format (Markdown).

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?

The description provides clear context for when to use this tool ('fetch a web page... faster and lighter than browser-based solutions'), but does not explicitly state when not to use it or mention alternatives beyond the sibling tool. It implies usage for web content extraction with performance benefits.

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