{"slug": "how-to-stop-cursor-and-claude-code-from-writing-outdated-api-code-with-context7", "title": "How to stop Cursor and Claude Code from writing outdated API code with Context7", "summary": "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.", "body_md": "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.\n\n[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.\n\nThis 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.\n\n`ctx7` CLI requires it)\nFrom any terminal:\n\n```\nnpx ctx7 setup\n```\n\nThis authenticates you with OAuth, generates an API key and installs the right pieces for your agent. You choose between two modes:\n\nTo target one agent directly, add a flag:\n\n```\nnpx ctx7 setup --cursor\nnpx ctx7 setup --claude\n```\n\nChanged your mind? `npx ctx7 remove` undoes the generated setup.\n\nIf you prefer to wire it yourself, Claude Code takes one command. The remote server version (nothing runs locally):\n\n```\nclaude mcp add --scope user --header \"Authorization: Bearer YOUR_API_KEY\" --transport http context7 https://mcp.context7.com/mcp\n```\n\nOr run the server locally through npx:\n\n```\nclaude mcp add --scope user context7 -- npx -y @upstash/context7-mcp --api-key YOUR_API_KEY\n```\n\nThe `--scope user` flag makes Context7 available in every project, not just the current folder.\n\nOpen 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:\n\n```\n{\n  \"mcpServers\": {\n    \"context7\": {\n      \"url\": \"https://mcp.context7.com/mcp\",\n      \"headers\": {\n        \"Authorization\": \"Bearer YOUR_API_KEY\"\n      }\n    }\n  }\n}\n```\n\nSince 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\"]`.\n\nOn 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\"]`.\n\nOnce installed, the simplest trigger is to end your prompt with `use context7`. Two examples straight from the README:\n\n```\nCreate a Next.js proxy that checks for a valid JWT in cookies\nand redirects unauthenticated users to /login. use context7\nConfigure a Cloudflare Worker script to cache\nJSON API responses for five minutes. use context7\n```\n\nBehind 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.\n\n**Name the library ID.** If you already know the library, put its ID in the prompt and Context7 skips the matching step:\n\n```\nImplement basic authentication with Supabase. use library /supabase/supabase for API and docs.\n```\n\n**Name the version.** Mention the version you are on and Context7 matches docs for that version:\n\n```\nHow do I set up a Next.js 16 proxy? use context7\n```\n\nThis 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.\n\nTyping `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:\n\n`CLAUDE.md`\nThe rule the README suggests:\n\n```\nAlways use Context7 when I need library/API documentation, code generation, setup or configuration steps without me having to explicitly ask.\n```\n\nContext7 also works as a plain CLI, handy for checking what the agent will see:\n\n```\nnpx ctx7 library \"Next.js\" \"set up middleware\"\nnpx ctx7 docs /vercel/next.js \"set up middleware\"\n```\n\nThe first searches the index and returns matching library IDs. The second pulls docs for a given ID and question.\n\nWe 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).\n\nIf 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).\n\n*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).*\n\n**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)**", "url": "https://wpnews.pro/news/how-to-stop-cursor-and-claude-code-from-writing-outdated-api-code-with-context7", "canonical_source": "https://dev.to/dedupedai/how-to-stop-cursor-and-claude-code-from-writing-outdated-api-code-with-context7-53p1", "published_at": "2026-10-29 00:29:09+00:00", "updated_at": "2026-10-29 00:41:48.842997+00:00", "lang": "en", "topics": ["ai-tools", "ai-agents", "agent-protocols", "developer-tools", "ai-products"], "entities": ["Upstash", "Context7", "Cursor", "Claude Code", "VS Code", "Codex", "Next.js", "Supabase"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/how-to-stop-cursor-and-claude-code-from-writing-outdated-api-code-with-context7", "markdown": "https://wpnews.pro/news/how-to-stop-cursor-and-claude-code-from-writing-outdated-api-code-with-context7.md", "text": "https://wpnews.pro/news/how-to-stop-cursor-and-claude-code-from-writing-outdated-api-code-with-context7.txt", "jsonld": "https://wpnews.pro/news/how-to-stop-cursor-and-claude-code-from-writing-outdated-api-code-with-context7.jsonld"}}