Context7 MCP: Up-to-Date Docs for AI Assistants
Context7 MCP feeds version-specific library docs to AI coding assistants. Set it up in Claude Code with ctx7 setup, the plugin, or claude mcp add.
Have you encountered these issues when using AI coding assistants?
- Outdated APIs: AI generates code using deprecated methods
- Non-existent functions: AI “hallucinates” APIs that don’t exist
- Version mismatches: Example code is for older versions and won’t run on current releases
- Constant doc switching: Repeatedly switching between editor and browser
Context7 MCP was created to solve these pain points. It’s a Model Context Protocol server developed by Upstash that provides version-specific official documentation in real-time, injected directly into AI prompts.
Updated October 21, 2026: Setup now runs through
npx ctx7 setup --claudeor the Context7 plugin; the second MCP tool isquery-docs(formerlyget-library-docs); the hosted endpoint ishttps://mcp.context7.com/mcp; and the Free and Pro quotas have changed. Commands and quotas below are checked against Context7’s official docs and the Claude Code MCP reference.
What is Context7 MCP?
Context7 is an MCP server that provides real-time, accurate, version-specific code documentation for LLMs and AI coding assistants.
Core Features
-
Real-Time Documentation Access 📚
- Pulls latest docs directly from official sources
- Ensures AI always uses the most current information
-
Version-Specific Precision 🎯
- Mention the version in your prompt (“Next.js 16”) and Context7 matches it, or pass a versioned library ID such as
/vercel/next.js/v16.2.9 - Avoids code errors from version mismatches
- Mention the version in your prompt (“Next.js 16”) and Context7 matches it, or pass a versioned library ID such as
-
Zero-Switch Workflow ⚡
- Documentation injected directly into prompts, no browser jumping
- Boosts productivity and maintains focus
-
Broad Compatibility 🔌
- Works with any MCP-compatible client
- Context7 publishes setup guides for Claude Code, Codex, GitHub Copilot CLI, Cursor, OpenCode, Pi and VS Code, plus manual configuration for 30+ other MCP clients
How It Works
The Context7 MCP server exposes exactly two tools, and clients list them under these names:
1. resolve-library-id
Resolves a general library name into a Context7-compatible library ID.
| Parameter | Type | Description |
|---|---|---|
libraryName | string, required | Library name with its official punctuation — Next.js, not nextjs |
query | string, required | What you want to do with the library, e.g. set up middleware |
The tool returns matching libraries with their ID, title, description, code-snippet count, source reputation, benchmark score, and available versions.
2. query-docs
Fetches documentation for a library using a Context7-compatible library ID.
| Parameter | Type | Description |
|---|---|---|
libraryId | string, required | Exact library ID, e.g. /vercel/next.js or /vercel/next.js/v16.2.9 |
query | string, required | What to look up, scoped to a single concept |
language | string, optional | The language you write in, e.g. Python — code examples in it rank first |
Call resolve-library-id before query-docs unless you already know the ID in /owner/repo form.
This tool was named
get-library-docsin earlier releases. It isquery-docstoday, and it has nomaxTokensparameter — scope the result with a precisequeryinstead.
Installation & Setup
Method 1: ctx7 setup (Recommended)
Context7 ships its own CLI, which requires Node.js 22.13 or newer:
npx ctx7 setup --claude
The flow authenticates with the OAuth device flow — it prints a verification link and a short code you open on any device, so it works the same locally, over SSH, or on a headless host — then generates an API key and installs the matching skill. It offers two modes:
- MCP server — registers the Context7 MCP server so Claude Code can call
resolve-library-idandquery-docsnatively - CLI + Skills — installs a
docsskill that drives thectx7 libraryandctx7 docscommands, with no MCP server at all
Add --project to configure the current project instead of your user-level configuration, and remove everything later with npx ctx7 remove.
Method 2: The Context7 Plugin
The plugin connects Claude Code to the hosted MCP server with no local Node.js, npm or npx required:
/plugin marketplace add upstash/context7
/plugin install context7@context7-marketplace
Restart Claude Code, run /mcp, select Context7, and complete the browser sign-in. No API key is required. Note that the plugin does not read CONTEXT7_API_KEY — on a headless, SSH or CI host, use npx ctx7 setup --claude or add the server manually instead.
Method 3: Manual claude mcp add
Context7’s official Claude Code instructions give two forms. The remote form is the one to prefer:
# Remote server (hosted, recommended)
claude mcp add --scope user \
--header "Authorization: Bearer YOUR_API_KEY" \
--transport http context7 https://mcp.context7.com/mcp
# Local stdio server
claude mcp add --scope user context7 \
-- npx -y @upstash/context7-mcp --api-key YOUR_API_KEY
Claude Code has three MCP scopes — local (the default, this project only, private), project (written to .mcp.json and shared through version control), and user (all your projects, private). There is no global scope. A project-scoped server lands in .mcp.json at the repository root; local and user servers live in ~/.claude.json.
Verify the result with claude mcp get context7, which reports the connection status, or claude mcp list, which health-checks every approved server.
Get Your API Key
- Visit context7.com/dashboard
- Sign up and create an API Key
- Pass it as the
Authorization: Bearer <key>header (remote) or--api-key(stdio).ctx7 setupand the plugin handle this for you
Real-World Examples
Example 1: Query Latest Next.js App Router Usage
You: "How do I set up a Next.js 16 proxy? use context7"
Context7 runs:
1. resolve-library-id(libraryName: "Next.js", query: "set up a proxy")
→ /vercel/next.js (plus the versioned IDs it has indexed)
2. query-docs(libraryId: "/vercel/next.js", query: "set up a proxy")
→ Current proxy documentation and code examples
Claude answers from the documentation it just fetched, not from training data.
Example 2: Skip Resolution with a Library ID
If you already know the ID, name it in the prompt and Context7 skips the lookup step:
You: "use context7 with /supabase/supabase for authentication docs"
Context7 runs:
1. query-docs(libraryId: "/supabase/supabase", query: "authentication")
→ Current Supabase auth documentation
Pass a versioned ID such as /vercel/next.js/v16.2.9 when you need one specific release.
Pricing Plans (checked October 21, 2026)
| Plan | Price | Included API calls | Best For |
|---|---|---|---|
| Free | $0/month | 1,000 per month | Individual developers, public repositories |
| Pro | $10 per seat/month | 2,000 per seat/month, then $5 per 1,000 | Teams, private repositories |
| Enterprise | Custom | 2,000 per seat/month, then $5 per 1,000 | SOC-2, SSO, self-hosted |
Search API and Context API requests each count as one call against the allowance. Free accounts are blocked when they hit the monthly limit, with 20 bonus calls granted each day until the month resets; Pro accounts are never blocked and bill the overage. Parsing private repositories is charged separately at $5 per 1M tokens. See Context7’s pricing page for the current terms.
Why Context7?
The Problem: AI’s “Knowledge Cutoff Date”
Large language models are trained on data with cutoff dates. Even on the current lineup — Claude Fable 5.1, Opus 5.5, Sonnet 5.5 and Haiku 5.5 all carry a reliable knowledge cutoff of June 2026 — that still leaves gaps:
- New framework versions release after the cutoff
- API detail changes (parameter names, return formats)
- Best practices for new features (like React Server Components evolution)
These changes lead AI to generate incorrect or outdated code.
The Solution: Real-Time Documentation Injection
Context7 uses the MCP protocol to inject the latest official documentation directly into AI’s context, ensuring every code generation is based on current, correct information.
Context7 vs. Manual Doc Lookup
| Comparison | Manual Lookup | Context7 MCP |
|---|---|---|
| Switching Cost | Need browser jump | Zero switching |
| Version Control | Manual version check | Auto-match version |
| Integration | Copy-paste needed | Auto-inject prompts |
| Efficiency | Interrupts workflow | Seamless integration |
| Accuracy | Depends on AI memory | Direct official docs |
Advanced Usage Tips
1. Explicitly Specify Versions
"How do I set up a Next.js 16 proxy? use context7"
Mention the version in the prompt and Context7 matches the right one. For an exact release, pass the versioned library ID directly: /vercel/next.js/v16.2.9.
2. Scope the Query, Not a Token Budget
There is no maxTokens knob. What you control is the question:
Good: "use context7 for the Supabase syntax for row-level security"
Avoid: "use context7, tell me about Supabase"
Queries work best when they describe a single concept you are trying to accomplish. Pass the optional language parameter — or just write in the language — to rank code examples in your stack first.
3. Add a Rule So You Don’t Have to Ask
ctx7 setup installs a skill that triggers on library questions automatically. To wire it up by hand instead, add a rule to CLAUDE.md:
Always use Context7 when I need library/API documentation, code generation, setup or configuration steps without me having to explicitly ask.
4. Combine with Other MCP Servers
Context7 works synergistically with other MCP servers:
- Memory MCP: Remember project package versions
- Filesystem MCP: Read
package.jsonto auto-infer versions - Sequential Thinking MCP: Break down complex problems
Supported Languages & Frameworks
Context7 indexes a large, continuously refreshed catalog of packages and frameworks. Each entry carries a library ID, an indexed code-snippet count, a source-reputation rating, a benchmark score, and any version-specific IDs. Search it from the terminal with npx ctx7 library <name> "<what you want to do>", or browse it on the website. Commonly used entries include:
Frontend
- React, Vue, Angular, Svelte
- Next.js, Nuxt, SvelteKit
- Tailwind CSS, Bootstrap
Backend
- Node.js, Express, NestJS
- Python (Flask, Django, FastAPI)
- Go, Rust
Databases & Infrastructure
- PostgreSQL, MongoDB, Redis
- AWS SDK, Google Cloud SDK
- Kubernetes, Docker
Browse the full, live catalog at the Context7 official site — the index is updated continuously, so treat any list in an article as a sample rather than a specification.
Best Practices
✅ Recommended
- Pick the scope deliberately:
--scope projectto share the server through.mcp.json,--scope userfor every project on your machine - Version locking: Name the version in the prompt, or pass a versioned library ID
- One concept per query: Specific questions return better documentation than broad ones
- Combine with Memory MCP: Let Claude remember project packages
❌ Avoid
- Over-reliance: Basic syntax doesn’t need documentation
- Vague queries: Single keywords burn an API call and return weak matches
- Mixed versions: Ensure project dependencies match doc versions
Troubleshooting
Issue 1: Cannot Connect to Context7
# Check what Claude Code has configured and whether it connected
claude mcp get context7
# Health-check every approved server
claude mcp list
# Check your Context7 login from the CLI
npx ctx7 whoami
claude mcp list prints a status next to each server — ✔ Connected, ! Needs authentication, or ✘ Failed to connect with the failure detail. A project-scoped server shows ⏸ Pending approval until you approve it in an interactive session.
Issue 2: Package Not Found
You: "I want to use some-obscure-library"
Context7: No matching library found
Solution:
- Use the library’s official punctuation —
Next.js, notnextjs - Search the index directly:
npx ctx7 library react "how to clean up useEffect" - Browse context7.com, or submit the library through Adding Libraries
Issue 3: Documentation Too Old
If documentation isn’t the latest:
- Pass a versioned library ID (
/vercel/next.js/v16.2.9) instead of the bare ID - Report it to the Context7 team (GitHub Issues) or consult Troubleshooting
- Supplement with WebFetch or WebSearch for anything the index hasn’t picked up yet
Context7’s Future
OAuth 2.0 Support
Context7’s MCP server supports OAuth 2.0 for clients that implement the MCP OAuth specification. There is no separate oauth configuration block — you change the endpoint from /mcp to /mcp/oauth:
- "url": "https://mcp.context7.com/mcp"
+ "url": "https://mcp.context7.com/mcp/oauth"
OAuth is available for remote HTTP connections only; a local stdio connection uses API-key authentication instead. In Claude Code, claude mcp login context7 runs the OAuth flow for a configured remote server, and claude mcp login context7 --no-browser prints the authorization URL instead of opening a browser — useful over SSH.
MCP Ecosystem
Context7 is a star project in the Model Context Protocol ecosystem. In December 2025, Anthropic donated MCP to the Agentic AI Foundation (co-founded by Anthropic, Block, and OpenAI), marking MCP as an industry standard.
In March 2025, OpenAI officially adopted MCP, integrating it into the ChatGPT desktop app, further driving MCP adoption.
Context7 was listed as Trial stage in Thoughtworks Technology Radar in November 2025, recognized as a mature tool worth trying.
On Anthropic’s side, the Build plugins for Claude announcement (September 25, 2026) confirms that “Claude supports the latest MCP spec, commonly referred to as MCP 2.0” — so a server written to the current specification works across Claude Code, the desktop app and the Claude apps.
Conclusion
Context7 MCP solves the core pain point of AI coding assistants: outdated knowledge and inaccurate code generation. By providing version-specific official documentation in real-time, it enables Claude Code, Codex, Cursor, OpenCode and other MCP clients to generate more accurate and reliable code.
Is It Right for You?
| Use Case | Recommendation |
|---|---|
| Learning new frameworks | ⭐⭐⭐⭐⭐ |
| Frequently switching tech stacks | ⭐⭐⭐⭐⭐ |
| Using latest framework versions | ⭐⭐⭐⭐⭐ |
| Daily development assistance | ⭐⭐⭐⭐ |
| Basic syntax lookup | ⭐⭐ |
Get Started Now
- Run
npx ctx7 setup --claudeand complete the device-flow sign-in - Or install the plugin:
/plugin marketplace add upstash/context7, then/plugin install context7@context7-marketplace - Ask a library question with
use context7, or add the rule toCLAUDE.mdso it fires on its own - Enjoy zero-switch development experience
Further Reading
- Context7 Official Website
- Context7 GitHub Repository
- Using Context7 with Claude Code — the official setup page
- MCP Clients — manual configuration for 30+ clients
- ctx7 CLI Reference
- Claude Code MCP documentation
- Model Context Protocol Specification
- Companion article: Context7 MCP: Access Up-to-Date Documentation in Claude Code — the workflow-focused walkthrough