Skip to main content
Glama
zcaceres

Fetch MCP Server

by zcaceres

fetch_markdown

Convert website content to Markdown format by fetching URLs, enabling structured extraction of web data for documentation or analysis.

Instructions

Fetch a website and return its contents converted content to Markdown

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesURL of the website to fetch
headersNoOptional headers to include in the request
max_lengthNoMaximum number of characters to return (default: 5000})
start_indexNoStart content from this character index (default: 0)

Implementation Reference

  • The core handler function for fetch_markdown tool. Fetches the URL, converts HTML to Markdown using TurndownService, applies length limits, and returns the content.
    static async markdown(requestPayload: RequestPayload) {
      try {
        const response = await this._fetch(requestPayload);
        const html = await response.text();
        const turndownService = new TurndownService();
        let markdown = turndownService.turndown(html);
        
        // Apply length limits
        markdown = this.applyLengthLimits(
          markdown,
          requestPayload.max_length ?? 5000,
          requestPayload.start_index ?? 0
        );
        
        return { content: [{ type: "text", text: markdown }], isError: false };
      } catch (error) {
        return {
          content: [{ type: "text", text: (error as Error).message }],
          isError: true,
        };
      }
    }
  • Tool schema definition including input schema for fetch_markdown, registered in ListTools response.
    {
      name: "fetch_markdown",
      description: "Fetch a website and return its contents converted content to Markdown",
      inputSchema: {
        type: "object",
        properties: {
          url: {
            type: "string",
            description: "URL of the website to fetch",
          },
          headers: {
            type: "object",
            description: "Optional headers to include in the request",
          },
          max_length: {
            type: "number",
            description: `Maximum number of characters to return (default: ${downloadLimit}})`,
          },
          start_index: {
            type: "number",
            description: "Start content from this character index (default: 0)",
          },
        },
        required: ["url"],
      },
    },
  • src/index.ts:156-159 (registration)
    Registration of the fetch_markdown handler in the CallToolRequestSchema handler, dispatching to Fetcher.markdown.
    if (request.params.name === "fetch_markdown") {
      const fetchResult = await Fetcher.markdown(validatedArgs);
      return fetchResult;
    }
  • Shared Zod schema for request payload validation, used for all fetch tools including fetch_markdown.
    export const RequestPayloadSchema = z.object({
      url: z.string().url(),
      headers: z.record(z.string()).optional(),
      max_length: z.number().int().min(0).optional().default(downloadLimit),
      start_index: z.number().int().min(0).optional().default(0),
    });
  • Helper method to apply max_length and start_index limits to the fetched content.
    private static applyLengthLimits(text: string, maxLength: number, startIndex: number): string {
      if (startIndex >= text.length) {
        return "";
      }
      
      const end = maxLength > 0 ? Math.min(startIndex + maxLength, text.length) : text.length;
      return text.substring(startIndex, end);
    }
Behavior2/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 of behavioral disclosure. It states the tool fetches and converts content, but lacks details on error handling, rate limits, authentication needs, or what happens with invalid URLs. For a web-fetching tool with zero annotation coverage, this is a significant gap in transparency.

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 a single, efficient sentence: 'Fetch a website and return its contents converted content to Markdown.' It's front-loaded with the core purpose, has zero wasted words, and is appropriately sized for the tool's complexity.

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

Completeness2/5

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

Given the tool's complexity (web fetching with conversion), lack of annotations, and no output schema, the description is incomplete. It doesn't cover behavioral aspects like error cases, performance, or output format details. For a tool that interacts with external resources and transforms data, more context is needed.

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 four parameters (url, headers, max_length, start_index). The description adds no additional parameter semantics beyond what's in the schema, such as format examples or constraints. Baseline 3 is appropriate when the schema does the heavy lifting.

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

Purpose4/5

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

The description clearly states the tool's purpose: 'Fetch a website and return its contents converted content to Markdown.' It specifies the verb ('fetch'), resource ('website'), and transformation ('converted to Markdown'). However, it doesn't explicitly differentiate from sibling tools like fetch_html, fetch_json, and fetch_txt, which presumably return different formats.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools or contexts where Markdown output is preferred over HTML, JSON, or plain text. Usage is implied by the tool's name and purpose, but no explicit when/when-not instructions are given.

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/zcaceres/fetch-mcp'

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