Context7 MCP: Up-to-Date Docs for AI Assistants
Learn how Context7 MCP provides real-time, version-specific documentation to AI coding assistants. Eliminate outdated APIs, hallucinated functions, and constant doc switching with automatic documentation injection.
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.
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 🎯
- Supports exact version numbers (e.g.,
react@18.2.0) - Avoids code errors from version mismatches
- Supports exact version numbers (e.g.,
-
Zero-Switch Workflow ⚡
- Documentation injected directly into prompts, no browser jumping
- Boosts productivity and maintains focus
-
Broad Compatibility 🔌
- Works with all MCP-compatible editors
- Claude Desktop, Cursor, Windsurf, and more
How It Works
Context7 provides two main tools:
1. resolve-library-id
Resolves package names to Context7-compatible Library IDs.
// User input: "I want to use React"
→ resolve-library-id("react")
→ Returns: [
{ id: "/react/react", name: "React", version: "latest" },
{ id: "/react/react/18.2.0", name: "React", version: "18.2.0" },
{ id: "/react/react/19.0.0", name: "React", version: "19.0.0" }
]
2. get-library-docs
Fetches the latest documentation for a specified library.
// Get React 18.2.0 documentation
→ get-library-docs("/react/react/18.2.0", maxTokens: 5000)
→ Returns: Official docs content (React Hooks, Component API, etc.)
Key Feature:
maxTokensparameter: Controls documentation length (default 5000)- Higher values provide more context but consume more tokens
Installation & Setup
Method 1: Official CLI (Recommended)
# Install for project scope
claude mcp add \
--scope project \
context7 \
-e CONTEXT7_API_KEY=<your-api-key> \
-- npx -y @upstash/context7-mcp
# Install globally
claude mcp add \
--scope global \
context7 \
-e CONTEXT7_API_KEY=<your-api-key> \
-- npx -y @upstash/context7-mcp
Method 2: Manual Configuration
Edit .claude/config.json (project) or ~/.claude/config.json (global):
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp"],
"env": {
"CONTEXT7_API_KEY": "<your-api-key>"
}
}
}
}
Get Your API Key
- Visit context7.com/dashboard
- Sign up and create an API Key
- Set the key in your environment variables
Real-World Examples
Example 1: Query Latest Next.js App Router Usage
You: "Help me create a dynamic route using Next.js 14 App Router"
Context7 automatically executes:
1. resolve-library-id("nextjs") → /vercel/next.js/14.0.0
2. get-library-docs("/vercel/next.js/14.0.0") → Fetch App Router docs
AI responds: According to Next.js 14 official documentation, here's the correct approach...
Example 2: Using Version-Specific APIs
You: "I'm using React 18.2, help me optimize this form with useTransition"
Context7 automatically executes:
1. resolve-library-id("react@18.2") → /react/react/18.2.0
2. get-library-docs("/react/react/18.2.0") → Fetch React 18.2 Hooks docs
AI responds: According to React 18.2's useTransition API...
Pricing Plans (January 2026 Update)
| Plan | Price | Requests | Best For |
|---|---|---|---|
| Free | $0/month | 500 requests/month | Personal trial |
| Pro | $10/month | Unlimited | Professional developers |
⚠️ Note: In January 2026, Context7 significantly adjusted its free tier, reducing from unlimited to 500 requests per month (92% reduction). If you’re a heavy user, upgrading to Pro is recommended.
Why Context7?
The Problem: AI’s “Knowledge Cutoff Date”
Large language models are trained on data with cutoff dates. Even though Claude Sonnet 4.5’s knowledge extends to January 2025:
- New framework versions (like Next.js 15) 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
"Implement responsive layout using Tailwind CSS 3.4's new container query feature"
Context7 will automatically parse 3.4 and fetch that version’s documentation.
2. Control Documentation Length
Adjust maxTokens in your project’s .claude/config.json:
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp"],
"env": {
"CONTEXT7_API_KEY": "<your-api-key>",
"CONTEXT7_MAX_TOKENS": "10000" // Increase to 10000
}
}
}
}
3. 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 supports thousands of popular packages and frameworks, including:
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
Full list available at Context7 official site.
Best Practices
✅ Recommended
- Project-level install: Use
--scope projectto avoid global pollution - Version locking: Explicitly specify version numbers in prompts
- Reasonable token use: 5000 for general queries, 10000+ for complex APIs
- Combine with Memory MCP: Let Claude remember project packages
❌ Avoid
- Over-reliance: Basic syntax doesn’t need documentation
- Unlimited tokens: Consumes quota, increases response latency
- Mixed versions: Ensure project dependencies match doc versions
Troubleshooting
Issue 1: Cannot Connect to Context7
# Check if API Key is correct
echo $CONTEXT7_API_KEY
# Test connection
npx @upstash/context7-mcp
Issue 2: Package Not Found
You: "I want to use some-obscure-library"
Context7: No matching library found
Solution:
- Verify package name spelling
- Try using full npm package name (e.g.,
@org/package) - Check Context7 support list
Issue 3: Documentation Too Old
If documentation isn’t the latest:
- Report to Context7 team (GitHub Issues)
- Manually specify newer version number
- Supplement with Web Search for latest info
Context7’s Future
OAuth 2.0 Support
Context7 now supports OAuth 2.0 authentication, offering more secure credential management for MCP OAuth-compliant clients:
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp"],
"oauth": {
"endpoint": "https://context7.com/mcp/oauth"
}
}
}
}
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.
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, Cursor, Windsurf, and similar tools 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
- Visit context7.com to sign up
- Get your API Key
- Install using
claude mcp add - Enjoy zero-switch development experience