What it is
Context7 pulls up-to-date, version-specific documentation and code examples straight from the source and places them directly into your prompt. This is meant to avoid outdated code, hallucinated APIs and generic answers for old package versions. It works in two modes: CLI + Skills (a skill guides the agent to use ctx7 CLI commands, no MCP required) or MCP (a Context7 MCP server the agent calls natively).
Who it's for
- Developers using AI coding agents or editors (e.g. Cursor, Claude Code, OpenCode) who want current library documentation in their prompts
- Teams hitting outdated or hallucinated API output from LLMs
- Library authors who want their docs available through Context7 (via the Adding Libraries guide)
Requirements
Requirements
- Node.js 18 or newer (for the ctx7 CLI)
- An MCP-capable client if using MCP mode
- API key recommended for higher rate limits (free key at context7.com/dashboard)
Setup
Run the one-command setup
Authenticates via OAuth, generates an API key, and installs the appropriate skill. You can choose between CLI + Skills or MCP mode. Use --cursor, --claude, or --opencode to target a specific agent.
bashnpx ctx7 setupRemove the generated setup
To remove the setup later, run this command. If you globally installed the CLI with npm install -g ctx7, remove that package separately with npm uninstall -g ctx7.
bashnpx ctx7 removeManual MCP configuration
Use the Context7 server URL https://mcp.context7.com/mcp with your MCP client and pass your API key via the Authorization: Bearer YOUR_API_KEY header. Client-specific instructions are at https://context7.com/docs/resources/all-clients.
Examples
Add Context7 to a prompt
PromptCreate a Next.js middleware that checks for a valid JWT in cookies
and redirects unauthenticated users to `/login`. use context7Expected output: Appending 'use context7' makes the agent fetch current documentation and examples into the context.
Specify a library ID
PromptImplement basic authentication with Supabase. use library /supabase/supabase for API and docs.Expected output: Using the slash-style ID lets Context7 skip library matching and retrieve docs directly.
Request a specific version
PromptHow do I set up Next.js 14 middleware? use context7Expected output: Mentioning the version in the prompt makes Context7 match the appropriate version.
Add an automatic-use rule
PromptAlways use Context7 when I need library/API documentation, code generation, setup or configuration steps without me having to explicitly ask.Expected output: Add this rule in Cursor Settings > Rules, CLAUDE.md, or an equivalent so Context7 is used without explicit requests.
Pros & cons
Pros
- Pro:Provides up-to-date, version-specific docs and examples directly in the prompt, addressing outdated code and hallucinated APIs
- Pro:Two modes (CLI + Skills or MCP) and single-command setup via npx ctx7 setup
- Pro:Supports targeting library IDs and versions for precise retrieval
- Pro:Multiple packages available, including CLI, TypeScript SDK and Vercel AI SDK tools
Cons
- Con:API key recommended for higher rate limits, so unauthenticated use may be limited
- Con:Documentation is community-contributed; accuracy, completeness and security are not guaranteed
- Con:Only the MCP server source is in this repo; the API backend, parsing and crawling engines are private
Images
