Skip to main content
Glama

web_fetch

Retrieve and clean web page content for AI analysis and operational tasks, enabling secure access to online information within developer workflows.

Instructions

Получить содержимое веб-страницы

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesURL страницы

Implementation Reference

  • Core handler implementing web_fetch: fetches URL with axios, parses HTML using cheerio, extracts title, clean text, and links, with host validation.
    async fetchPage(url: string): Promise<WebPage> {
      try {
        console.log(`🌐 Получение страницы: ${url}`);
        
        // Проверяем разрешенные хосты
        this.validateUrl(url);
        
        // Получаем страницу
        const response = await axios.get(url, {
          headers: {
            'User-Agent': this.userAgent,
          },
          timeout: 10000, // 10 секунд таймаут
        });
        
        // Парсим HTML
        const $ = cheerio.load(response.data);
        
        // Извлекаем основную информацию
        const title = $('title').first().text().trim() || 'Без заголовка';
        
        // Убираем скрипты, стили и другие ненужные элементы
        $('script, style, noscript, iframe, img, svg').remove();
        
        // Получаем чистый текст
        const text = $('body').text()
          .replace(/\s+/g, ' ')
          .trim();
        
        // Получаем ссылки
        const links = $('a[href]')
          .map((_, el) => $(el).attr('href'))
          .get()
          .filter(href => href && href.startsWith('http'))
          .slice(0, 20); // Ограничиваем количество ссылок
        
        const page: WebPage = {
          url,
          title,
          content: response.data,
          text: text.substring(0, 5000), // Ограничиваем размер текста
          links,
        };
        
        console.log(`✅ Страница получена: ${title} (${text.length} символов, ${links.length} ссылок)`);
        
        return page;
      } catch (error) {
        console.error('Ошибка получения страницы:', error);
        throw new Error(`Ошибка получения страницы: ${error}`);
      }
    }
  • Output schema/interface for the web page data returned by the handler.
    export interface WebPage {
      url: string;
      title: string;
      content: string;
      text: string;
      links: string[];
    }
  • src/server.ts:118-131 (registration)
    Registration of web_fetch tool in MCP server's ListTools handler, including name, description, and input schema.
    {
      name: 'web_fetch',
      description: 'Получить содержимое веб-страницы',
      inputSchema: {
        type: 'object',
        properties: {
          url: {
            type: 'string',
            description: 'URL страницы',
          },
        },
        required: ['url'],
      },
    },
  • Dispatch handler in main MCP server CallToolRequestSchema that invokes WebService.fetchPage.
    case 'web_fetch':
      return {
        content: await this.webService.fetchPage(args.url as string)
      };
  • Registration of web_fetch tool in HTTP transport's /tools endpoint.
    {
      name: 'web_fetch',
      description: 'Получить содержимое веб-страницы',
      inputSchema: {
        type: 'object',
        properties: {
          url: { type: 'string', description: 'URL страницы' }
        },
        required: ['url']
      }
    },
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. While 'получить' (get) implies a read-only operation, it doesn't specify important behavioral traits like authentication requirements, rate limits, timeout handling, error conditions, or what happens with dynamic content (JavaScript, redirects). For a web fetching tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

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, focused sentence that directly states the tool's purpose without any unnecessary words. It's appropriately sized for a simple tool with one parameter and gets straight to the point with zero wasted verbiage.

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?

For a web fetching tool with no annotations and no output schema, the description is insufficiently complete. It doesn't explain what format the content is returned in (HTML, text, metadata), how errors are handled, whether it follows redirects, or any limitations (size, content types). Given the complexity of web fetching and the lack of structured documentation elsewhere, the description should provide more contextual information.

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 description doesn't add any parameter-specific information beyond what's already in the schema (which has 100% coverage). The schema fully documents the single 'url' parameter with its type and description. Since schema coverage is high, the baseline score of 3 is appropriate - the description doesn't compensate but doesn't need to given the comprehensive schema documentation.

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 'Получить содержимое веб-страницы' (Get web page content) clearly states the verb (get/retrieve) and resource (web page content), making the purpose immediately understandable. However, it doesn't differentiate from potential sibling tools like 'file_read' or 'rag_search' that might also retrieve content from different sources.

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 'file_read' (for local files) or 'rag_search' (for document search). There's no mention of prerequisites, limitations, or specific contexts where this tool is preferred over other content retrieval methods available in the sibling tool list.

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/Galiusbro/MCP'

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