How to stop Cursor and Claude Code from writing outdated API code with Context7
You ask your coding agent for a Next.js route, a Supabase sign-up form or a Cloudflare Worker, and it confidently writes code against an API that changed a year ago. Sometimes it invents a function that never existed. The model is not broken. Its training data is simply older than the library you i

Posted on Oct 29 • Originally published at dedupedai.com
You ask your coding agent for a Next.js route, a Supabase sign-up form or a Cloudflare Worker, and it confidently writes code against an API that changed a year ago. Sometimes it invents a function that never existed. The model is not broken. Its training data is simply older than the library you installed last week.
Context7 from Upstash fixes this by pulling current, version-specific documentation and code examples straight from the source and putting them into your agent's context at the moment it needs them. It works in Cursor, Claude Code, VS Code and Codex, and its docs carry manual setup for 30+ MCP clients.
This guide covers the one-command setup, manual setup for Cursor and Claude Code, the prompts that make it work well, and a rule so you never have to remember to ask.
npx ctx7 setup Enter fullscreen mode Exit fullscreen mode This authenticates you with OAuth, generates an API key and installs the right pieces for your agent. You choose between two modes:
To target one agent directly, add a flag:
npx ctx7 setup --cursor npx ctx7 setup --claude Enter fullscreen mode Exit fullscreen mode Changed your mind? npx ctx7 remove undoes the generated setup.
If you prefer to wire it yourself, Claude Code takes one command. The remote server version (nothing runs locally):
claude mcp add --scope user --header "Authorization: Bearer YOUR_API_KEY" --transport http context7 https://mcp.context7.com/mcp Enter fullscreen mode Exit fullscreen mode Or run the server locally through npx:
claude mcp add --scope user context7 -- npx -y @upstash/context7-mcp --api-key YOUR_API_KEY Enter fullscreen mode Exit fullscreen mode The --scope user flag makes Context7 available in every project, not just the current folder.
Open Cursor Settings, then Tools & MCP, then New MCP Server. Context7 recommends putting the config in ~/.cursor/mcp.json (global) or.cursor/mcp.json inside a project if you only want it there:
{ "mcpServers": { "context7": { "url": "https://mcp.context7.com/mcp", "headers": { "Authorization": "Bearer YOUR_API_KEY" } } } } Enter fullscreen mode Exit fullscreen mode Since Cursor 1.0 there is also a one-click install button on the Context7 docs page. If you want the local server instead, swap the url and headers for "command": "npx" and "args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"].
On Windows, the docs note one difference for local servers: run npx through cmd, with "command": "cmd" and "args": ["/c", "npx", "-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"].
Once installed, the simplest trigger is to end your prompt with use context7. Two examples straight from the README:
Name the library ID. If you already know the library, put its ID in the prompt and Context7 skips the matching step:
Implement basic authentication with Supabase. use library /supabase/supabase for API and docs. Enter fullscreen mode Exit fullscreen mode Name the version. Mention the version you are on and Context7 matches docs for that version:
How do I set up a Next.js 16 proxy? use context7 Enter fullscreen mode Exit fullscreen mode This is the part people skip, and it matters. A generic answer about "Next.js middleware" is exactly the stale code you were trying to avoid.
Typing use context7 every time gets old. If you installed with ctx7 setup, a skill already triggers Context7 for library questions. If you set it up manually, add a rule:
Always use Context7 when I need library/API documentation, code generation, setup or configuration steps without me having to explicitly ask. Enter fullscreen mode Exit fullscreen mode Use the CLI without MCP Context7 also works as a plain CLI, handy for checking what the agent will see:
npx ctx7 library "Next.js" "set up middleware" npx ctx7 docs /vercel/next.js "set up middleware" Enter fullscreen mode Exit fullscreen mode The first searches the index and returns matching library IDs. The second pulls docs for a given ID and question.
We keep a short, plain-English write-up of this exact workflow, with who it is for and what can go wrong: How to set up Context7 MCP so your agent uses current docs.
If you live in Cursor, our list of AI use cases for Cursor collects other repos that plug into it. And if Context7 made you curious about what else MCP can add to your editor, see our ranked list of the best open-source MCP servers.
Deduped tracks the AI repos people are actually building with and writes up how to use them. Repo: github.com/upstash/context7.
Get one email every Monday with the week's hottest AI repos and exactly how to use them: subscribe free at dedupedai.com