Context7 MCP Server
Context7 MCP Server bridges the gap between AI coding assistants and current library documentation. Instead of relying on outdated training data or hallucinated APIs, Context7 fetches fresh, accurate documentation and code examples directly from official sources.
Why Context7?
The Problem
Without Context7, AI coding assistants face significant limitations:
- Outdated Information: Code examples are often based on year-old training data
- Hallucinated APIs: Models may generate non-existent APIs
- Version Mismatches: Generic answers that don’t account for specific library versions
The Solution
Context7 MCP Server provides:
- ✅ Real-time documentation from official sources
- ✅ Version-specific code examples
- ✅ Accurate API references
- ✅ No more tab-switching to read docs
Core Features
1. Library Documentation Retrieval
Query any library and get relevant documentation with code examples:
``` How do I set up Next.js middleware? use context7 ```
Context7 will fetch the latest Next.js documentation and provide concrete examples.
2. Version-Specific Queries
Get documentation for specific library versions:
``` How do I use Supabase with Next.js 14? use context7 ```
3. Library ID Resolution
For precise results, specify the library ID:
``` Implement authentication with Supabase. use library /supabase/supabase ```
Supported Libraries
Context7 supports hundreds of popular libraries including:
- Frontend: Next.js, React, Vue, Angular, Svelte
- Backend: Express, Fastify, NestJS, Django, Flask
- Databases: Supabase, Prisma, MongoDB, PostgreSQL
- Cloud: AWS SDK, Cloudflare Workers, Vercel
- AI/LLM: LangChain, OpenAI, Anthropic SDKs
- And many more…
Supported MCP Clients
Context7 works with 30+ MCP-compatible clients:
| Category | Clients |
|---|---|
| Code Editors | Cursor, VS Code, Windsurf, Cline |
| AI Assistants | Claude Code, Gemini CLI, Goose |
| IDEs | JetBrains AI Assistant, Junie |
| CLI Tools | Codex, Copilot CLI, OpenCode |
| Specialized | Amp, Kiro, Qoder, Factory |
Installation
Quick Install (Cursor 1.0+)
Click the install button in your Cursor settings or paste this config:
```json { “mcpServers”: { “context7”: { “command”: “npx”, “args”: [“-y”, “@upstash/context7-mcp”, “—api-key”, “YOUR_API_KEY”] } } } ```
Claude Code
```bash claude mcp add context7 — npx -y @upstash/context7-mcp —api-key YOUR_API_KEY ```
Remote Server (No API Key)
```json { “mcpServers”: { “context7”: { “url”: “https://mcp.context7.com/mcp”, “headers”: { “CONTEXT7_API_KEY”: “YOUR_API_KEY” } } } } ```
Available Tools
Context7 provides two main tools:
1. resolve-library-id
Resolves a library name to a Context7-compatible library ID:
```typescript resolve_library_id({ libraryName: “nextjs”, query: “middleware setup” }) ```
2. query-docs
Retrieves documentation for a specific library:
```typescript query_docs({ libraryId: “/vercel/next.js”, query: “How to create middleware for authentication” }) ```
Best Practices
Auto-Invoke Rule
Avoid typing `use context7` every time by adding a rule:
“Always use Context7 MCP when I need library/API documentation, code generation, setup or configuration steps without me having to explicitly ask.”
Cursor Settings → Rules
Add this rule to automatically invoke Context7 for code-related queries.
CLAUDE.md
For Claude Code, add to your project root:
``` Always use Context7 MCP when I need library/API documentation, code generation, setup or configuration steps without me having to explicitly ask. ```
API Keys
Context7 offers generous free tier:
| Plan | Monthly Requests | Libraries |
|---|---|---|
| Free | 1,000 | 50 |
| Pro | 10,000 | Unlimited |
| Enterprise | Unlimited | Unlimited |
Get your API key at: https://context7.com
Contributing
Adding New Libraries
You can submit libraries to be added to Context7:
- Visit https://context7.com/docs/adding-libraries
- Submit a library request
- The team will process and add it to the documentation
Self-Hosting
For enterprise use, you can self-host the documentation parsing engine.
Security & Privacy
- Data Encryption: All data is encrypted in transit and at rest
- No Training on User Data: Your queries are never used for training
- GDPR Compliant: Full compliance with data protection regulations
- OAuth 2.0: Enterprise-grade authentication available
Performance
- Fast Response: Typical response time < 500ms
- Global CDN: Documentation served from edge locations
- Caching: Intelligent caching reduces redundant fetches
Summary
Context7 MCP Server transforms how AI coding assistants interact with library documentation. By providing real-time, version-specific information directly from official sources, it eliminates the frustration of outdated or hallucinated code examples. Whether you’re building with Next.js, Supabase, or any other popular library, Context7 ensures your AI assistant has the most accurate information at its fingertips.