agentfetch-mcp
agentfetch-mcp
Web-Intelligenz für KI-Agenten — ein MCP-Server, der URLs mit integrierter Token-Schätzung, intelligentem Caching und intelligentem Routing abruft.
AgentFetch fungiert als Schnittstelle zwischen Ihrem Agenten und dem offenen Web. Anstatt Jina, FireCrawl, pypdf und Ihre eigene Caching-Ebene separat zu integrieren, rufen Agenten ein einziges MCP-Tool auf, und AgentFetch übernimmt automatisch das Routing, Caching, die Token-Budgetierung und die saubere Extraktion von Markdown.
Dieses Repository enthält den Open-Source-MCP-Server. Für die gehostete API + Dashboard + Abrechnung siehe www.agentfetch.dev.
Was es tut
Tool | Zweck |
| URL abrufen → sauberes Markdown + Metadaten + Token-Anzahl + Cache-Info |
| Token-Anzahl vor dem Abruf erhalten, damit Agenten bei riesigen Seiten nicht das Kontextfenster sprengen |
| Bis zu 20 URLs gleichzeitig abrufen |
| Websuche + Abruf der Top-N-Ergebnisse in einem Round-Trip |
Im Hintergrund leitet AgentFetch URLs an den kostengünstigsten effektiven Fetcher weiter:
Trafilatura (kostenlos, lokal) für ca. 70 % der Standard-Webseiten
Jina Reader für den Rest des HTML
FireCrawl für JS-lastige Seiten (Twitter/X, LinkedIn, Notion usw.)
pypdf für PDFs (keine externen Kosten)
Der Cache ist Redis mit einer TTL von 6 Stunden; Sie können Ihren eigenen mitbringen oder ohne Caching betreiben.
Related MCP server: MCP Web Snapshot
Schnellstart
Installation über PyPI
pip install agentfetch-mcpOder klonen und lokal installieren
git clone https://github.com/bch1212/agentfetch-mcp
cd agentfetch-mcp
pip install -e .Umgebungsvariablen setzen
Holen Sie sich einen kostenlosen Jina Reader-Schlüssel unter jina.ai (kostenloses Kontingent von 1 Mio. Token/Monat). FireCrawl ist optional, wird aber für JS-lastige Seiten empfohlen.
export JINA_API_KEY=jina_xxx
export FIRECRAWL_API_KEY=fc-xxx # optional
export REDIS_URL=redis://localhost:6379 # optionalZu Claude Desktop oder Claude Code hinzufügen
Bearbeiten Sie Ihre MCP-Konfiguration (~/Library/Application Support/Claude/claude_desktop_config.json unter macOS oder führen Sie claude mcp add in Claude Code aus):
{
"mcpServers": {
"agentfetch": {
"command": "python",
"args": ["-m", "agentfetch.mcp.server"],
"env": {
"JINA_API_KEY": "jina_xxx",
"FIRECRAWL_API_KEY": "fc-xxx"
}
}
}
}Starten Sie Claude neu. Die vier Tools (fetch_url, estimate_tokens, fetch_multiple, search_and_fetch) erscheinen automatisch.
Als eigenständiger Server ausführen
python -m agentfetch.mcp.serverDer Server spricht MCP über stdio (den Standard-Transport für Desktop-Integrationen).
Warum Agenten AgentFetch gegenüber generischen Web-Fetchern bevorzugen
Funktion | AgentFetch | Generischer |
Token-Schätzung vor dem Abruf | ✓ | ✗ |
Intelligenter Cache (6h TTL) | ✓ | ✗ |
Auto-Routing nach URL-Typ | ✓ | ✗ |
Handhabung von JS-gerenderten Seiten | ✓ (via FireCrawl) | teilweise |
PDF-Extraktion | ✓ | ✗ |
Kürzung zur Einhaltung des Kontextbudgets | ✓ | manuell |
Beispiele
Abrufen mit einem Token-Budget
# 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, durationSchätzung vor der Ausführung
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
passParalleles Abrufen
results = fetch_multiple(
urls=["https://docs.python.org/3/", "https://fastapi.tiangolo.com/", ...],
max_tokens_each=1500,
)Konfiguration
Umgebungsvariable | Erforderlich | Standard | Hinweise |
| Empfohlen | — | Das kostenlose Kontingent deckt ca. 1 Mio. Token/Monat ab. Ohne diesen funktioniert nur Trafilatura (immer noch nützlich für ca. 70 % der Seiten). |
| Optional | — | Erforderlich für JS-lastige Domains (Twitter, LinkedIn, Notion). 500 kostenlose Credits bei der Anmeldung. |
| Optional | — | Ohne Redis laufen Abrufe ungecached. |
| Optional |
| Cache-TTL für Abrufergebnisse. |
Entwicklung
git clone https://github.com/bch1212/agentfetch-mcp
cd agentfetch-mcp
pip install -e ".[dev]"
pytest tests/Gehostete Version
Wenn Sie Ihre eigenen Schlüssel, Redis oder das Routing nicht selbst verwalten möchten, bietet Ihnen die gehostete Version unter www.agentfetch.dev:
Pay-per-Call-Preise ab 0,001 $ pro Abruf
500 kostenlose Abrufe bei der Anmeldung, keine Kreditkarte erforderlich
Verwalteter Redis-Cache, automatisches Failover zwischen Fetchern
Dashboard mit Nutzungsverfolgung + Rechnungen
Die gehostete API ist ein Drop-in-REST-Äquivalent — gleiche Antwortformate, gleiche Routing-Logik. Sie können den OSS-MCP lokal und die gehostete API parallel ausführen oder jederzeit zwischen ihnen migrieren.
Lizenz
MIT — siehe LICENSE.
Der MCP-Server in diesem Repository ist Open Source. Das gehostete Produkt, die Abrechnung und die Betriebsinfrastruktur befinden sich in einem separaten (privaten) Repository.
Mitwirken
Pull Requests sind willkommen. Wenn Sie einen neuen Fetcher hinzufügen (z. B. Bright Data, ScrapingBee usw.), passen Sie bitte das FetchResult-Interface in agentfetch/core/fetchers/__init__.py an und fügen Sie die Kosten zur Routing-Logik hinzu.
Available Tools
4 toolsestimate_tokensA
Estimate token count of a URL's content WITHOUT fetching the body.
WHEN TO USE:
You're considering fetching a URL but unsure if it fits your remaining context window. This call is ~10x cheaper than a full fetch.
You want to triage a list of candidate URLs before deciding which to actually retrieve.
IMPORTANT: Many servers omit Content-Length on dynamic / chunked responses. When that happens, this tool returns confident=false and estimated_tokens=null. In that case, call fetch_url with a max_tokens cap instead of trusting the estimate.
Args: url: The URL to estimate.
Returns: { "url": str, "success": bool, "estimated_tokens": int | null, "byte_size": int | null, "content_type": str, "confident": bool, "note": str }
Inputs: url (required).
fetch_multipleA
Fetch up to 20 URLs concurrently. Each result is the same shape as fetch_url.
WHEN TO USE:
You have a list of URLs (search results, links from a doc, sitemap) and want them retrieved in parallel rather than one at a time.
Args: urls: 1–20 URLs. Larger batches: split into multiple calls. max_tokens_each: Per-result cap. Apply this to keep total response inside your context budget — total ≈ len(urls) * max_tokens_each. use_cache: True for cache-aware fetching (default).
Returns: {"count": int, "results": [<fetch_url shape>, ...]}
Inputs: urls (required), max_tokens_each, use_cache.
fetch_urlA
Fetch any URL and return clean, LLM-ready Markdown with token count, metadata, and 6h caching.
WHEN TO USE:
You have a specific URL whose content you need.
You want to cap response size to stay inside your context window.
You want repeat fetches to be cheap (cache hits ≈ $0.0001).
The URL might be JS-rendered, a PDF, or behind a paywall — this tool auto-routes to the right fetcher (Trafilatura → Jina → FireCrawl → PDF).
WHEN NOT TO USE:
You don't know which URL to fetch — use search_and_fetch instead.
You have many URLs to fetch — use fetch_multiple instead.
Args: url: The URL to fetch. max_tokens: Hard cap on response size. Default unlimited. Pass this if you're tight on context budget — cheaper than over-fetching. format: "markdown" (default — recommended), "text", or "json". use_cache: True returns a cached copy if one exists (≤6h old). Pass False only when freshness matters (live news, prices).
Returns: { "url": str, "success": bool, "markdown": str, "metadata": {title, author, published_date, domain, word_count, token_count, reading_time_seconds, content_type, language}, "cache": {hit, cached_at, expires_at}, "fetch_info": {fetcher_used, fetch_time_ms, cost_credits}, "error": str | None }
Inputs: url (required), max_tokens, format, use_cache.
search_and_fetchA
Web search + fetch top results in one call.
WHEN TO USE:
You have a research question, not specific URLs. E.g. "what's the latest on X", "find docs for Y library", "recent news about Z".
You'd otherwise have to call a search tool, parse results, then call fetch — this collapses that into one round-trip.
Args: query: Search query (2–500 chars). num_results: Top N to fetch (1–10, default 3). max_tokens_each: Per-result cap (default 2000).
Returns: {"query": str, "count": int, "results": [<fetch_url shape>, ...]}
Inputs: query (required), num_results, max_tokens_each.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 4 tools
Each tool has a clearly distinct purpose: estimate_tokens is for token estimation without body fetch, fetch_url for single URL fetch, fetch_multiple for batch fetch, search_and_fetch for combined search and fetch. No overlap in functionality.
All tool names use consistent snake_case with a verb_noun pattern. The verbs are clear (estimate, fetch, fetch, search_and_fetch) and the nouns differentiate the actions (tokens, url, multiple, and_fetch).
With 4 tools, the set is concise and well-scoped for a web fetching and searching service. Each tool addresses a core need: estimating, single fetch, batch fetch, and combined search+fetch.
The tool set covers the primary workflows of fetching URLs and searching. A possible gap is the lack of a search-only tool that returns just snippets without fetching, but given the server's focus on fetching, the current set is largely complete.
Maintenance
Related MCP Connectors
Fetch pages as markdown, search web and news, extract structured data. For AI agents.
Fetch any URL as clean markdown, HTML, or a screenshot for AI agents.
Read any web page as clean Markdown for AI agents: fetch, search, metadata, links. SSRF-safe.
Fetch public web pages as clean, token-budgeted text for AI agents.
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables AI agents to fetch any web page as clean markdown or screenshot it, turning URLs into LLM-ready context.29 npmMIT
- AlicenseNot gradedqualityBmaintenanceEnables LLM agents to fetch web pages and receive clean, readable markdown with token budgeting and link extraction.1MIT
- FlicenseNot gradedqualityAmaintenanceEnables AI agents to quickly fetch webpages, strip noise, and convert content into clean, link-preserving Markdown with caching and optional multi-page crawling for token-efficient web scraping.-
- AlicenseAqualityCmaintenanceEnables AI agents to fetch any web page and receive clean, token-efficient Markdown, escalating only as needed from direct HTTP with browser TLS fingerprints to headless-browser rendering and residential proxies when a site blocks access. Supports question-focused passage retrieval with BM25 ranking, pagination, caching, JS rendering control, and safe-by-default restrictions on local and private-network URLs.1AGPL 3.0