Context7 MCP server in Claude Code.
Stop Claude Code from hallucinating APIs that changed two majors ago. Context7 pulls current, version-specific library docs into the session — and registering it takes one command.
Every model has a training cutoff, and fast-moving libraries punish you for it: Claude Code will confidently write against an API signature that was deprecated last quarter. Context7 — Upstash's documentation server, the most-starred MCP server around at 57.1k GitHub stars — fixes this by fetching current, version-specific docs and code examples at prompt time.
It's arguably the highest-leverage MCP server for a coding agent, and in Claude Code it's also one of the easiest to install. Here's the setup, the verification step, and how to actually get Claude to use it.
What Context7 does mid-session
The server exposes two tools that work as a pair: one resolves a library name like 'next.js' or 'drizzle' to a Context7 library ID, and the other fetches focused documentation for that ID — scoped to a topic and, crucially, to the version you're using. When Claude Code is about to write a Next.js route handler or a Tailwind v4 config, it can ground itself in today's docs instead of training-data memory.
The package lives on npm as @upstash/context7-mcp. The service works without an account; an optional API key from the Context7 dashboard raises rate limits if you lean on it heavily.
Add it with one command
Use Claude Code's built-in MCP management. This registers Context7 as a stdio server in your user scope so it's available in every project:
claude mcp add context7 -- npx -y @upstash/context7-mcpOr commit it to the repo
For teams, a project-root .mcp.json keeps everyone's Claude Code identically equipped — useful when the repo depends on libraries that change fast. Each contributor approves the server once on first launch:
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp"]
}
}
}Make Claude actually use it
Run `/mcp` in a session to confirm context7 is connected, then try: 'use context7 to check the current App Router data fetching API, then refactor this page.' Claude calls the resolve tool, pulls the docs, and writes against them. If you find yourself typing 'use context7' often, add a line to your project's CLAUDE.md telling Claude to consult Context7 before writing code against external libraries — that makes the lookup habitual instead of on-request.
Context7's live tool list and listing are on the Loomal marketplace at https://loomal.ai/marketplace/context7.
Troubleshooting in Claude Code
Not listed in `/mcp`? Check scope with `claude mcp list` — a server registered in another directory's local scope won't follow you to this project. For .mcp.json installs, make sure the file is valid JSON and that you accepted the approval prompt; a declined project server stays hidden until you reset the choice.
If the server connects but doc fetches fail, it's nearly always network-side: the server queries Context7's service, so proxies and offline machines will break it even though the process starts fine. Persistent rate-limit errors are the signal to add an API key — set it via the args per the README. As with any config change, restart your session before retesting.
FAQ
How do I install Context7 in Claude Code?
Run `claude mcp add context7 -- npx -y @upstash/context7-mcp` for a user-scoped install, or add the equivalent entry to a .mcp.json at your project root to share it with the team. Verify with `/mcp` in a new session.
Do I need a Context7 API key?
Not to start — the server works anonymously. If you hit rate limits during heavy use, create a free key in the Context7 dashboard and pass it to the server per the README. For occasional doc lookups, anonymous use is usually fine.
Claude isn't calling Context7 even though it's connected. Why?
Connected tools are available, not mandatory — Claude decides when to call them. Mention 'use context7' in the prompt, or add a standing instruction in CLAUDE.md to check current docs before writing library code. That reliably triggers the lookup.
What's the difference between Context7's two tools?
The first resolves a human library name to a Context7-compatible library ID; the second fetches documentation for that ID, optionally scoped to a topic. Claude chains them automatically — resolve once, then fetch the docs it needs.
More MCP servers for Claude Code.
Browse the Loomal marketplace — every listing shows a live-probed tool list.