Context7 MCP: Access Up-to-Date Documentation in Claude Code
Integrate Context7 MCP to access real-time official documentation for any library or framework. Never rely on outdated training data again.
One of the biggest challenges with AI coding assistants is knowledge cutoff—Claude’s training data has a specific end date, meaning it may not know about recent API changes, new features, or deprecated methods.
Context7 MCP solves this by providing Claude with real-time access to official documentation for any library or framework.
Updated October 21, 2026: Setup now runs through
npx ctx7 setup --claudeor the Context7 plugin, the hosted endpoint ishttps://mcp.context7.com/mcp, and the MCP tools areresolve-library-idandquery-docs. The configuration examples below are checked against Context7’s official docs and the Claude Code MCP reference. For the full tool and pricing reference, see the companion guide, Context7 MCP: Up-to-Date Docs for AI Assistants.
The Problem: Outdated Knowledge
User: "How do I use the new Next.js App Router?"
Claude (without Context7):
→ May reference older Pages Router patterns
→ Missing new server components syntax
→ Outdated API examples
→ Deprecated patterns still suggested
User: "How do I use the new Next.js App Router?"
Claude (with Context7):
→ Fetches current Next.js documentation
→ Uses latest App Router patterns
→ Correct server components syntax
→ Up-to-date best practices
What is Context7?
Context7 is an MCP (Model Context Protocol) server that:
- Fetches current documentation from official sources, indexed and kept fresh by Context7
- Resolves a library name to a stable ID, so answers come from the right project and version
- Covers a large, continuously refreshed catalog of public libraries — search it with
npx ctx7 library <name> "<task>" - Supports private repositories on the Pro and Enterprise plans
┌─────────────────────────────────────────────────────────────┐
│ Context7 Architecture │
│ │
│ ┌───────────┐ ┌───────────┐ ┌───────────┐ │
│ │ Claude │ ──► │ Context7 │ ──► │ Official │ │
│ │ Code │ │ MCP │ │ Docs │ │
│ └───────────┘ └───────────┘ └───────────┘ │
│ │ │ │ │
│ │ ▼ │ │
│ │ ┌───────────┐ │ │
│ │ │ Index │◄───────────┘ │
│ │ └───────────┘ │
│ │ │ │
│ │ ▼ │
│ └──────────► Enriched Response │
│ │
└─────────────────────────────────────────────────────────────┘
Setting Up Context7
Step 1: Add Context7
The quickest route is Context7’s own CLI, which requires Node.js 22.13 or newer:
npx ctx7 setup --claude
It signs you in with the OAuth device flow, generates an API key, and installs the matching skill. It offers an MCP-server mode and a CLI + Skills mode that needs no MCP server at all.
To add the MCP server by hand instead, Context7’s official Claude Code instructions give these two forms:
# Remote server (hosted, recommended)
claude mcp add --scope user \
--header "Authorization: Bearer YOUR_API_KEY" \
--transport http context7 https://mcp.context7.com/mcp
# Local stdio server
claude mcp add --scope user context7 \
-- npx -y @upstash/context7-mcp --api-key YOUR_API_KEY
Use --scope project instead of --scope user to write the server into .mcp.json and share it with your team through version control. (local — the default — and user both live in ~/.claude.json; there is no global scope.)
Step 2: Verify Installation
claude mcp get context7
claude mcp list
claude mcp list prints a health status next to each server — ✔ Connected, ! Needs authentication, or ✘ Failed to connect with the failure detail. A project-scoped server from .mcp.json stays at ⏸ Pending approval until you approve it in an interactive session.
Step 3: Test the Integration
"How do I set up a Next.js 16 proxy? use context7"
Claude resolves the library, fetches the current documentation, and answers from it.
Using Context7
Automatic Documentation Fetch
ctx7 setup installs a skill that fires on library questions without you saying anything. To wire the same behaviour up by hand, add a rule to CLAUDE.md:
Always use Context7 when I need library/API documentation, code generation,
setup or configuration steps without me having to explicitly ask.
Then:
User: "How do I set up Prisma with PostgreSQL?"
Claude:
→ resolve-library-id(libraryName: "Prisma", query: "set up with PostgreSQL")
→ query-docs(libraryId: "/prisma/prisma", query: "set up with PostgreSQL")
→ Answers from the documentation it just fetched
Explicit Documentation Request
You can explicitly request documentation by adding use context7 to the prompt:
"use context7 for the React docs on server components,
then explain how to use them with suspense."
If you already know the library ID, name it and Context7 skips the resolution step:
"use context7 with /vercel/next.js for app router setup"
Library-Specific Queries
Context7 understands library context:
"Using the latest Tailwind CSS docs, how do I set up
the new dark mode with class-based switching?"
Supported Libraries
Context7 indexes a large, continuously refreshed catalog of public libraries. Each entry carries a library ID, an indexed code-snippet count, a source-reputation rating, a benchmark score, and any version-specific IDs. Search the live index with npx ctx7 library <name> "<what you want to do>" or browse it at context7.com. Commonly used entries include:
Frontend
React, Next.js, Vue.js, Svelte, Angular, Tailwind CSS
Backend
Node.js, Express, Fastify, NestJS, Django, FastAPI
Database
Prisma, Drizzle, TypeORM, Mongoose, PostgreSQL, MongoDB
DevOps
Docker, Kubernetes, GitHub Actions, Vercel, AWS
Library IDs follow an /owner/project shape, and Context7’s own documentation uses examples such as /vercel/next.js, /prisma/prisma, /supabase/supabase and /mongodb/docs. Versioned IDs add the release: /vercel/next.js/v16.2.9. Don’t guess an ID — run resolve-library-id (or npx ctx7 library) and use what it returns, with the library’s official punctuation (Next.js, not nextjs).
Coverage differs per library and changes as the index refreshes, so check the snippet count and source reputation in the resolver output rather than assuming a library is complete.
Use Cases
1. Learning New Frameworks
"I'm new to SvelteKit. Using current documentation,
explain the folder structure and routing conventions."
Claude fetches SvelteKit docs and explains with accurate, current information.
2. Migration Assistance
"We're migrating from Create React App to Vite.
What are the current steps and configuration needed?"
Claude references current Vite migration guide.
3. API Integration
"How do I implement Stripe Checkout with the latest
API version? Include webhook handling."
Claude fetches current Stripe documentation with latest API patterns.
4. Troubleshooting
"I'm getting 'hydration mismatch' in Next.js 16.
What are the current best practices to fix this?"
Claude references current Next.js troubleshooting docs.
Context7 vs Training Data
| Aspect | Training Data | Context7 |
|---|---|---|
| Currency | Cutoff date | Real-time |
| Accuracy | May be outdated | Current |
| Completeness | Limited | Full docs |
| API versions | Historical | Latest |
| Deprecations | May suggest old | Knows deprecated |
When Context7 Helps Most
High value:
- Rapidly evolving frameworks (Next.js, React, etc.)
- Libraries with frequent breaking changes
- New features released after training cutoff
- Deprecated API identification
Lower value:
- Stable languages (C, SQL basics)
- Fundamental programming concepts
- Well-established patterns
Configuration Options
Context7’s MCP server has no client-side cache, custom-source or rate-limit configuration block. What you actually configure is the MCP server entry, the authentication, and which mode you run in.
The MCP server entry
A remote entry in .mcp.json (project scope) or ~/.claude.json (local and user scope) looks like this:
{
"mcpServers": {
"context7": {
"type": "http",
"url": "https://mcp.context7.com/mcp",
"headers": {
"Authorization": "Bearer YOUR_API_KEY"
}
}
}
}
A remote entry needs an explicit type. Claude Code reads an entry with a url but no type as a stdio server and skips it with an error.
OAuth instead of an API key
Swap the endpoint to use OAuth on clients that implement the MCP OAuth specification:
- "url": "https://mcp.context7.com/mcp"
+ "url": "https://mcp.context7.com/mcp/oauth"
OAuth is for remote HTTP connections only; a local stdio connection authenticates with --api-key. In Claude Code, run claude mcp login context7 (add --no-browser over SSH) to complete the flow.
Private documentation
Private repositories are a Context7 account feature, not a config file: add them from the dashboard on the Pro or Enterprise plan. Parsing is billed per token. For a fully self-managed deployment, ctx7 setup --base-url https://context7.internal.example points the setup at an on-premise instance.
CLI + Skills instead of MCP
ctx7 setup --cli --claude installs a docs skill into ~/.claude/skills that drives the ctx7 library and ctx7 docs commands directly, with no MCP server registered at all. Add --project to scope either mode to the current project.
Integration with Workflows
Development Workflow
"Implement user authentication using the latest
Auth.js (NextAuth) patterns for Next.js 16."
Claude:
→ Fetches current Auth.js documentation
→ Identifies App Router patterns
→ Implements with current best practices
→ Includes proper TypeScript types
Code Review
"Review this Prisma schema. Check against current
best practices from the official documentation."
Claude:
→ Fetches Prisma schema documentation
→ Compares against current recommendations
→ Identifies improvements
→ Suggests updates if patterns changed
Debugging
"I'm getting a React 19 error about refs in
function components. What's the current approach?"
Claude:
→ Fetches React 19 refs documentation
→ Explains current ref patterns
→ Provides migration steps if needed
Combining with Other MCPs
Context7 + Memory MCP
"Using current React documentation, implement our
component following patterns we saved in memory."
Claude:
→ Fetches current React docs
→ Retrieves saved patterns from memory
→ Combines both for implementation
Context7 + GitHub MCP
"Create a PR implementing the new Prisma relations
feature following current documentation."
Claude:
→ Fetches current Prisma docs
→ Implements feature
→ Creates PR with proper description
Context Considerations
Token Usage
Context7 responses add to context:
Without Context7:
└── Claude's knowledge only
With Context7:
├── Claude's knowledge
└── + Fetched documentation (varies by query)
Recommendation: Use Context7 for specific queries, not every prompt.
Quota Awareness
Each resolve-library-id and query-docs call spends one API call from your plan’s monthly allowance. On the Free plan that allowance is 1,000 calls per month; Pro includes 2,000 per seat and bills overage at $5 per 1,000. So a resolve-then-query pair costs two calls:
"use context7 for Prisma relations"
→ resolve-library-id (1 call)
→ query-docs (1 call)
"use context7 with /prisma/prisma for relations"
→ query-docs (1 call) ← naming the ID skips the resolve step
Monitor usage in the Context7 dashboard.
Troubleshooting
Documentation Not Fetching
- Check the server connected:
claude mcp get context7orclaude mcp list - If the status is
! Needs authentication, runclaude mcp login context7 - If it is
⏸ Pending approval, approve the.mcp.jsonserver in an interactive session - Check you haven’t hit the monthly API-call limit in the dashboard
- Try an explicit request: “use context7 for X”
Outdated Information Returned
- Pass a versioned library ID (
/vercel/next.js/v16.2.9) rather than the bare ID - Confirm you resolved the right project — several packages can share a name
- Report a stale or mis-parsed library through Context7’s troubleshooting guide
Missing Library
- Search the index yourself:
npx ctx7 library <name> "<task>" - Use the library’s official punctuation —
Next.js, notnextjs - Submit a public library through Adding Libraries; for internal docs, add a private repository on the Pro or Enterprise plan
Best Practices
1. Be Specific About Versions
Good:
"Using Next.js 16 App Router documentation..."
Avoid:
"Using Next.js documentation..."
2. Specify What You Need
Good:
"From the Prisma docs, explain the new relation mode options"
Avoid:
"Tell me about Prisma"
3. Combine with Context
"Given our PostgreSQL setup, use current Prisma docs
to implement the user-posts relationship."
4. Verify Currency
"Confirm this pattern is current according to React docs,
then implement it."
Getting Started
Today:
- Run
npx ctx7 setup --claude, or install the plugin with/plugin marketplace add upstash/context7and/plugin install context7@context7-marketplace - Test with one library query
- Compare output with and without Context7
This week:
- Identify frequently-used libraries and note their library IDs
- Add the Context7 rule to
CLAUDE.mdso it fires without being asked - Integrate into development workflow
This month:
- Establish team patterns for Context7 usage
- Share the server through a project-scoped
.mcp.jsonif the whole team needs it - Watch your API-call usage in the dashboard and size the plan to it
Context7 eliminates the knowledge gap between AI training and current documentation. Stop guessing about API changes and work with confidence that Claude has the latest information.
Sources: Context7 docs for Claude Code, MCP Clients, Context7 on GitHub, Claude Code MCP documentation, MCP Protocol