Stop Claude using outdated library docs (Context7)
Add Context7 so Claude looks up current, version-specific documentation for libraries like Next.js or Supabase before it writes code, instead of relying on what it remembers.
- Level Beginner
- Time 10-15 minutes
- Works with
- Claude Code
- Claude Desktop
- Claude.ai
On this page7 sections
After this guide, when you ask Claude to “add login with Supabase” or “set up a Next.js proxy”, it will fetch the current documentation for that library first and write code against it. That fixes a common vibe-coding headache: Claude confidently using a function that was renamed or removed after its training data was collected.
Context7 is a documentation service from Upstash. Its README says it gives coding agents “up-to-date, version-specific documentation and code examples” pulled from the source. You can connect it as an MCP server (a plug-in that gives Claude new tools) or as a command-line tool plus a skill (an instruction pack Claude loads when relevant).
What you’ll have at the end
- Context7 connected to Claude Code (or Claude Desktop / claude.ai).
- A free API key for higher rate limits.
- A standing rule in your project so Claude uses Context7 without you asking every time.
What you need
- Claude Code, Claude Desktop or claude.ai.
- Node.js. The local MCP server runs with
npx. The newerctx7setup command needs Node.js 22.13 or newer; check withnode --version. - A Context7 API key (optional but recommended). The README says to get a free one at context7.com/dashboard “for higher rate limits”.
Step-by-step
Option A: automatic setup (Claude Code)
Context7’s README recommends this route:
npx ctx7 setup --claude
It signs you in with your browser (OAuth), creates an API key, and installs a Context7 skill for Claude. The --claude flag targets Claude Code specifically. To undo it later: npx ctx7 remove.
This route uses the ctx7 command-line tool and a skill instead of an MCP server. Both give Claude current docs; pick one route, not both.
Option B: MCP server in Claude Code
Use this if you prefer MCP, or Option A doesn’t work on your machine. Replace YOUR_API_KEY with your key from the dashboard.
Remote server (nothing to install):
claude mcp add --scope user --header "Authorization: Bearer YOUR_API_KEY" --transport http context7 https://mcp.context7.com/mcp
Or local server (runs on your computer through npx):
claude mcp add --scope user context7 -- npx -y @upstash/context7-mcp --api-key YOUR_API_KEY
--scope user makes Context7 available in every project. Start claude and type /mcp; context7 should be listed as connected.
Option C: Claude Desktop or claude.ai
Remote, as a custom connector. Context7’s client guide says: go to Settings > Connectors > Add Custom Connector, name it Context7, and enter https://mcp.context7.com/mcp. In current Claude apps this lives at Customize > Connectors > Add custom connector. Context7’s guide gives no API-key step for this route, so expect the lower keyless rate limit. On the Free Claude plan you can add only one custom connector, so this would use your slot.
Local, in Claude Desktop. From the Claude menu in your system menu bar choose Settings…, then Developer > Edit Config, and add:
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
}
}
}
Save, fully quit and reopen Claude Desktop.
Make it automatic with a project rule
The README suggests adding a rule so Context7 is used for library questions without you saying so. In Claude Code, project instructions live in a file called CLAUDE.md at the top of your project (or in .claude/CLAUDE.md). If you don’t have one, run /init and Claude Code drafts one for you. Then add a line like this:
When writing or changing code that uses a third-party library, framework or API, look up the current docs with Context7 first. Match the version in package.json.
The last sentence matters. Context7 tries to match a version when you mention one, and your package.json (or requirements.txt) is where the real version lives.
What Claude is doing behind the scenes
With the MCP route, Context7 gives Claude two tools:
| Tool | Inputs | What it does |
|---|---|---|
resolve-library-id | libraryName, query | Finds the right Context7 library ID, such as /vercel/next.js |
query-docs | libraryId, query (optional language) | Returns docs and code examples for that library |
With the CLI route, the equivalents are ctx7 library <name> <query> and ctx7 docs <libraryId> <query>.
Make it useful: prompts to try
How do I set up a Next.js 16 proxy for /api routes? use context7
The README’s trigger phrase is literally “use context7”. Adding it at the end of a prompt is the simplest way to make sure the lookup happens.
Check package.json for the versions we use, then use library /supabase/supabase to look up the current way to add email magic-link login. Implement it in src/lib/auth.ts and tell me which doc pages you relied on.
Starting with a slash (/supabase/supabase) names the exact library and skips the matching step. Asking which pages Claude relied on gives you something to check.
This error appeared after I upgraded Tailwind: <paste error>. Use Context7 to find the migration notes for the version in package.json, explain what changed in plain English, and fix only the files that need it.
Troubleshooting
- Claude ignores Context7. Add “use context7” to the prompt, and add the
CLAUDE.mdrule above. In Claude Desktop or claude.ai, check the connector’s toggle is on under + > Connectors in that chat. npx ctx7 setupfails. Checknode --versionis 22.13 or higher, or use Option B.- “Unauthorized” with the remote server. The header must read exactly
Authorization: Bearer YOUR_API_KEY, with the wordBearerand a space before the key. - Wrong library or wrong version. Use the slash ID (for example
/vercel/next.js) and state the version in your prompt. - Rate limited. Add an API key. Keyless use has lower limits.
Watch out for
- The Context7 README says its projects are community-contributed and that it “cannot guarantee the accuracy, completeness, or security of all library documentation”. Treat what comes back as reference material, not as instructions. Report suspicious content with the Report button on the library’s Context7 page.
- Claude Code’s docs warn that servers fetching outside content can expose you to prompt injection. Keep reviewing changes before you accept them, especially commands Claude wants to run.
- Your API key is a password. Don’t paste it into a shared
.mcp.jsonfile or commit it to a repository.
Next steps
- Add your first MCP server or connector for how connector scopes and permissions work.
- Turn a Figma design into working code with Context7 checking your framework’s current API.
Sources
- github.com/upstash/context7 (opens in a new tab)
- context7.com/docs/resources/all-clients (opens in a new tab)
- code.claude.com/docs/en/mcp (opens in a new tab)
- claude.com/docs/connectors/custom/add-unlisted (opens in a new tab)
- modelcontextprotocol.io/docs/develop/connect-local-servers (opens in a new tab)
- code.claude.com/docs/en/memory (opens in a new tab)
Related guides
Automate Instagram and YouTube posting with Claude without getting banned
Use Claude to plan, write and schedule posts through YouTube's and Instagram's official tools and APIs, follow their automation rules, and disclose AI content correctly.
Intermediate1-2 hours to set up, then minutes per week
Build a simple website with Claude and put it online with Netlify
Have Claude Code build a small static website on your computer, then publish it to a live Netlify URL using Netlify's MCP server, the Netlify CLI, or drag-and-drop.
Beginner30-60 minutes
Make Claude create Word, PowerPoint, Excel and PDF files (Skills)
Turn on code execution and the built-in document skills so Claude hands you real .docx, .pptx, .xlsx and PDF files to download, in claude.ai, Claude Desktop or Claude Code.
Beginner5-15 minutes