Remote OpenClaw Blog
Context7 MCP Server: Install and Use It in Claude Code
7 min read ·
Context7 is an open-source MCP server from Upstash that pulls up-to-date, version-specific documentation and code examples for thousands of libraries and injects them directly into your AI assistant's context. It exists because LLMs train on data that is months or years old, so without it they hallucinate APIs that never existed and suggest deprecated methods; with it, adding "use context7" to a prompt fetches current docs straight from the source.
What Is the Context7 MCP Server?
The Context7 MCP server is a Model Context Protocol server, built and maintained by Upstash, that delivers version-specific library documentation and working code examples into LLM prompts on demand. The upstash/context7 repository launched in March 2025, is MIT licensed, and has grown past 58,000 GitHub stars as of July 2026, making it one of the most-starred MCP servers in existence.
It works over the open Model Context Protocol, so the same server plugs into Claude Code, Cursor, Codex, VS Code, Claude Desktop, and any other MCP-capable client. You can run it locally via npx or connect to the hosted endpoint at https://mcp.context7.com/mcp. Context7 is also listed in our MCP server directory, where you can compare it against similar documentation servers: see the Context7 MCP listing.
Why Context7 Exists
Context7 exists because LLMs rely on training data with a fixed cutoff, which makes them confidently generate code against old library versions. The project README describes the failure mode directly: without current docs, models produce examples based on year-old training data, suggest APIs that do not exist, and give generic answers for outdated package versions.
Instead of hoping the model remembers the right signature for Next.js middleware or a Prisma relation query, Context7 fetches the documentation for the exact library and version you are using and places it in the prompt before the model answers. That shifts the model from recalling APIs to reading them, which is the same reason documentation-focused MCP servers have become a default part of coding agent setups. For background on how MCP fits into agent workflows, see our guide to how MCP servers work.
How to Install Context7 in Claude Code
The recommended install for Claude Code is the one-line setup CLI, which authenticates via OAuth device flow, generates an API key, and installs a documentation skill. As of July 2026, the Context7 docs list three supported paths for Claude Code.
# 1. Recommended: automated setup (OAuth + API key + skill)
npx ctx7 setup --claude
# 2. Manual: local MCP server over stdio
claude mcp add --scope user context7 -- npx -y @upstash/context7-mcp --api-key YOUR_API_KEY
# 3. Manual: hosted remote server over HTTP
claude mcp add --scope user --header "CONTEXT7_API_KEY: YOUR_API_KEY" \
--transport http context7 https://mcp.context7.com/mcp
There is also a Claude Code plugin that bundles the MCP server with a skill, a docs-researcher agent, and a /context7:docs command. Install it from inside Claude Code with /plugin marketplace add upstash/context7 followed by /plugin install context7@context7-marketplace. The local server requires Node.js 18 or newer, and npx ctx7 remove reverses the automated setup. For the general mechanics of adding servers, Anthropic's Claude Code MCP docs cover scopes and transports.
How to Use Context7 in Prompts
The simplest way to use Context7 is to append "use context7" to any coding prompt, which tells your assistant to fetch current documentation before answering. If you installed via ctx7 setup or the plugin, the bundled skill triggers automatically on library questions, so you often do not need the phrase at all.
use context7 to show me how to set up middleware in Next.js 15
use context7 for Prisma query examples with relations
use context7 with /supabase/supabase for authentication docs
Under the hood the server exposes two tools. resolve-library-id matches a library name like "next.js" to a Context7 ID like /vercel/next.js, and query-docs retrieves documentation for that ID scoped to your question. Referencing a library ID directly in your prompt skips the resolution step. With the plugin installed you also get /context7:docs <library> [query] for manual lookups and the docs-researcher agent, which runs lookups in a separate context so long documentation pulls do not clutter your main session.
API Keys and Rate Limits
Context7 works without an API key, but anonymous requests share a lower rate limit; a free API key from the Context7 dashboard raises it. The key is passed as the CONTEXT7_API_KEY header on the remote server, as an --api-key flag on the local server, or as an environment variable the Claude Code plugin reads automatically.
For remote HTTP connections, Context7 also supports OAuth 2.0: point your client at https://mcp.context7.com/mcp/oauth instead of /mcp and the client handles authorization. OAuth is only available for remote connections; local stdio installs use API key authentication. Treat the key like any other credential and keep it in your shell profile or client config rather than committed files. Our guide on securing MCP server connections covers the broader checklist.
Context7 Alternatives
Context7 is the most popular documentation MCP server, but several alternatives in our directory solve the same stale-docs problem with different tradeoffs.
| Server | What it does | Best for |
|---|---|---|
| Context7 | Version-specific docs and code examples injected on demand | General library and framework documentation |
| Docfork | Fresh documentation for 9,000+ libraries in a single tool call, per the project | Minimizing tool-call round trips |
| Ref Tools | Token-efficient access to technical documentation | Keeping context windows small |
| Microsoft Learn MCP | Official real-time access to Microsoft Learn docs and samples | Azure, .NET, and Microsoft stack work |
If you want an assistant to discover servers like these on its own, see how to find MCP servers from Claude Code.
Limitations and Tradeoffs
Context7 only helps with libraries that are indexed, and coverage quality varies by project. If a library is missing or its docs are thin, you can submit it for indexing, but until then the model falls back on training data. Injected documentation also consumes context window space, so very broad queries can pull in more tokens than the answer needs; the docs-researcher agent pattern exists specifically to contain that cost.
You should also weigh the dependency itself. The hosted endpoint is a third-party service with rate limits on the anonymous and free tiers, and local installs still call out to Context7's index. For fully offline work, a local-first docs server is a better fit. Finally, Context7 improves documentation accuracy, not reasoning: it will not fix a flawed architecture decision, it just stops the model from inventing APIs while executing one. When you do not need external docs at all, skipping the server keeps your tool list lean, a point our build-your-own MCP server guide makes in more depth.
Related Guides
- OpenClaw MCP Servers Explained
- How to Find MCP Servers from Claude Code
- Securing Your MCP Server Connections
- How to Build Your Own MCP Server
Go deeper
The operator playbooks
Production-ready PDF guides for OpenClaw and Hermes Agent — $19.99 each.
Skills for this topic
Browse all skills →Frequently Asked Questions
How do I add Context7 to Claude Code?
Run npx ctx7 setup --claude for the automated flow, or add it manually with claude mcp add --scope user context7 -- npx -y @upstash/context7-mcp --api-key YOUR_API_KEY . A remote HTTP option connects to https://mcp.context7.com/mcp with your key in a header.
What does "use context7" do in a prompt?
Adding "use context7" tells your assistant to call the Context7 tools, resolve the library you mentioned to its Context7 ID, and fetch current documentation before answering. With the Context7 skill or plugin installed, this happens automatically on most library questions.

