Skip to main content
Glama
amotivv

Web Content MCP Server

fetch_page

Retrieve and process web pages for LLM context using a URL, with options to include screenshots or limit content length. Part of the Web Content MCP Server for enhanced data extraction.

Instructions

Fetches and processes a web page for LLM context

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
includeScreenshotNoWhether to include a screenshot (base64 encoded)
maxContentLengthNoMaximum content length to return
urlYesURL to fetch

Implementation Reference

  • Main handler function executing the fetch_page tool logic: validates input, fetches and processes page content, optionally includes screenshot, truncates if needed, and formats response.
    private async handleFetchPage(args: any) {
      // Validate arguments
      if (typeof args !== 'object' || args === null || typeof args.url !== 'string') {
        throw new McpError(ErrorCode.InvalidParams, 'Invalid arguments for fetch_page');
      }
    
      const { url, includeScreenshot = false, maxContentLength = 10000 } = args;
    
      try {
        // Fetch the page content
        const html = await this.browserClient.fetchContent(url);
        
        // Process the content for LLM
        const processedContent = this.contentProcessor.processForLLM(html, url);
        
        // Truncate if necessary
        const truncatedContent = processedContent.length > maxContentLength
          ? processedContent.substring(0, maxContentLength) + '...'
          : processedContent;
        
        // Get screenshot if requested
        let screenshot = null;
        if (includeScreenshot) {
          screenshot = await this.browserClient.takeScreenshot(url);
        }
        
        // Return the result
        return {
          content: [
            {
              type: 'text',
              text: truncatedContent,
            },
            ...(screenshot ? [{
              type: 'image',
              image: screenshot,
            }] : []),
          ],
        };
      } catch (error) {
        console.error('Error fetching page:', error);
        return {
          content: [
            {
              type: 'text',
              text: `Error fetching page: ${error instanceof Error ? error.message : String(error)}`,
            },
          ],
          isError: true,
        };
      }
    }
  • Input schema and metadata definition for the fetch_page tool in the ListTools response.
      name: 'fetch_page',
      description: 'Fetches and processes a web page for LLM context',
      inputSchema: {
        type: 'object',
        properties: {
          url: {
            type: 'string',
            description: 'URL to fetch',
          },
          includeScreenshot: {
            type: 'boolean',
            description: 'Whether to include a screenshot (base64 encoded)',
          },
          maxContentLength: {
            type: 'number',
            description: 'Maximum content length to return',
          },
        },
        required: ['url'],
      },
    },
  • src/server.ts:146-147 (registration)
    Registration of the fetch_page handler in the tool call dispatcher switch statement.
    case 'fetch_page':
      return await this.handleFetchPage(args);
  • Helper method in BrowserClient that fetches rendered HTML content from Cloudflare Browser Rendering API.
    async fetchContent(url: string): Promise<string> {
      try {
        console.log(`Fetching content from: ${url}`);
        
        // Make the API call to the Cloudflare Worker
        const response = await axios.post(`${this.apiEndpoint}/content`, {
          url,
          rejectResourceTypes: ['image', 'font', 'media'],
          waitUntil: 'networkidle0',
        });
        
        return response.data.content;
      } catch (error) {
        console.error('Error fetching content:', error);
        throw new Error(`Failed to fetch content: ${error instanceof Error ? error.message : String(error)}`);
      }
    }
  • Helper method in ContentProcessor that converts HTML to LLM-friendly markdown with extracted metadata.
    processForLLM(html: string, url: string): string {
      // Extract metadata
      const metadata = this.extractMetadata(html, url);
      
      // Clean the content
      const cleanedContent = this.cleanContent(html);
      
      // Format for LLM context
      return this.formatForLLM(cleanedContent, metadata);
    }
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 'fetches and processes' but doesn't clarify aspects like rate limits, authentication needs, error handling, or what 'processes' entails (e.g., cleaning HTML, extracting text). This leaves significant gaps for a tool that interacts with external resources.

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 that front-loads the core purpose without any wasted words. It's appropriately sized for the tool's complexity, making it easy to parse 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 the tool's complexity (fetching and processing web pages), lack of annotations, and no output schema, the description is incomplete. It doesn't explain return values, error cases, or behavioral traits, leaving the agent with insufficient information for reliable use.

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 input schema has 100% description coverage, so the baseline is 3. The description adds no additional meaning beyond the schema, which already details parameters like 'url', 'includeScreenshot', and 'maxContentLength'. No extra syntax, format, or usage context is provided.

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 with specific verbs ('fetches and processes') and resource ('a web page'), and specifies the outcome ('for LLM context'). It doesn't explicitly differentiate from sibling tools like 'extract_structured_content' or 'summarize_content', which prevents a perfect score.

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 like 'extract_structured_content' or 'search_documentation'. It lacks context about prerequisites, exclusions, or comparative use cases, offering only a basic functional statement.

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/amotivv/cloudflare-browser-rendering'

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