Skip to main content
Glama
Mantraa-Zzz

Web Search MCP Server

by Mantraa-Zzz

web_scrape

Extract text content and metadata from any webpage URL for data collection and analysis purposes.

Instructions

抓取指定网页的内容,提取文本和元数据

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
extractMetadataNo是否提取元数据(默认true)
extractTextNo是否提取纯文本内容(默认true)
urlYes要抓取的网页URL

Implementation Reference

  • Primary handler for executing the web_scrape tool. Parses arguments, invokes the scraping helper, formats scraped data (title, URL, metadata, content preview) into a text response, and propagates errors.
    private async handleWebScrape(args: any) {
      const { url, extractText = true, extractMetadata = true } = args;
    
      try {
        const content = await this.scrapeWebPage(url, extractText, extractMetadata);
        
        let result = `网页内容抓取结果:\n\n`;
        result += `**标题**: ${content.title}\n`;
        result += `**URL**: ${content.url}\n\n`;
        
        if (extractMetadata && content.metadata) {
          result += `**元数据**:\n`;
          if (content.metadata.description) {
            result += `- 描述: ${content.metadata.description}\n`;
          }
          if (content.metadata.keywords) {
            result += `- 关键词: ${content.metadata.keywords}\n`;
          }
          if (content.metadata.author) {
            result += `- 作者: ${content.metadata.author}\n`;
          }
          if (content.metadata.publishedDate) {
            result += `- 发布日期: ${content.metadata.publishedDate}\n`;
          }
          result += `\n`;
        }
        
        if (extractText) {
          result += `**内容摘要** (前500字符):\n${content.content.substring(0, 500)}${content.content.length > 500 ? '...' : ''}`;
        }
    
        return {
          content: [
            {
              type: 'text',
              text: result,
            },
          ],
        };
      } catch (error) {
        throw new Error(`网页抓取失败: ${error instanceof Error ? error.message : String(error)}`);
      }
    }
  • Input schema defining the parameters for the web_scrape tool: required URL and optional flags for text and metadata extraction.
    inputSchema: {
      type: 'object',
      properties: {
        url: {
          type: 'string',
          description: '要抓取的网页URL',
        },
        extractText: {
          type: 'boolean',
          description: '是否提取纯文本内容(默认true)',
          default: true,
        },
        extractMetadata: {
          type: 'boolean',
          description: '是否提取元数据(默认true)',
          default: true,
        },
      },
      required: ['url'],
    },
  • src/index.ts:98-121 (registration)
    Registration of the web_scrape tool in the ListToolsRequestSchema response, specifying name, description, and input schema.
    {
      name: 'web_scrape',
      description: '抓取指定网页的内容,提取文本和元数据',
      inputSchema: {
        type: 'object',
        properties: {
          url: {
            type: 'string',
            description: '要抓取的网页URL',
          },
          extractText: {
            type: 'boolean',
            description: '是否提取纯文本内容(默认true)',
            default: true,
          },
          extractMetadata: {
            type: 'boolean',
            description: '是否提取元数据(默认true)',
            default: true,
          },
        },
        required: ['url'],
      },
    },
  • Core helper function implementing the web scraping logic: fetches page with axios, parses with cheerio, extracts title, cleans text content, and scrapes meta tags for metadata.
    private async scrapeWebPage(url: string, extractText: boolean, extractMetadata: boolean): Promise<WebPageContent> {
      const response = await axios.get(url, {
        timeout: this.requestTimeout,
        headers: {
          'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36',
        },
      });
    
      const $ = cheerio.load(response.data);
      
      const title = $('title').text().trim() || '无标题';
      let content = '';
      let metadata: any = {};
    
      if (extractText) {
        // 移除脚本和样式标签
        $('script, style, nav, header, footer, aside').remove();
        content = $('body').text().replace(/\s+/g, ' ').trim();
      }
    
      if (extractMetadata) {
        metadata = {
          description: $('meta[name="description"]').attr('content') || 
                      $('meta[property="og:description"]').attr('content'),
          keywords: $('meta[name="keywords"]').attr('content'),
          author: $('meta[name="author"]').attr('content') || 
                  $('meta[property="article:author"]').attr('content'),
          publishedDate: $('meta[property="article:published_time"]').attr('content') ||
                        $('meta[name="date"]').attr('content'),
        };
      }
    
      return {
        url,
        title,
        content,
        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 extraction of text and metadata but fails to describe critical traits such as rate limits, authentication needs, error handling (e.g., for invalid URLs), or output format. This is inadequate for a web scraping tool that likely involves network operations and potential restrictions.

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 in Chinese that directly states the tool's function without unnecessary words. It is front-loaded with the core purpose and appropriately sized for a simple tool, making it easy for an agent 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 complexity of web scraping (involving network calls, potential errors, and content parsing) and the absence of both annotations and an output schema, the description is insufficient. It does not explain what 'extract text and metadata' entails in practice (e.g., structured data, limitations), leaving gaps in understanding the tool's behavior and results.

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, clearly documenting all three parameters (url, extractText, extractMetadata) with their types, defaults, and purposes. The description adds no additional parameter semantics beyond what the schema provides, so it meets the baseline score of 3 for high schema coverage.

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 as '抓取指定网页的内容,提取文本和元数据' (scrape content from specified web pages, extract text and metadata), which includes a specific verb ('抓取' - scrape) and resource ('网页' - web pages). It distinguishes from sibling tools like 'web_search' by focusing on extraction rather than searching, though it doesn't explicitly mention how it differs from 'web_search_and_scrape'.

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 'web_search' or 'web_search_and_scrape'. It lacks context on prerequisites (e.g., URL validity), exclusions (e.g., dynamic content), or comparisons with siblings, leaving the agent to infer usage based on tool names alone.

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/Mantraa-Zzz/Web_Search'

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