Skip to main content
Glama
goswamig

Fetch MCP Server

by goswamig

fetch_txt

Extract plain text content from any website by providing a URL. Excludes HTML for cleaner output, with optional headers for custom requests.

Instructions

Fetch a website, return the content as plain text (no HTML)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
headersNoOptional headers to include in the request
urlYesURL of the website to fetch

Implementation Reference

  • The main handler function for 'fetch_txt' tool. Fetches HTML, uses JSDOM to parse, removes scripts and styles, extracts body textContent, normalizes whitespace, and returns as plain text content.
    static async txt(requestPayload: RequestPayload) {
      try {
        const response = await this._fetch(requestPayload);
        const html = await response.text();
    
        const dom = new JSDOM(html);
        const document = dom.window.document;
    
        const scripts = document.getElementsByTagName("script");
        const styles = document.getElementsByTagName("style");
        Array.from(scripts).forEach((script) => script.remove());
        Array.from(styles).forEach((style) => style.remove());
    
        const text = document.body.textContent || "";
    
        const normalizedText = text.replace(/\s+/g, " ").trim();
    
        return {
          content: [{ type: "text", text: normalizedText }],
          isError: false,
        };
      } catch (error) {
        return {
          content: [{ type: "text", text: (error as Error).message }],
          isError: true,
        };
      }
    }
  • src/index.ts:118-120 (registration)
    Registration/dispatch logic in CallToolRequest handler that invokes Fetcher.txt for 'fetch_txt' tool.
    if (request.params.name === "fetch_txt") {
      const fetchResult = await Fetcher.txt(validatedArgs);
      return fetchResult;
  • Tool schema definition including name, description, and inputSchema for 'fetch_txt' registered in ListTools handler.
    {
      name: "fetch_txt",
      description:
        "Fetch a website, return the content as plain text (no HTML)",
      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",
          },
        },
        required: ["url"],
      },
    },
  • Zod schema for request payload (url required, headers optional) used to validate inputs for all fetch tools including 'fetch_txt'.
    export const RequestPayloadSchema = z.object({
      url: z.string().url(),
      headers: z.record(z.string()).optional(),
    });
  • Helper function to perform the actual fetch with custom User-Agent and error handling, used by all tool handlers including 'fetch_txt'.
    export class Fetcher {
      private static async _fetch({
        url,
        headers,
      }: RequestPayload): Promise<Response> {
        try {
          const response = await fetch(url, {
            headers: {
              "User-Agent":
                "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
              ...headers,
            },
          });
    
          if (!response.ok) {
            throw new Error(`HTTP error: ${response.status}`);
          }
          return response;
        } catch (e: unknown) {
          if (e instanceof Error) {
            throw new Error(`Failed to fetch ${url}: ${e.message}`);
          } else {
            throw new Error(`Failed to fetch ${url}: Unknown error`);
          }
        }
      }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions the action ('fetch a website') and output format, but fails to disclose critical traits such as error handling, rate limits, authentication needs, or whether it follows redirects. This leaves significant gaps in understanding the tool's behavior beyond basic functionality.

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 extremely concise and front-loaded, consisting of a single sentence that directly states the tool's purpose and key differentiator. There is no wasted language, and every word earns its place by conveying essential information efficiently.

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 complexity of a web-fetching tool with no annotations and no output schema, the description is incomplete. It lacks details on behavioral aspects (e.g., error handling, timeouts) and output specifics (e.g., structure of returned text), which are crucial for effective use. The description does not compensate for the absence of structured data, leaving significant gaps in understanding.

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?

The schema description coverage is 100%, with clear descriptions for both parameters (e.g., 'URL of the website to fetch'). The description adds no additional parameter semantics beyond what the schema provides, such as format examples or constraints. Given the high schema coverage, the baseline score of 3 is appropriate, as the schema adequately documents the parameters.

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 tool's purpose with a specific verb ('fetch') and resource ('website'), and explicitly distinguishes it from siblings by specifying the output format ('plain text (no HTML)'). This directly contrasts with fetch_html, fetch_json, and fetch_markdown, making the differentiation unambiguous.

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

Usage Guidelines3/5

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

The description implies usage context by specifying the output format ('plain text'), which suggests when to use this tool over siblings that return HTML, JSON, or Markdown. However, it lacks explicit guidance on when not to use it or detailed alternatives beyond the sibling names, leaving some ambiguity about specific use cases.

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

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

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