agentfetch-mcp
agentfetch-mcp
为 AI 智能体提供网络智能 — 一个内置了 URL 获取、令牌估算、智能缓存和智能路由功能的 MCP 服务器。
AgentFetch 位于您的智能体与开放网络之间。智能体无需分别集成 Jina、FireCrawl、pypdf 和您自己的缓存层,只需调用一个 MCP 工具,AgentFetch 即可自动处理路由、缓存、令牌预算和整洁的 Markdown 提取。
本仓库包含开源的 MCP 服务器。如需托管 API + 仪表板 + 计费功能,请访问 www.agentfetch.dev。
功能说明
工具 | 用途 |
| 获取 URL → 整洁的 Markdown + 元数据 + 令牌计数 + 缓存信息 |
| 在获取 之前 获取令牌计数,防止智能体因页面过大而耗尽上下文窗口 |
| 并发获取最多 20 个 URL |
| 网络搜索 + 在一次往返中获取前 N 个结果 |
在底层,AgentFetch 会将 URL 路由到性价比最高的有效抓取工具:
Trafilatura(免费,本地)用于约 70% 的标准网页
Jina Reader 用于其余的 HTML 页面
FireCrawl 用于 JS 密集型页面(Twitter/X、LinkedIn、Notion 等)
pypdf 用于 PDF(零外部成本)
缓存使用 Redis,TTL 为 6 小时;您可以自带 Redis 或在无缓存模式下运行。
Related MCP server: Fetch MCP Server
快速开始
从 PyPI 安装
pip install agentfetch-mcp或克隆并本地安装
git clone https://github.com/bch1212/agentfetch-mcp
cd agentfetch-mcp
pip install -e .设置环境变量
在 jina.ai 获取免费的 Jina Reader 密钥(免费层级每月 100 万令牌)。FireCrawl 是可选的,但建议用于 JS 密集型页面。
export JINA_API_KEY=jina_xxx
export FIRECRAWL_API_KEY=fc-xxx # optional
export REDIS_URL=redis://localhost:6379 # optional添加到 Claude Desktop 或 Claude Code
编辑您的 MCP 配置(macOS 上为 ~/Library/Application Support/Claude/claude_desktop_config.json,或在 Claude Code 中运行 claude mcp add):
{
"mcpServers": {
"agentfetch": {
"command": "python",
"args": ["-m", "agentfetch.mcp.server"],
"env": {
"JINA_API_KEY": "jina_xxx",
"FIRECRAWL_API_KEY": "fc-xxx"
}
}
}
}重启 Claude。四个工具(fetch_url、estimate_tokens、fetch_multiple、search_and_fetch)将自动出现。
作为独立服务器运行
python -m agentfetch.mcp.server该服务器通过 stdio(桌面集成的标准传输方式)进行 MCP 通信。
为什么智能体更喜欢 AgentFetch 而非通用的 web_fetch
特性 | AgentFetch | 通用 |
获取前令牌估算 | ✓ | ✗ |
智能缓存 (6h TTL) | ✓ | ✗ |
按 URL 类型自动路由 | ✓ | ✗ |
JS 渲染页面处理 | ✓ (通过 FireCrawl) | 部分 |
PDF 提取 | ✓ | ✗ |
截断以适应上下文预算 | ✓ | 手动 |
示例
在令牌预算内获取
# Inside any MCP-aware agent (Claude Desktop, Claude Code, etc.)
result = fetch_url(
url="https://news.ycombinator.com",
max_tokens=2000, # cap response size
use_cache=True, # serve from cache if <6h old
)
# result.markdown → clean Markdown, ≤2000 tokens
# result.metadata → title, author, word_count, language
# result.cache.hit → True if served from cache
# result.fetch_info → which fetcher ran, cost, duration在提交前进行估算
estimate = estimate_tokens(url="https://very-long-article.com")
if estimate.estimated_tokens and estimate.estimated_tokens < 5000:
result = fetch_url(url="https://very-long-article.com")
else:
# too big — skip or summarize via search_and_fetch with max_tokens_each
pass并行获取
results = fetch_multiple(
urls=["https://docs.python.org/3/", "https://fastapi.tiangolo.com/", ...],
max_tokens_each=1500,
)配置
环境变量 | 必需 | 默认值 | 说明 |
| 推荐 | — | 免费层级每月涵盖约 100 万令牌。没有它,仅 Trafilatura 可用(仍适用于约 70% 的页面)。 |
| 可选 | — | JS 密集型域名(Twitter、LinkedIn、Notion)所需。注册即送 500 免费额度。 |
| 可选 | — | 若无 Redis,获取操作将不缓存。 |
| 可选 |
| 获取结果的缓存 TTL。 |
开发
git clone https://github.com/bch1212/agentfetch-mcp
cd agentfetch-mcp
pip install -e ".[dev]"
pytest tests/托管版本
如果您不想自己管理密钥、Redis 或路由,托管版本 www.agentfetch.dev 为您提供:
按调用付费,单次获取低至 $0.001
注册即送 500 次免费获取,无需信用卡
托管的 Redis 缓存,抓取工具间自动故障转移
带有使用情况跟踪和发票的仪表板
托管 API 是即插即用的 REST 等效服务 — 相同的响应格式,相同的路由逻辑。您可以本地运行 OSS MCP 并并行使用托管 API,或随时在两者之间迁移。
许可证
MIT — 参见 LICENSE。
本仓库中的 MCP 服务器是开源的。托管产品、计费和运维基础设施位于单独的(私有)仓库中。
贡献
欢迎提交 PR。如果您要添加新的抓取工具(例如 Bright Data、ScrapingBee 等),请匹配 agentfetch/core/fetchers/__init__.py 中的 FetchResult 接口,并将成本添加到路由逻辑中。
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseAqualityBmaintenanceFast, token-efficient web content extraction tool that converts websites to clean Markdown for AI agents, featuring smart caching, content extraction with Mozilla Readability, and polite crawling capabilities.11,299158MIT
- AlicenseBqualityDmaintenanceEnables LLMs to retrieve and process web content by fetching URLs and converting HTML to markdown format. Supports chunked reading of large pages and can access both public websites and local networks.1MIT
- AlicenseCqualityDmaintenanceEnables LLMs to retrieve and process web content by fetching URLs and converting HTML to markdown, with support for chunked reading and customizable user-agents.1MIT
- Alicense-qualityCmaintenanceEnables AI agents to fetch and render web pages (including JavaScript-heavy SPAs) with headless Chromium, extract readable content with Mozilla Readability, capture navigation links, download images, and return a clean markdown file path.12ISC
Related MCP Connectors
Read any web page as clean Markdown for AI agents: fetch, search, metadata, links. SSRF-safe.
Fetch any URL and get clean Markdown. Web scraping for AI agents.
Web scraping for AI agents. Converts URLs to clean, LLM-ready Markdown with anti-bot bypass.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/bch1212/agentfetch-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server