web-fetch-mcp

web-fetch-mcp

A web-fetch MCP server for LLM agents that fetches pages with an escalation ladder through different engines, raising FetchBlocked instead of returning blocked content.

Category
访问服务器

README

web-fetch-mcp

PyPI Python CI License

A web-fetch MCP server for LLM agents that fails honestly — it raises FetchBlocked instead of silently handing your model a CAPTCHA or login page as if it were the article.

  • PyPI: https://pypi.org/project/web-fetch-mcp/
  • Source: https://github.com/Dutta-SD/web-fetch-mcp
  • Install: pip install web-fetch-mcp

Naive fetchers poison an agent's context: when a site returns a JavaScript interstitial or a login wall with HTTP 200, the agent reads the challenge page as if it were content and reasons from garbage. web-fetch-mcp detects that and either escalates to a stronger strategy or fails loudly.

Status: early / alpha. The escalation logic and helpers are unit-tested, but real-world bypass rates are not yet benchmarked — see assets/benchmarks.md and the roadmap in TODO.md.

How it works

A cheapest-first escalation ladder. Each tier targets a different layer of bot-detection, and the server only pays for the expensive ones when it has to:

Tier Engine Targets Speed
1 curl_cffi (Chrome TLS/HTTP2 fingerprint) TLS (JA3/JA4) + HTTP/2 fingerprinting ~500 ms
2 Patchright (real headful Chrome) JavaScript fingerprinting; renders SPAs ~1–3 s
3 nodriver (custom CDP) automation-protocol (CDP) detection ~2–4 s

Every tier's output is checked for hard blocks (403/429/503) and soft blocks (HTTP-200 challenge or login bodies served in place of content). Transient failures retry with exponential backoff + jitter (honoring Retry-After) before escalating. If everything is blocked, it raises FetchBlocked with a remedy hint — it never returns a block page as content.

Escalation path (mode="auto")

Escalation path: fetch(url) tries Tier 1 (curl_cffi static), escalating to
Tier 2 (Patchright headful Chrome) then Tier 3 (nodriver stealth) on a block or
empty SPA shell; the first tier to return usable content is rendered, otherwise
it raises FetchBlocked.

Each tier runs through with_retry (exponential backoff + jitter, honoring Retry-After) before the chain escalates. Tier 1 must clear the strict check (not blocked and not an unrendered SPA shell); Tiers 2–3 only need to be not-blocked. The single-tier modes (static/dynamic/stealth) run exactly one box and skip the chain.

Tools

  • fetch — retrieve a page as markdown / text / html / article (main-content extraction via trafilatura). Non-HTML URLs are auto-handled: JSON is pretty-printed, PDFs are text-extracted, images return a note to use screenshot.
  • screenshot — render a page in real Chrome and return a PNG.

Architecture

A layered package (src/web_fetch_mcp/), dependencies pointing inward:

controller  (FastMCP tools, lifespan)        controller/app.py
   -> service   (retry decorator, strategy registry, escalation, facade)
        -> accessor  (curl_cffi / Patchright / nodriver, BrowserManager)
             -> core   (models, config, detection, rendering, proxy, backoff)
  • Strategy — the three tiers are interchangeable async (request) -> FetchResult callables in a registry (service/strategies.py).
  • Chain of Responsibility (intent) — auto mode walks the tiers cheapest-first, escalating until one yields usable content (service/escalation.py).
  • Decoratorwith_retry adds exponential-backoff + Retry-After to any tier (service/retry.py), hand-rolled on the stdlib (no tenacity).
  • ManagerBrowserManager owns one reused Chromium and closes it on the FastMCP lifespan shutdown (accessor/browser.py).

Quickstart

uv sync
uv pip install -e .        # installs the `web-fetch-mcp` console command
web-fetch-mcp              # run the stdio MCP server

Register it with any MCP-compatible client as a stdio server that runs the web-fetch-mcp command (or python -m web_fetch_mcp.controller.app).

fetch("https://example.com/article", output="article")   # clean main content
fetch("https://api.site/data.json")                       # pretty-printed JSON
fetch("https://spa.example.com", mode="dynamic")          # force a JS render

Responsible use

This tool is for fetching content you are authorized to access. You are solely responsible for complying with each site's Terms of Service, robots.txt, and applicable law. It honors Retry-After and backs off by default; please rate-limit responsibly. It does not solve CAPTCHAs or bypass authentication you do not hold. Provided as-is, without warranty.

License

Apache-2.0.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选