Context7 MCP
Add the Context7 MCP server to Claude Code so every session pulls current library docs at query time rather than guessing from stale training data.
Problem: A model's training data has a cutoff date. Ask about React 19, Next.js 15, or any library that shipped a major release in the last few months, and the answer comes back wrong. Stale patterns. Invented APIs. Functions that got renamed two versions ago.
Quick Win: Add Context7 to your MCP config and suffix any prompt with use context7. Docs get pulled before any code is written.
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp@latest"]
}
}
}What Context7 MCP Actually Is
Here is the short version. Context7 is an MCP server. Its one job: pull current, version-pinned documentation and examples straight from the library's own source, not from a months-old weights file.
The flow is simple. Official docs are indexed into library IDs. When you name a library in a prompt, the server resolves the name, grabs the right sections, and slips that material into the conversation before the model responds.
Why It Matters for Claude Code
Hallucinated APIs are the core pain. Models suggest functions that were renamed, deprecated, or never existed in the first place. The cause is always the same: training data lives behind the actual release timeline.
With this server loaded, you get:
- Docs at query time rather than whatever shipped in the weights
- Version-matched examples tied to the release named in your prompt
- Working patterns lifted from official docs that compile on the first try
- Fewer hallucinations because real APIs replace invented ones
Ask for Next.js 15 app router patterns. Context7 fetches the Next.js 15 docs on the spot. Your code comes back referencing what exists today, not what existed when Next.js 13 was the latest release in the training set.
Installation and Setup
Node.js 18 or newer is required. The package is @upstash/context7-mcp.
Claude Code CLI
One command usually does the trick:
claude mcp add context7 -- npx -y @upstash/context7-mcp@latest
Or drop it directly into .mcp.json at the project root:
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp@latest"]
}
}
}Claude Desktop
macOS users should edit ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp@latest"]
}
}
}The equivalent file on Windows lives at %APPDATA%\Claude\claude_desktop_config.json.
Alternative: Bun Runtime
Bun user? Swap the command:
{
"mcpServers": {
"context7": {
"command": "bunx",
"args": ["-y", "@upstash/context7-mcp@latest"]
}
}
}Restart Claude Code once the config lands.
Using It in Practice
Two tools ship with the server:
resolve-library-id: Maps a plain library name to a Context7-compatible identifier. Claude reaches for this whenever a library comes up by name.
query-docs: Pulls the actual docs for one library. Back come current documentation, examples, and API references.
Basic Usage
Stick use context7 on any prompt that needs fresh docs:
Create a Next.js 15 middleware that handles authentication. use context7
Three things happen:
- The name "Next.js" resolves to the library ID
/vercel/next.js - Middleware docs come back from a query
- Code gets written against current API shapes
Version-Specific Queries
A version number dropped into the prompt is picked up automatically:
How do I configure Prisma 6 with PostgreSQL? use context7
Documentation returned will match the exact release named.
Common Library IDs
The ID format is /organization/repository. Eight you will hit often:
| Library | Context7 ID |
|---|---|
| Next.js | /vercel/next.js |
| React | /facebook/react |
| Prisma | /prisma/prisma |
| Supabase | /supabase/supabase |
| Drizzle | /drizzle-team/drizzle-orm |
| tRPC | /trpc/trpc |
| Tailwind | /tailwindlabs/tailwindcss |
| Zod | /colinhacks/zod |
Skip resolution entirely by passing the ID yourself:
use library /supabase/supabase for API and docs
Supported Libraries
Thousands of libraries live in the index. The main categories:
Frontend: React, Vue, Svelte, Angular, Solid, Qwik
Meta-frameworks: Next.js, Nuxt, SvelteKit, Astro, Remix
Backend: Express, Fastify, Hono, NestJS, Koa
Databases: Prisma, Drizzle, Mongoose, TypeORM, Supabase
Utilities: Zod, tRPC, React Query, SWR, Zustand, Jotai
Testing: Vitest, Jest, Playwright, Cypress
Any library with public docs is probably covered. New versions get picked up on a rolling basis.
Pairing With MCP Tool Search
MCP Tool Search pairs cleanly with this server. Flip it on and the tools only load when the conversation calls for them, so session startup stays light.
Why it matters: you can stack this alongside other MCP servers without running into context limits:
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp@latest"]
},
"brave-search": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-brave-search"],
"env": { "BRAVE_API_KEY": "your-key" }
},
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": { "GITHUB_TOKEN": "your-token" }
}
}
}The server only wakes up when docs come up in the prompt or the trigger phrase shows up. Idle time costs zero tokens.
Troubleshooting
ERR_MODULE_NOT_FOUND: Swap npx for bunx. Some environments trip over npm's cache layer.
Library not found: Not every package is indexed. The server tells you plainly when it can't resolve a name. Reach for a web search MCP as a fallback.
Outdated results: Indexing runs on a schedule. Releases from the last few days may not be there yet. For bleeding-edge features, read the official docs directly.
Next Steps
A server like this flips Claude Code from a fixed snapshot into something that actively researches. Stack it with others for a fuller setup:
- Read the MCP fundamentals if the protocol is still new
- Browse a catalog of 50+ MCP servers for more capabilities
- Add a web search MCP for research beyond libraries
- Turn on MCP Tool Search to keep context usage tight
Wire Context7 in and the deprecated patterns stop showing up. use context7 becomes a reflex the first time the code quality difference lands.
Stop configuring. Start building.