Use case · Coding agents
Ground coding agents in current docs and real code
ContextFetch searches docs, Stack Overflow, GitHub and the open web, then hands your agent each page as Markdown, pruned to the part that answers its question.
Add a timeout to the async API calls in worker.py
{ "query": "python asyncio timeout", "numResults": 5 }
The asyncio Timeout Trap: Why wait_for() Doesn't Stop Tasks Instantly and How to Fix It
runebook.dev/en/docs/python/library/asyncio-task/timeouts
GitHub - aio-libs-abandoned/async-timeout: asyncio-compatible timeout class · GitHub
github.com/aio-libs-abandoned/async-timeout
async def main_problem(): try: # Timeout is 1 second await asyncio.wait_for(long_running_operation(), timeout=1.0) except asyncio.TimeoutError: print("Timeout occurred! ") # The task might still be running for a while!
Recall
Search where code answers live
Each query goes to every source at once: web metasearch, Hacker News, Wikipedia and our own index. When the question looks technical, Stack Overflow and GitHub search join in.
The candidates are fused into one list, the best pages are fetched, and a cross-encoder ranks what is left.
- searxng217
- stackoverflow10
- github10
- hn7
- local5
- wikipedia0
From the response's contextfetch.sources field, recorded 17 Oct 2026.
Pruned context
Give agents the passage, not the page
A cross-encoder scores every chunk of every page against the query and keeps the ones that answer it. Your agent reads less, and you pay for fewer input tokens.
The Reader does the same for one URL: append ?q= and it returns the page as pruned Markdown, with the savings in its headers.
$ curl -si "…/r/https://docs.python.org/3/library/asyncio-task.html?q=timeouts"
HTTP/2 200
content-type: text/markdown; charset=utf-8
x-raw-tokens: 11188
x-output-tokens: 173
x-token-savings: 98.5
x-credits-remaining: 13
↓ 98.5% tokens · 11,188 → 173
MCP
Search current docs from your coding tools
One line adds the ContextFetch MCP server to Claude Code. Cursor, Windsurf and any other MCP client take the same npx command. No key for the first 25 calls a day.
$ claude mcp add contextfetch -- npx -y @contextfetch/mcp
6 tools:
- ✓ contextfetch_search
- ✓ contextfetch_extract_url
- ✓ contextfetch_find_similar
- ✓ contextfetch_deep_research
- ✓ contextfetch_balance
- ✓ contextfetch_auto_reload
How it works
One call from question to context
What happened inside the recorded "python asyncio timeout" search, from the response's own timings. Stages overlap, so they add up to more than the total.
- 01
Recall
All sources are queried in parallel and fused with weighted rank fusion.
1,233 ms
- 02
Fetch
The best candidates are fetched in parallel and converted to Markdown, tables kept.
1,093 ms
- 03
Rerank and prune
One batched cross-encoder call ranks pages and picks highlights and pruned chunks.
1,018 ms
- 04
Repeat from cache
The same query within 15 minutes is answered from cache. It is still billed as one search.
153 ms p50, production
Code
Keep your Exa client, change the base URL
exa_py and exa-js work against ContextFetch after one argument changes. Or call the HTTP API directly, with no key for the first calls.
- Filter to docs and repos with includeDomains
- Ask for highlights or pruned context per result
- Up to 25 results per search, one credit
# pip install exa-pyfrom exa_py import Exa exa = Exa(api_key="YOUR_API_KEY", base_url="https://api.contextfetch.dev") res = exa.search( "python asyncio timeout", num_results=5, include_domains=["docs.python.org", "stackoverflow.com", "github.com"], contents={"highlights": True},)for r in res.results: print(r.url, r.highlights[0][:200])# Search, with page Markdown pruned to the query (no key needed)curl -s https://api.contextfetch.dev/v1/search \ -H "Content-Type: application/json" \ -d '{"query":"python asyncio timeout","numResults":5, "contents":{"pruned_context":true}}' # One docs page as Markdown, pruned to a questioncurl -si "https://api.contextfetch.dev/r/https://docs.python.org/3/library/asyncio-task.html?q=timeouts"# Claude Code: keyless, zero signupclaude mcp add contextfetch -- npx -y @contextfetch/mcp # Optional paid keyclaude mcp add contextfetch -e CONTEXTFETCH_API_KEY=YOUR_API_KEY -- npx -y @contextfetch/mcp # Claude Desktop / Cursor (mcpServers JSON){ "contextfetch": { "command": "npx", "args": ["-y", "@contextfetch/mcp"] } }Pricing
ContextFetch Search
$1.00per 1,000 searches
Markdown, highlights and pruned context are in the same credit. 25 searches a day are free with no key. One-time payment. Credits never expire. Full Markdown and pruning included.
Common questions
Which sources does ContextFetch search for code questions?
Every search queries its sources in parallel under a time budget: a SearXNG metasearch instance, Wikipedia, Hacker News and our own index of pages found by earlier searches. Stack Overflow and GitHub search join when the query looks technical, and arXiv when it looks academic. The best candidates are fetched, converted to Markdown and reranked by a cross-encoder.
How does ContextFetch reduce token cost for coding agents?
Ask for pruned_context and each result carries only the chunks that score against your query, in their original order. In the recorded "python asyncio timeout" search on this page that was 5,322 → 2,305 tokens; the Reader call on one Python docs page went from 11,188 to 173 tokens. Across our benchmark: on average 69% fewer tokens than the full page (median 79%) in a benchmark on 29 synthetic docs; not yet measured on live pages.
How fast is it inside an agent loop?
On the production API, called from a client in Florida, a cold search with 10 results and page text had a p50 of 3,141 ms over 5 queries, and the same query repeated within the 15-minute cache window 153 ms, network included. The method and raw JSON are on the benchmarks page.
How do I add ContextFetch to Claude Code, Cursor or Windsurf?
Run claude mcp add contextfetch -- npx -y @contextfetch/mcp for Claude Code, or add the same npx command to the mcpServers config of any MCP client. It works with no key for 25 calls a day; set CONTEXTFETCH_API_KEY to use paid credits.
Is result quality measured against other search APIs?
Not yet. ContextFetch publishes only what it measured: its own latency, token pruning on a synthetic corpus, and competitors' list prices. Our benchmark script compares providers only when you run it with your own API keys.
How much does ContextFetch cost for coding agents?
$1.00 per 1,000 searches on the $15 pack, less on bigger packs, with up to 25 results, Markdown, highlights and pruned context in the same credit. Credits are a one-time purchase and never expire.
Read more
Turn every docs page into context your agent can use
Start with no key: 25 free searches a day.