Overview
Context7 is an open-source tool from Upstash that gives AI coding assistants access to current, version-specific documentation for the libraries you actually use. LLMs are trained on data that ages quickly, so they often suggest outdated APIs, hallucinate methods that do not exist, or answer for old package versions. Context7 fixes this by retrieving real documentation and code examples from the source and inserting them directly into your prompt.
It works in two modes. The CLI plus Skills mode installs a skill that teaches your agent to fetch docs through the `ctx7` command-line tool, with no MCP needed. The MCP mode registers a Context7 MCP server so your agent can call documentation tools natively. You add the phrase "use context7" to a prompt, or set up a rule so it triggers automatically for library and API questions.
What it does
- Fetches up-to-date, version-specific documentation and working code examples for any indexed library
- Two setup modes: a CLI + Skills flow using the ctx7 command, or a native MCP server
- Single-command setup with npx ctx7 setup, with flags to target Cursor, Claude, or OpenCode
- Library ID syntax (for example /vercel/next.js) to skip matching and load docs for an exact library
- Version targeting by simply mentioning the version in your prompt
- Rules and skills that trigger Context7 automatically for documentation and configuration questions
Getting started
The ctx7 CLI requires Node.js 18 or newer. A free API key from context7.com/dashboard is recommended for higher rate limits. One command sets up Context7 for your coding agent.
Run the setup command
Run the setup command, which authenticates via OAuth, generates an API key, and installs the appropriate skill. It lets you choose between CLI + Skills mode and MCP mode. Add a flag like --cursor, --claude, or --opencode to target a specific agent.
npx ctx7 setupAsk with Context7 in your prompt
Add the phrase "use context7" to any library-related prompt so the agent fetches current docs and code examples before answering.
Create a Next.js middleware that checks for a valid JWT in cookies
and redirects unauthenticated users to `/login`. use context7Use the CLI commands directly
Search the Context7 index by library name, then retrieve documentation for a specific Context7-compatible library ID.
ctx7 library next.js "middleware auth"
ctx7 docs /vercel/next.js "middleware auth"Configure MCP manually (optional)
For MCP clients, point them at the Context7 server URL and pass your API key via the CONTEXT7_API_KEY header. The server URL is https://mcp.context7.com/mcp; client-specific instructions are in the linked docs. To remove the generated setup later, run npx ctx7 remove.
Commands and code are distilled from the project's own documentation — always check the official repo for the latest.
When to use it
- Stopping an AI coding assistant from suggesting outdated or hallucinated APIs by grounding it in real, current docs
- Generating code for a specific library version by mentioning the version in the prompt
- Loading exact documentation for a known library via its Context7 ID (for example /supabase/supabase) to skip the matching step
- Setting up a rule or skill so the agent automatically pulls library and configuration docs without being asked each time
How Context7 compares
Context7 alongside other open-source rag frameworks & platforms tools AI/TLDR tracks, ranked by GitHub stars.
| Tool | Stars | What it does |
|---|---|---|
| Dify | ★ 146k | An open-source platform with a visual workflow builder for creating LLM and RAG applications without writing much code. |
| RAGFlow | ★ 83.2k | A RAG engine built around deep document understanding that turns complex files into a grounded, citation-backed question-answering layer. |
| Context7 | ★ 57.7k | Up-to-date, version-specific library docs piped straight into your coding agent's prompt |
| Quivr | ★ 39.2k | Quivr is an open-source RAG framework that ingests your documents and answers questions about them, working with any LLM and any file type. |
| LightRAG | ★ 36.8k | A graph-based RAG system that builds an entity-and-relationship knowledge graph for fast retrieval and easy incremental updates. |
| GraphRAG | ★ 33.9k | Microsoft's graph-based RAG system that extracts a knowledge graph from documents to answer broad, multi-document questions. |
| PageIndex | ★ 33.2k | PageIndex turns long PDFs into a table-of-contents tree and uses LLM reasoning to retrieve relevant sections, with no vector database and no chunking. |
| FastGPT | ★ 28.6k | FastGPT is an open-source AI agent platform that pairs a built-in knowledge base with a drag-and-drop Flow editor, so you can build question-answering apps without heavy setup. |