Skip to main content
Glama
pgzhang

MCP Google Server

by pgzhang

read_webpage

Extract readable text content from any webpage URL for analysis or processing.

Instructions

Fetch and extract text content from a webpage

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesURL of the webpage to read

Implementation Reference

  • Handler for the 'read_webpage' tool: validates input arguments, fetches the webpage content using axios, parses HTML with cheerio to extract title and cleaned text, returns structured content as JSON or error.
    } else if (request.params.name === 'read_webpage') {
      if (!isValidWebpageArgs(request.params.arguments)) {
        throw new McpError(
          ErrorCode.InvalidParams,
          'Invalid webpage arguments'
        );
      }
    
      const { url } = request.params.arguments;
    
      try {
        const response = await axios.get(url);
        const $ = cheerio.load(response.data);
    
        // Remove script and style elements
        $('script, style').remove();
    
        const content: WebpageContent = {
          title: $('title').text().trim(),
          text: $('body').text().trim().replace(/\s+/g, ' '),
          url: url,
        };
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(content, null, 2),
            },
          ],
        };
      } catch (error) {
        if (axios.isAxiosError(error)) {
          return {
            content: [
              {
                type: 'text',
                text: `Webpage fetch error: ${error.message}`,
              },
            ],
            isError: true,
          };
        }
        throw error;
      }
    }
  • src/index.ts:109-122 (registration)
    Registration of the 'read_webpage' tool in the ListToolsRequestHandler, including name, description, and input schema definition.
    {
      name: 'read_webpage',
      description: 'Fetch and extract text content from a webpage',
      inputSchema: {
        type: 'object',
        properties: {
          url: {
            type: 'string',
            description: 'URL of the webpage to read',
          },
        },
        required: ['url'],
      },
    },
  • Helper function to validate input arguments for the 'read_webpage' tool.
    const isValidWebpageArgs = (
      args: any
    ): args is { url: string } =>
      typeof args === 'object' &&
      args !== null &&
      typeof args.url === 'string';
  • TypeScript interface defining the structure of the webpage content returned by the tool.
    interface WebpageContent {
      title: string;
      text: string;
      url: string;
    }

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A3.5/5.0
Behavior2/5

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

No annotations are provided, so the description must cover behavioral traits. It only states basic purpose without mentioning rate limits, authentication, dynamic content handling, or error responses.

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?

Single sentence, front-loaded with action, no unnecessary words. Perfectly concise.

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?

For a simple tool with one parameter and no output schema, the description is adequate but lacks details on handling of large pages, timeouts, or what 'text content' entails (e.g., stripping HTML).

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 coverage is 100% (single 'url' parameter described), so baseline is 3. The description adds no extra meaning beyond the schema, such as URL format or protocol support.

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?

Description clearly states the action ('Fetch and extract') and the resource ('text content from a webpage'), distinguishing it from sibling tool 'search' which is for querying.

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?

No explicit guidance on when to use this tool versus alternatives. The sibling 'search' suggests a different purpose, but the description does not clarify contexts or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools