Context7 MCP
Context7 documentation server — inject up-to-date library documentation directly into AI context for accurate, version-specific code.
// Add to your client
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp"]
}
}
}Paste into your client's MCP configuration file.
// Try it now
"Look up the current Next.js App Router documentation for server actions and explain it"
- ! Not every library is indexed — less popular ones may fall back to the AI's memory
- ! Documentation freshness varies by project — active ones update fast, dormant ones lag
- ! You still need to verify generated code — Context7 reduces but doesn't eliminate hallucinations
API key or simple config
// When to use
- You want your AI to write code against the actual latest API of a library
- You keep hitting hallucinated function names or outdated patterns
- You're using a library that changed significantly between versions
- You're learning a new library and want your AI to reference real docs
// When NOT to use
- You're using a proprietary or private library not indexed by Context7
- You're offline — this needs network access to Context7's index
- You already have exhaustive docs in your codebase — use a local RAG instead
// Usage Scenarios
Version-Accurate Code Generation
Generate code using the actual current API of a library, not a hallucinated one.
Example prompt
"Write a Next.js 15 Server Component that fetches data using the latest recommended pattern"
API Reference Lookup
Answer questions about specific functions or hooks with verified documentation.
Example prompt
"What's the correct signature and usage for useActionState in React 19?"
Migration Help
Help migrate code between versions using real release notes and docs.
Example prompt
"Help me migrate this Prisma 4 schema to Prisma 6 — use the real migration guide"
// About
Plain English
AI assistants are great at writing code — until the library you're using has changed since the AI was trained. Then you start getting answers that look right but reference functions that no longer exist, or use old patterns the docs say not to use anymore. It's confusing and slow. This server fixes that by giving your AI a live library card. Whenever you mention a tool — React, Next.js, Prisma, Tailwind, hundreds more — Context7 looks up the actual current documentation for that library and slides it into the conversation before the AI writes any code. The result: code generated against the real, current API, not a hazy memory of how things used to work two years ago. For someone learning a new framework, this means examples that match the tutorials you read on the official site. For someone migrating between versions, the AI reads the real migration guide instead of guessing. It won't fix every wrong answer — you still review the code — but it cuts down on the most frustrating kind of mistake: confidently wrong API calls.
The Context7 MCP server resolves library names to current documentation and injects relevant code examples directly into your AI's context. Eliminates hallucinated API calls by providing accurate, version-specific documentation.
Particularly valuable for working with rapidly evolving libraries where LLM training data may be outdated. Supports thousands of popular libraries.
// Use Cases
- Get accurate, up-to-date API documentation in context
- Eliminate hallucinated function calls from AI
- Work with latest library versions without retraining
- Quick lookup of library APIs during development
// Works With
// Also Consider
// Related Servers
Anthropic Claude API MCP
Use Claude API within Claude — chain AI calls, compare model outputs, and build sophisticated multi-agent workflows.
Git MCP
Official Git MCP server — read repository history, diffs, blame, and status through AI without leaving your conversation.
Memory MCP
Official persistent memory server for AI — store facts, preferences, and context across conversations using a knowledge graph.