Skip to main content
Glama

fetch_website_single

Fetch content from a single webpage and convert it to clean markdown format for structured data extraction and processing.

Instructions

Fetch content from a single webpage and convert to clean markdown

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesThe URL to fetch
timeoutNoRequest timeout in milliseconds (default: 10000)

Implementation Reference

  • src/server.ts:345-363 (registration)
    Registration of the 'fetch_website_single' tool in the TOOLS array, including name, description, and input schema definition.
    {
      name: "fetch_website_single",
      description: "Fetch content from a single webpage and convert to clean markdown",
      inputSchema: {
        type: "object",
        properties: {
          url: {
            type: "string",
            description: "The URL to fetch",
          },
          timeout: {
            type: "number",
            description: "Request timeout in milliseconds (default: 10000)",
            default: 10000,
          },
        },
        required: ["url"],
      },
    },
  • Handler function for executing the 'fetch_website_single' tool. Validates input, configures single-page scraping options, invokes the scraper, and returns markdown content.
    case "fetch_website_single": {
      const { url, timeout = 10000 } = args as any;
    
      if (!url) {
        throw new Error("URL is required");
      }
    
      try {
        const options: FetchOptions = {
          maxDepth: 0,
          maxPages: 1,
          timeout,
        };
    
        const markdown = await scraper.scrapeWebsite(url, options);
    
        return {
          content: [
            {
              type: "text",
              text: markdown,
            },
          ],
        };
      } catch (error) {
        throw new Error(`Failed to fetch single page: ${error}`);
      }
    }
  • Core scraping logic used by the tool (configured with maxDepth=0 for single page). Fetches page content, processes links based on depth, and formats as markdown.
    async scrapeWebsite(startUrl: string, options: FetchOptions = {}): Promise<string> {
      const {
        maxDepth = 2,
        maxPages = 50,
        sameDomainOnly = true,
        timeout = 10000
      } = options;
    
      this.baseUrl = startUrl;
      this.visitedUrls.clear();
    
      const allContent: PageContent[] = [];
      const urlsToProcess: Array<{ url: string; depth: number }> = [{ url: startUrl, depth: 0 }];
    
      while (urlsToProcess.length > 0 && allContent.length < maxPages) {
        const { url, depth } = urlsToProcess.shift()!;
    
        if (depth > maxDepth || this.visitedUrls.has(url)) {
          continue;
        }
    
        const pageContent = await this.fetchPageContent(url, depth, options);
        
        if (pageContent) {
          allContent.push(pageContent);
    
          // Add child URLs for processing
          if (depth < maxDepth) {
            for (const link of pageContent.links) {
              if (!this.visitedUrls.has(link)) {
                urlsToProcess.push({ url: link, depth: depth + 1 });
              }
            }
          }
        }
    
        // Small delay to be respectful
        await new Promise(resolve => setTimeout(resolve, 500));
      }
    
      return this.formatAsMarkdown(allContent, startUrl);
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden. It mentions conversion to markdown, which is a behavioral trait, but lacks details on error handling, rate limits, authentication needs, or what 'clean' entails. This is inadequate for a tool that performs network operations.

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 with zero waste. It is front-loaded with the core purpose and transformation, making it easy to understand quickly.

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 no annotations and no output schema, the description is incomplete. It lacks information on return values (e.g., markdown structure, error formats), behavioral constraints, and differentiation from the sibling tool, which is crucial for a tool with network dependencies.

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 both parameters. The description does not add any meaning beyond what the schema provides, such as URL format expectations or timeout implications. 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 content'), target resource ('from a single webpage'), and transformation ('convert to clean markdown'). It distinguishes from the sibling tool 'fetch_website_nested' by specifying 'single' versus implied nested/multiple pages.

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 for fetching a single webpage's content, but does not explicitly state when to use this tool versus the sibling 'fetch_website_nested' or other alternatives. No exclusions or prerequisites are mentioned.

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/flutterninja9/better-fetch'

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