Snapshot
| Context7 | Ref | |
|---|---|---|
| Approach | Batch retrieval | Iterative search + read |
| Content | Code snippets | Any content type (source of truth) |
| Token optimization | Consistent ~3k tokens/query | Adaptive 500-5k tokens/query |
| Tools | resolve-library-id, query-docs | ref_search_documentation, ref_read_url |
| Scrape any URL on the fly | No | Yes |
| Private repos | Paid add-on | Included |
| PDF & file upload | No | Yes |
| Repo indexing | Paid | Free |
| Prompt injection protection | In-house | Centure.ai |
| Paid plan | $10/mo for 500 queries | $9/mo for 1,000 queries |
Search Philosophy
Both Context7 and Ref now use stateful sessions to optimize token usage and avoid duplicate results. Where they differ is in search patterns and feature depth.Context7’s Approach
Context7 asks your agent to pick a library and then query that library’s docs. Strengths:- Pre-processed code snippets
- One of the most popular MCP servers showing why MCP is valuable
- Batch retrieval doesn’t match iterative agent/human search patterns
- Limited to snippets from public documentation—no private repos, PDFs, or file uploads without paid upgrades
Ref’s Approach
Ref uses agentic search with MCP sessions: provides search() and read() tools, allowing agents to:- Issue queries and get result overviews
- Selectively read only relevant documents
- Iterate efficiently with session state
- Adaptive token usage - agents choose which pages to read, so simple queries return only what’s needed while complex queries can dig deeper
- Never return same link twice - agents can access prior results from context
- On-the-fly extraction - automatically filter large pages (e.g., 90K token Figma docs → 5K relevant tokens)
- Pre-fetching - results are cached for faster reads
Why Token Efficiency Matters
Both servers optimize for token usage because:- Tokens cost money
- Context rot: irrelevant tokens degrade output quality
- Agents build context over multiple searches, so session-level metrics matter more than single-query precision