docs/clients/claude-code.mdx
Context7 integrates with Claude Code to provide current library documentation instead of relying on training data. Claude Code supports skills, agents, and commands that make documentation lookups more powerful.
Run the setup command to configure Context7 for Claude Code:
npx ctx7 setup --claude
This flow authenticates via OAuth, generates an API key, and installs the appropriate skill. You can choose between CLI or MCP mode.
<Tip> If you're setting up Claude Code on a remote server, headless VM, or over SSH, use an existing API key instead:npx ctx7 setup --claude --api-key YOUR_API_KEY
The default OAuth flow redirects back to localhost, which only works when the browser can reach the same machine that's running ctx7 setup.
</Tip>
Create or manage API keys in the Context7 dashboard. For manual MCP installation or other configuration options, see All MCP Clients.
With ctx7 setup, a skill is installed that triggers automatically when you ask about libraries — no need to say "use context7". You can also invoke it explicitly:
use context7 to show me how to set up middleware in Next.js 15
use context7 for Prisma query examples with relations
use context7 for the Supabase syntax for row-level security
If you know the library ID, use it directly to skip resolution:
use context7 with /supabase/supabase for authentication docs
use context7 with /vercel/next.js for app router setup
The full Context7 plugin for Claude Code includes more than just the MCP server:
<CardGroup cols={2}> <Card title="MCP Server" icon="server"> The tools for fetching documentation (`resolve-library-id`, `query-docs`) </Card> <Card title="Skills" icon="sparkles"> Auto-triggers documentation lookups when you ask about libraries </Card> <Card title="Agents" icon="robot"> A `docs-researcher` agent for focused lookups that keep context lean </Card> <Card title="Commands" icon="terminal"> `/context7:docs` for manual documentation queries </Card> </CardGroup>The plugin is available from the Context7 marketplace. Run these commands in Claude Code:
/plugin marketplace add upstash/context7
/plugin install context7-plugin@context7-marketplace
This adds the Context7 marketplace and installs the plugin with skills, agents, and commands.
This skill triggers automatically when you ask about libraries, frameworks, or need code examples. You don't need to type "use context7" — the skill recognizes when documentation would help.
<AccordionGroup> <Accordion title="What triggers the skill"> - Setup questions: "How do I configure Next.js middleware?" - Code generation: "Write a Prisma query for user relations" - API references: "What are the Supabase auth methods?" - Framework mentions: React, Vue, Svelte, Express, Tailwind, etc. </Accordion> <Accordion title="How it works"> 1. **Resolve**: Finds the library ID using `resolve-library-id` with your question as context 2. **Select**: Picks the best match based on name accuracy and quality scores 3. **Fetch**: Calls `query-docs` with the library ID and your specific question 4. **Return**: Provides code examples and explanations from current documentation </Accordion> </AccordionGroup>When you're in the middle of a long task and don't want documentation tool calls cluttering your context, spawn the docs-researcher agent. It runs in a separate context and returns just the answer.
The agent uses the same tools (resolve-library-id and query-docs) but runs on a lighter model (Sonnet) to keep things fast.
| Scenario | Use |
|---|---|
| Deep into a task with long context | Agent |
| Want to avoid context bloat | Agent |
| Context is short | Inline tools |
| Want docs visible in conversation | Inline tools |
Manual command for documentation lookups.
Format:
/context7:docs <library> [query]
Examples:
<Tabs> <Tab title="Basic" icon="search"> ``` /context7:docs react hooks /context7:docs next.js authentication /context7:docs prisma relations ``` </Tab> <Tab title="With Library ID" icon="link"> ``` /context7:docs /vercel/next.js app router /context7:docs /supabase/supabase row level security ```Using a library ID directly skips the resolution step. </Tab> </Tabs>
When to use: