Skip to main content
Glama
guanyuyan
by guanyuyan

web_fetch

Fetch web pages, PDFs, and text files, then return compact token-efficient main content while detecting anti-bot pages and handling JS-rendered sites.

Instructions

抓取网页并返回极省 token 的紧凑正文(自动辨别反爬拦截页并如实上报)。

支持 HTML 页面、PDF(需安装 mcp-scrape[pdf])与纯文本(.txt/.md); 后两者直接返回文本内容,不做 DOM 精简。

Args: url: 目标网页完整 URL,需带 http/https 协议头。 max_tokens: 正文 token 预算上限,超出时保留头尾、省略中段。 link_policy: 链接处理策略。internal=站内链接保留为相对路径、站外降级为纯文本(默认,最省); all=站内外链接全保留;none=全部降级为纯文本。 format: 输出格式。markdown=保留标题/列表/链接标记(默认); text=剥掉 markdown 标记的纯文本;json=按行切分的块数组(content 为字符串列表)。 headers: 自定义请求头,如 {"Referer": "...", "User-Agent": "..."};传入时不走共享缓存。 cookies: 自定义 cookie 字典;传入时不走共享缓存。 timeout: 单次请求超时秒数(默认取配置 request_timeout)。 deadline_ms: 整次调用的总预算(毫秒),不传表示不限。预算不够时逐级降级: 压缩单步超时 → 跳过重试(diagnostics 里是 deadline:skip_retry)→ 不升级 L2(deadline:skip_l2)→ 未开始就耗尽时直接返回 timeout。 预算内拿到的正文照常返回,但降级结果不会写入结果缓存。 wait_for: 仅 L2 生效,等待该 CSS 选择器出现后再取内容(适合 SPA);不传则套用站点 recipe。 scroll: 仅 L2 生效,滚动页面触发懒加载/无限滚动;不传则套用站点 recipe。 click: 仅 L2 生效,渲染后点击一次该 CSS 选择器(如"加载更多");不传则套用站点 recipe。 bypass_cache: 跳过并绕过响应缓存,强制走网络。 debug: 返回 diagnostics(分层决策、L2 交互命中情况、正文根与候选命中数), 只含计数与决策、不含页面内容;失败时默认也会带精简版决策轨迹。 session: 登录态会话名(默认 default);需与 login 时使用的会话名一致,多身份互不干扰。 proxy: 本次请求使用的代理(如 http://127.0.0.1:7890、socks5://127.0.0.1:1080), L1 与升级后的 L2 都走该出口;不传则按代理池 SCRAPE_MCP_PROXY_POOL 分配, 未配池时沿用 SCRAPE_MCP_PROXY。 显式传入代理的请求不读也不写共享缓存,避免把不同出口的结果混在一起。

Input Schema

NameRequiredDescriptionDefault
urlYes
clickNo
debugNo
proxyNo
formatNomarkdown
scrollNo
cookiesNo
headersNo
sessionNodefault
timeoutNo
wait_forNo
max_tokensNo
deadline_msNo
link_policyNointernal
bypass_cacheNo

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed12 schema fields changedv0.10.1
    • addedInput schema / properties / bypass_cache
      Added value: +{
      +  "default": false,
      +  "title": "Bypass Cache",
      +  "type": "boolean"
      +}
    • addedInput schema / properties / click
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "title": "Click"
      +}
    • addedInput schema / properties / cookies
      Added value: +{
      +  "anyOf": [
      +    {
      +      "additionalProperties": {
      +        "type": "string"
      +      },
      +      "type": "object"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "title": "Cookies"
      +}
    • addedInput schema / properties / deadline_ms
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "integer"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "title": "Deadline Ms"
      +}
    • addedInput schema / properties / debug
      Added value: +{
      +  "default": false,
      +  "title": "Debug",
      +  "type": "boolean"
      +}
    • addedInput schema / properties / format
      Added value: +{
      +  "default": "markdown",
      +  "title": "Format",
      +  "type": "string"
      +}
    • addedInput schema / properties / headers
      Added value: +{
      +  "anyOf": [
      +    {
      +      "additionalProperties": {
      +        "type": "string"
      +      },
      +      "type": "object"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "title": "Headers"
      +}
    • addedInput schema / properties / proxy
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "title": "Proxy"
      +}
    • addedInput schema / properties / scroll
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "boolean"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "title": "Scroll"
      +}
    • addedInput schema / properties / session
      Added value: +{
      +  "default": "default",
      +  "title": "Session",
      +  "type": "string"
      +}
    • addedInput schema / properties / timeout
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "number"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "title": "Timeout"
      +}
    • addedInput schema / properties / wait_for
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "title": "Wait For"
      +}
  2. First observedv0.1.0

TDQS

A4.2/5.0
Behavior5/5

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

With no annotations, the description carries the full burden and does: it discloses the deadline degradation ladder (skip retry, skip L2, immediate timeout), that degraded results are not written to cache, that headers/cookies/proxy requests bypass and do not populate the shared cache, and that debug returns counts and decisions but no page content. It also notes failures still return a trimmed decision trace.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Purpose and the anti-bot caveat are front-loaded in one sentence, then a clean per-argument list. Dense but proportionate to 15 parameters; a few entries (proxy pool env vars) could be trimmed without losing callable information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

An output schema exists, so return values need not be explained, and the description still covers caching, degradation, sessions and proxies. The one real omission is sibling differentiation and the default rendering tier (what plain web_fetch does without wait_for/scroll/click).

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate, and it documents all 15 parameters: enumerated values for link_policy (internal/all/none) and format (markdown/text/json), what bypass_cache and debug do, proxy format examples, and the L2-only restriction on wait_for/scroll/click with recipe fallback. This is materially richer than the bare schema.

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?

A specific verb and resource (fetch a web page, return token-compact body) plus notable extras: anti-bot page detection reported faithfully, support for HTML/PDF/plain text. It never names the sibling fetchers (web_crawl, web_extract, web_batch), so an agent cannot distinguish which of the four to pick from the description alone.

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?

Usage is implied rather than stated: wait_for is flagged as suitable for SPAs, session must match the name used at login, and L2 gating is mentioned. There is no explicit when-to-use / when-not guidance and no routing to web_crawl or web_extract, which matters given three closely related siblings.

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