agentfetch-mcp
AgentFetch-MCP is a web intelligence server for AI agents, providing URL fetching, token estimation, and web search with smart routing, caching, and clean Markdown extraction.
fetch_url: Fetch any URL and receive clean, LLM-ready Markdown (or text/JSON) with rich metadata (title, author, published date, language, word count, token count, cache info). Supportsmax_tokenscaps and cache control. Handles standard pages, JS-rendered sites, and PDFs.estimate_tokens: Estimate the token count of a URL's content without fetching the full body — useful for triaging URLs and avoiding context window overflow before committing to a full fetch.fetch_multiple: Fetch up to 20 URLs concurrently in a single call, each with the same rich result shape as a single fetch and per-resultmax_tokens_eachcaps.search_and_fetch: Run a web search and automatically fetch the top N results (default 3, up to 10) in one round-trip — ideal for research questions without known URLs, withmax_tokens_eachsupport.Intelligent auto-routing: Automatically selects the best fetcher based on URL type — Trafilatura (free/local), Jina Reader, FireCrawl (JS-heavy sites like Twitter, LinkedIn, Notion), or pypdf for PDFs.
Smart caching: Redis-backed caching with a configurable 6-hour TTL makes repeated fetches fast and cheap.
Token budget management: Enforce
max_tokenslimits on any fetch to keep responses within context windows.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@agentfetch-mcpfetch https://en.wikipedia.org/wiki/Artificial_intelligence with token limit 2000"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
agentfetch-mcp
Web intelligence for AI agents — an MCP server that fetches URLs with token estimation, smart caching, and intelligent routing built in.
AgentFetch sits between your agent and the open web. Instead of integrating Jina, FireCrawl, pypdf, and your own caching layer separately, agents call one MCP tool and AgentFetch handles routing, caching, token budgeting, and clean Markdown extraction automatically.
This repository contains the open-source MCP server. For the hosted API + dashboard + billing, see www.agentfetch.dev.
What it does
Tool | What it's for |
| Fetch a URL → clean Markdown + metadata + token count + cache info |
| Get a token count before fetching, so agents don't blow context windows on huge pages |
| Fetch up to 20 URLs concurrently |
| Web search + fetch top N results in one round-trip |
Under the hood, AgentFetch routes URLs to the cheapest effective fetcher:
Trafilatura (free, local) for ~70% of standard web pages
Jina Reader for the rest of HTML
FireCrawl for JS-heavy pages (Twitter/X, LinkedIn, Notion, etc.)
pypdf for PDFs (zero external cost)
Cache is Redis with a 6-hour TTL; you can bring your own or run without caching.
Related MCP server: Fetch MCP Server
Quick start
Install from PyPI
pip install agentfetch-mcpOr clone and install locally
git clone https://github.com/bch1212/agentfetch-mcp
cd agentfetch-mcp
pip install -e .Set environment variables
Get a free Jina Reader key at jina.ai (1M tokens/mo free tier). FireCrawl is optional but recommended for JS-heavy pages.
export JINA_API_KEY=jina_xxx
export FIRECRAWL_API_KEY=fc-xxx # optional
export REDIS_URL=redis://localhost:6379 # optionalAdd to Claude Desktop or Claude Code
Edit your MCP config (~/Library/Application Support/Claude/claude_desktop_config.json on macOS, or run claude mcp add in Claude Code):
{
"mcpServers": {
"agentfetch": {
"command": "python",
"args": ["-m", "agentfetch.mcp.server"],
"env": {
"JINA_API_KEY": "jina_xxx",
"FIRECRAWL_API_KEY": "fc-xxx"
}
}
}
}Restart Claude. The four tools (fetch_url, estimate_tokens, fetch_multiple, search_and_fetch) appear automatically.
Run as a standalone server
python -m agentfetch.mcp.serverThe server speaks MCP over stdio (the standard transport for desktop integrations).
Why agents prefer AgentFetch over generic web fetch
Feature | AgentFetch | Generic |
Token estimation before fetching | ✓ | ✗ |
Smart cache (6h TTL) | ✓ | ✗ |
Auto-routing by URL type | ✓ | ✗ |
JS-rendered page handling | ✓ (via FireCrawl) | partial |
PDF extraction | ✓ | ✗ |
Truncation to fit context budget | ✓ | manual |
Examples
Fetching with a 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, durationEstimating before committing
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
passParallel fetching
results = fetch_multiple(
urls=["https://docs.python.org/3/", "https://fastapi.tiangolo.com/", ...],
max_tokens_each=1500,
)Configuration
Env var | Required | Default | Notes |
| Recommended | — | Free tier covers ~1M tokens/mo. Without it, only Trafilatura works (still useful for ~70% of pages). |
| Optional | — | Needed for JS-heavy domains (Twitter, LinkedIn, Notion). 500 free credits on signup. |
| Optional | — | Without Redis, fetches run uncached. |
| Optional |
| Cache TTL for fetch results. |
Development
git clone https://github.com/bch1212/agentfetch-mcp
cd agentfetch-mcp
pip install -e ".[dev]"
pytest tests/Hosted version
If you'd rather not manage your own keys, Redis, or the routing yourself, the hosted version at www.agentfetch.dev gives you:
Pay-per-call pricing from $0.001/fetch
500 free fetches on signup, no credit card
Managed Redis cache, automatic failover between fetchers
Dashboard with usage tracking + invoices
The hosted API is a drop-in REST equivalent — same response shapes, same routing logic. You can run the OSS MCP locally and the hosted API in parallel, or migrate between them at any time.
License
MIT — see LICENSE.
The MCP server in this repo is open source. The hosted product, billing, and ops infrastructure live in a separate (private) repo.
Contributing
PRs welcome. If you're adding a new fetcher (e.g., Bright Data, ScrapingBee, etc.), please match the FetchResult interface in agentfetch/core/fetchers/__init__.py and add the cost to the routing logic.
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 }
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations exist, but the description fully discloses behavior: no body fetch, 10x cheaper, fallback when Content-Length missing, and return structure with confident flag.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Well-structured with sections, but includes a full return example that is slightly verbose yet informative.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a one-parameter tool, the description covers purpose, usage, fallback, and return format completely, compensating for lack of output schema.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema has 0% coverage, but the description includes an 'Args' section explaining the url parameter, adding meaning beyond the schema.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool estimates token count without fetching the body, and distinguishes from sibling tools like fetch_url by emphasizing it does not fetch the body.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Explicitly provides when-to-use (unsure about context window, triaging URLs) and when-not-to-use (if confident=false, use fetch_url with max_tokens).
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
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": [, ...]}
| Name | Required | Description | Default |
|---|---|---|---|
| urls | Yes | ||
| max_tokens_each | No | ||
| use_cache | No |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Describes concurrency and per-result token cap, but no annotations present. Lacks details on error handling, rate limits, or caching behavior beyond defaults.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Well-structured into purpose, when-to-use, args, and returns. No redundant sentences, every line contributes.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Covers purpose, usage, parameters, return shape, and concurrency limit. Could include error behavior or more details on caching, but overall sufficient for a fetch tool.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Provides clear explanations for all three parameters: url limit and splitting, max_tokens_each token budget guidance, and use_cache caching behavior. Adds significant value over schema-only info.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
Clearly states 'Fetch up to 20 URLs concurrently' with a specific verb and resource. Distinguishes from sibling tools by highlighting concurrency and batch limit.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Includes 'WHEN TO USE' section explicitly describing scenarios. Mentions splitting large batches but does not explicitly state when not to use or name alternatives like fetch_url.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
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 }
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | ||
| max_tokens | No | ||
| format | No | markdown | |
| use_cache | No |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations exist, so the description fully bears the transparency burden. It discloses caching (6h), auto-routing to multiple fetchers, cost estimates, and return structure including error handling. This far exceeds minimal requirements.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is well-structured with sections, bullet points, and a return format sample. While fairly long, every sentence adds value—usage guidance, parameter details, and return schema. Minor conciseness loss from repetition of 'WHEN TO USE' structure.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Despite no output schema and no annotations, the description compensates fully: explains return structure in detail, caching behavior, fetcher selection logic, cost implications, and context window management (max_tokens). An agent has everything needed to invoke correctly.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, so the description must add context for all parameters. It explains url (implicit), max_tokens (hard cap, default unlimited, context budget advice), format (default markdown, recommended), and use_cache (default true, when to pass false). Each parameter gets meaningful guidance beyond the schema.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description opens with 'Fetch any URL and return clean, LLM-ready Markdown' clearly stating the verb+resource+output quality. It explicitly distinguishes from siblings 'search_and_fetch' and 'fetch_multiple' in the WHEN NOT TO USE section.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The WHEN TO USE and WHEN NOT TO USE sections provide explicit scenarios (e.g., specific URL, JS-rendered, PDF, paywall) and name alternative tools. This gives clear guidance on when to invoke this tool versus its siblings.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
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": [, ...]}
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | ||
| num_results | No | ||
| max_tokens_each | No |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description effectively discloses the combined search-and-fetch behavior and the return format. However, it lacks details on error handling or failure scenarios for individual result fetches.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is well-structured with a header and 'WHEN TO USE' section, making it easy to parse. It is concise yet informative, though the parameter descriptions could be integrated more succinctly.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
The description adequately covers the tool's purpose, usage, parameters, and return format. Given no output schema, the return shape is documented. Missing details on partial failures or edge cases, but overall sufficient for this combined tool.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Despite zero schema coverage, the description fully compensates by specifying constraints (query 2-500 chars, num_results 1-10, max_tokens_each default 2000) and explaining each parameter's role, adding substantial meaning beyond the schema.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states 'Web search + fetch top results in one call,' which precisely defines the tool's combined action. It distinguishes itself from siblings like fetch_url and fetch_multiple by highlighting the aggregation of search and fetch into one step.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description includes a 'WHEN TO USE' section that explicitly recommends the tool for research questions rather than specific URLs. It contrasts with the alternative of using separate search and fetch tools, providing clear guidance on when to prefer this tool.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
4 tool updates
v1.0.0- First observed
estimate_tokens - First observed
fetch_multiple - First observed
fetch_url - First observed
search_and_fetch
TDQS
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
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Fetch pages as markdown, search web and news, extract structured data. For AI agents.
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 search, fetch, extract, and research for AI agents. Markdown output + AI-synthesized answers.
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.1534161MIT
- 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
- AlicenseAqualityDmaintenanceEnables 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.116ISC
- AlicenseNot gradedqualityDmaintenanceProvides AI agents with reliable web fetching capabilities, handling retries, caching, and anti-bot bypass automatically.MIT
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