How to stop Cursor and Claude Code from writing outdated API code with Context7 Upstash's Context7 pulls current, version-specific library documentation and code examples into coding agents like Cursor, Claude Code, VS Code and Codex via MCP, aiming to stop agents from writing against outdated or invented APIs. Setup is a single `npx ctx7 setup` command that handles OAuth and API key generation, or manual MCP server registration for Claude Code and Cursor, with prompts ending in `use context7` triggering doc lookups through the `resolve-library-id` and `query-docs` tools. 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 https://github.com/upstash/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. ctx7 CLI requires it From any terminal: npx ctx7 setup 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 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 Or run the server locally through npx: claude mcp add --scope user context7 -- npx -y @upstash/context7-mcp --api-key YOUR API KEY 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" } } } } 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: Create a Next.js proxy that checks for a valid JWT in cookies and redirects unauthenticated users to /login. use context7 Configure a Cloudflare Worker script to cache JSON API responses for five minutes. use context7 Behind the scenes the MCP server exposes two tools. resolve-library-id turns a library name like Next.js into a Context7 ID such as /vercel/next.js . query-docs then fetches the relevant documentation and code examples for your question, and it accepts an optional language parameter so examples in your language rank first. 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. 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 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: CLAUDE.md The rule the README suggests: Always use Context7 when I need library/API documentation, code generation, setup or configuration steps without me having to explicitly ask. 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" 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 https://dedupedai.com/use-cases/upstash-context7/stop-agent-using-outdated-apis/?utm source=devto&utm medium=article&utm campaign=howto context7 . If you live in Cursor, our list of AI use cases for Cursor https://dedupedai.com/use-cases/a/cursor/?utm source=devto&utm medium=article&utm campaign=howto context7 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 https://dedupedai.com/best-ai-repos-for/mcp-servers/?utm source=devto&utm medium=article&utm campaign=howto context7 . Deduped tracks the AI repos people are actually building with and writes up how to use them. Repo: github.com/upstash/context7 https://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 https://dedupedai.com/join/?utm source=devto&utm medium=article&utm campaign=howto context7