Context7 vs Web Search — Token & Speed Test
Four day-to-day doc lookups (2× SvelteKit, 2× Effect) run through Context7 MCP and a comparable web-search workflow, measured with tiktoken.
Context7 consumed ~40% more tokens than the web workflow (6,375 vs 4,568 across 4 queries) but was ~34% faster (~23s vs ~35s per query) and returned denser, code-first content. About a quarter of Context7's cost is the mandatory resolve-library-id step — pin library IDs per project and the token gap nearly disappears.
Method
Four questions a developer would plausibly ask mid-task were run through both pipelines, back to back, in one Claude Code session:
- Q1 — How do I use load functions and form actions in SvelteKit?
- Q2 — How do I set and read cookies in hooks and load functions in SvelteKit?
- Q3 — How do I handle errors and retries in Effect?
- Q4 — How do I define services and layers with dependency injection in Effect?
Each Context7 run = one resolve-library-id call + one query-docs call (the prescribed per-question flow). Each web run = one WebSearch + one WebFetch of the best result (the fetch is summarized by a small model before it reaches the agent, mirroring how Claude Code's WebFetch actually works). Raw tool outputs were saved verbatim to markdown files and tokenized with tiktoken (o200k_base). Wall-clock timestamps were logged around every call.
Token counts
| Query | C7 resolve | C7 query-docs | C7 total | Web search | Web fetch | Web total | Δ (C7 − Web) |
|---|---|---|---|---|---|---|---|
| Q1 SvelteKit load + form actions | 453 | 856 | 1,309 | 574 | 611 | 1,185 | +124 |
| Q2 SvelteKit cookies + hooks | 360 | 1,011 | 1,371 | 645 | 328 | 973 | +398 |
| Q3 Effect errors + retries | 424 | 1,309 | 1,733 | 677 | 405 | 1,082 | +651 |
| Q4 Effect services + layers | 427 | 1,535 | 1,962 | 744 | 584 | 1,328 | +634 |
| Total | 1,664 | 4,711 | 6,375 | 2,640 | 1,928 | 4,568 | +1,807 |
Tokens per tool output, o200k_base encoding. Step columns are the two tool calls in each pipeline.
resolve-library-id alone accounts for 1,664 tokens (26%) of Context7's total, and its output is nearly identical every time for the same library. If you pin library IDs per project (e.g. note /llmstxt/svelte_dev_kit_llms_txt and /websites/effect-ts_github_io_effect in CLAUDE.md so the agent can skip resolution), Context7 drops to ~4,711 tokens — within ~3% of the web workflow.
Speed
| Query | C7 resolve (s) | C7 query (s) | C7 total (s) | Web search (s) | Web fetch (s) | Web total (s) |
|---|---|---|---|---|---|---|
| Q1 SvelteKit load + form actions | 12.4 | 12.5 | 24.9 | 17.4 | 17.8 | 35.2 |
| Q2 SvelteKit cookies + hooks | 9.8 | 11.4 | 21.2 | 16.9 | 15.3 | 32.2 |
| Q3 Effect errors + retries | 10.0 | 9.4 | 19.4 | 15.5 | 14.1 | 29.6 |
| Q4 Effect services + layers | 11.2 | 15.0 | 26.2 | 16.1 | 25.9* | 42.0 |
| Total | 91.7 | 139.0 |
Wall-clock between bracketing timestamps; every interval includes ~2–4s of agent inference overhead, so absolute values are inflated but the comparison is fair. *Q4 web fetch is additionally inflated by extra agent work at the end of the run.
Context7 won on latency in every single pairing. Individual Context7 calls landed around 7–12s; web search and the WebFetch summarization step (which runs an extra model pass over the page) each ran roughly 13–16s. A two-call Context7 question costs about 20–25s end to end versus 30–35s for search + fetch.
Content quality
The token counts only tell half the story — what you get per token differs a lot:
- Context7 returns verbatim, current code snippets straight from indexed docs, with source URLs. Q4 (Effect services/layers) pulled the curated
effect-solutionspatterns including full workingContext.Service+Layer.effectimplementations — high signal for the agent to write code from. - Web returns a search summary plus a small-model digest of one page. It is cheaper and reads more like an explanation, but it is lossy (the model paraphrases code), covers only the one page you fetched, and the search step spends ~600–750 tokens largely on link metadata.
- Noise exists on both sides. Context7's Q1 answer mixed in SvelteKit's newer remote-functions API alongside classic form actions, and one Effect snippet had a mangled import line; the web digest for Q3 was accurate but shallower, deferring to "see the official docs."
- Context7 tokens spent on code
- Majority — snippets dominate query-docs output
- Web tokens spent on overhead
- ~58% of web total is the search step (links + summary)
- Freshness
- Both current; Context7 pins to indexed doc versions, web reflects live pages
Caveats
- n = 4, single run. This is a vibe check, not a benchmark. Variance between runs (network, search ranking, doc index) is untested.
- Tokenizer is a proxy. tiktoken's o200k_base (GPT-4o encoding) was used because Anthropic doesn't ship a local tokenizer; Claude's tokenizer typically counts somewhat higher, but the ratios between pipelines hold.
- Timing includes agent overhead. Each interval contains one model inference gap (~2–4s). Relative comparisons are fair; absolute latencies are upper bounds.
- Tool-output tokens only. Tool schemas/definitions sitting in the system prompt (both MCP tools and WebSearch/WebFetch) aren't counted, nor are the small request payloads.
- Web workflow shape matters. One search + one fetch is a lean baseline; real sessions often fetch 2–3 pages, which would widen the web token count quickly (~300–600 tokens per extra fetch).
Takeaways
Keep Context7 as the default for library questions — it's meaningfully faster and its output is code you can act on directly. To claw back the token premium, pin known library IDs in project memory/CLAUDE.md so the agent can skip resolve-library-id for SvelteKit and Effect; that removes ~415 tokens per question and makes Context7 roughly token-neutral with web search while staying ~35% faster.
| Scenario | Tokens / query | Time / query | Verdict |
|---|---|---|---|
| Context7 (resolve + query) | ~1,594 | ~23s | Default |
| Context7 (pinned ID, query only) | ~1,178 | ~12s | Best |
| Web search + 1 fetch | ~1,142 | ~35s | Fallback / non-library topics |
Pinned-ID time estimated as the measured query-docs intervals alone.
Raw materials live in ~/Developer/sandbox/deej/context7-token-test/: per-query markdown transcripts (context7/, websearch/), timing.log, analyze.py, and results.json.