Context7 MCP Server: What It Does, Its Tools, and Setup
October 28, 2026

The Context7 MCP server feeds your AI coding assistant current, version-specific library documentation, so it stops writing code against APIs that changed after its training data was collected. Upstash builds it, the server code is MIT-licensed, and it works with Claude Code, Cursor, VS Code, Codex and dozens of other clients.
Here's the short version:
- What it does: your assistant asks Context7 for docs on a library (Next.js, Supabase, Prisma) and gets back up-to-date snippets and code examples inside the prompt.
- What it exposes: two MCP tools,
resolve-library-idandquery-docs. - How to connect: the hosted server at
https://mcp.context7.com/mcp(nothing to install), or a local server run withnpx. - The API key: Context7's README calls it "recommended" for higher rate limits. You can also sign in with OAuth on remote connections.
Below: how it works, the exact setup commands from the official docs, and the caveats worth knowing before you rely on it.
What the Context7 MCP server does
Language models learn libraries from training data, and that data ages. Ask about a framework that shipped a new major version last month and you'll often get last year's API, or a method that never existed.
Context7 fixes the input rather than the model. The upstash/context7 README says it "pulls up-to-date, version-specific documentation and code examples straight from the source — and gives them to your coding agent."
In practice you add a phrase to your prompt:
Create a Next.js proxy that checks for a valid JWT in cookies
and redirects unauthenticated users to `/login`. use context7
The assistant calls Context7, pulls the relevant Next.js docs, and writes the code with those docs in its context window.
If MCP itself is new to you, our plain-English guide to MCP covers how servers and clients talk to each other.
Two modes: MCP or CLI + Skills
Context7 isn't MCP-only. The README lists two modes, and Context7's docs add plugins for Claude Code and Codex:
| Option | How it works | Needs MCP? |
|---|---|---|
| MCP | Registers a Context7 MCP server so your agent calls the doc tools natively | Yes |
| CLI + Skills | Installs a skill that tells your agent to fetch docs with ctx7 CLI commands | No |
| Claude Code / Codex plugin | Connects to the hosted MCP server; the Codex plugin also includes a documentation lookup skill | Uses the hosted server |
This guide focuses on the MCP mode, since that's what most people searching for "context7 mcp" want.
The two Context7 MCP tools
The server exposes exactly two tools. Per Context7's MCP client docs, clients list them under these names:
| Tool | What it does | Parameters |
|---|---|---|
resolve-library-id | Turns a library name into a Context7 ID like /vercel/next.js | libraryName (required), query (required) |
query-docs | Returns documentation and code examples for that ID | libraryId (required), query (required), language (optional) |
The flow is two steps. The assistant first resolves "Next.js" to /vercel/next.js, then queries the docs for your specific question. The docs say the language parameter ranks code examples in your language first, and libraryId can include a version, such as /vercel/next.js/v16.2.9.
Skip the lookup with a library ID
If you already know the library, put its ID in the prompt. The README's example:
Implement basic authentication with Supabase. use library /supabase/supabase for API and docs.
That skips resolve-library-id and goes straight to the docs. To target a version, just name it in the prompt ("How do I set up a Next.js 16 proxy? use context7") and Context7 matches it.
Make it automatic
Typing "use context7" every time gets old. The README suggests a rule in your agent's instructions, such as CLAUDE.md for Claude Code or Cursor's Rules settings:
Always use Context7 when I need library/API documentation, code generation, setup or configuration steps without me having to explicitly ask.
If you install with npx ctx7 setup, a skill is configured that triggers Context7 for library questions, so you don't need the rule.
How to install the Context7 MCP server
You have three routes. The fastest is the guided setup:
npx ctx7 setup
Per the README, this "authenticates via OAuth, generates an API key, and installs the appropriate skill," and lets you pick CLI + Skills or MCP mode. Add --claude, --cursor, or --opencode to target one agent. The ctx7 CLI needs Node.js 22.13 or newer. Run npx ctx7 remove to undo it.
If you'd rather configure by hand, you choose between remote and local.
Remote vs local
| Remote (hosted) | Local | |
|---|---|---|
| Endpoint | https://mcp.context7.com/mcp | npx -y @upstash/context7-mcp on your machine |
| Install | Nothing | Node.js (troubleshooting docs say v20+) |
| API key | Authorization: Bearer YOUR_API_KEY header | --api-key flag or CONTEXT7_API_KEY env var |
| OAuth | Yes, via /mcp/oauth | No, API key only |
Context7's troubleshooting page recommends remote if you hit Node.js problems: it "requires no local Node.js installation." The local server still calls Context7's hosted API for the docs themselves, so both need a network connection.
Context7 MCP in Claude Code
From Context7's client docs, the remote version:
claude mcp add --scope user --header "Authorization: Bearer YOUR_API_KEY" --transport http context7 https://mcp.context7.com/mcp
The local version:
claude mcp add --scope user context7 -- npx -y @upstash/context7-mcp --api-key YOUR_API_KEY
There's also a Context7 plugin. Per the Claude Code page in Context7's docs, run these inside Claude Code:
/plugin marketplace add upstash/context7
/plugin install context7@context7-marketplace
Then restart Claude Code, run /mcp, select Context7 and sign in through the browser. No API key needed. One catch: the docs say the plugin "does not read CONTEXT7_API_KEY," so on a headless or CI machine use npx ctx7 setup --claude or the manual command instead.
The --scope user flag makes Context7 available in every project. For what scopes and config files mean in Claude Code, see our Claude Code MCP configuration guide or Anthropic's own Claude Code MCP docs.
Context7 MCP in Cursor
Paste this into ~/.cursor/mcp.json (or .cursor/mcp.json in a project) for the remote server:
{
"mcpServers": {
"context7": {
"url": "https://mcp.context7.com/mcp",
"headers": {
"Authorization": "Bearer YOUR_API_KEY"
}
}
}
}
Or for the local server:
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
}
}
}
The docs also offer one-click install buttons for Cursor. Note that Cursor Cloud Agents don't read your local config; Context7's Cursor page has you add the server in the Cloud Agent UI, using a header named Context7-API-Key there.
VS Code, Codex, Claude Desktop and others
- VS Code: the easiest path is the Context7 VS Code extension, which registers the server and takes a key through the
context7.apiKeysetting. Manual setup goes in.vscode/mcp.jsonunder aserverskey with"type": "http". - OpenAI Codex:
codex mcp add context7 -- npx -y @upstash/context7-mcp --api-key YOUR_API_KEY, or a[mcp_servers.context7]block in~/.codex/config.toml. There's a Codex plugin too. - Claude Desktop: for remote, go to Settings > Connectors > Add Custom Connector and enter
https://mcp.context7.com/mcp. For local, editclaude_desktop_config.jsonwith the samenpxcommand as Cursor.
The README says the all-clients page covers manual setup for 30+ clients. That page includes Gemini CLI, Zed, Cline, Copilot CLI, JetBrains AI Assistant and a Docker setup.
The API key, rate limits and pricing
This is where most confusion comes from, so here's what Context7's own pages say:
- The key is optional but recommended. The README: "API Key Recommended: Get a free API key at context7.com/dashboard for higher rate limits." The API guide lists "low rate limits" without a key.
- OAuth replaces the key on remote connections. Change the URL from
/mcpto/mcp/oauthin a client that supports MCP OAuth. Local stdio connections can't use OAuth. - Keys start with
ctx7sk. The troubleshooting docs say to check that first if you get a401 Unauthorized. - The flag beats the env var. For the local server,
--api-keytakes precedence overCONTEXT7_API_KEYif both are set.
On cost: Context7's Plans & Pricing page says that, as of October 2026, a free account with an API key includes 1,000 API calls a month for the MCP server, CLI and APIs. When a free account runs out, requests stop until the next month, apart from a small daily bonus. Paid plans add more calls, private repositories and team seats. Allowances change, so check that page before you plan around a number.
Limits and caveats
Context7 solves a real problem, but it isn't magic. Know these before you trust it:
The docs are community-contributed. The README's disclaimer says Context7 "cannot guarantee the accuracy, completeness, or security of all library documentation," and that listed projects are maintained by their owners, not Context7. A library's entry is only as good as its source.
Only the MCP server is open source. The same disclaimer says the API backend, parsing engine and crawling engine "are private and not part of this repository." You can read and run the server code, but it depends on Upstash's hosted service for the docs.
Some of your query leaves your machine. Context7's data privacy page says your full prompt and code aren't sent. What is sent: a search query your assistant writes, the library name or ID, your API key if set, your client's name and version, the transport type, and your IP address (for rate limiting on hosted connections). Those queries are stored anonymously for benchmarking, except for Enterprise teamspaces. If you work on sensitive code, read that page first, and see our MCP security risks guide for the wider picture.
It costs context. Every doc lookup adds text to the conversation. On long sessions, that eats into the context window. Ask focused questions so query-docs returns one concept, not a whole manual.
The assistant decides when to call it. Without a rule or skill, it may not. If answers still look outdated, check /mcp (in Claude Code) to confirm the server is connected, then add the rule above.
For other servers that pair well with Context7, see our roundup of the best MCP servers.
FAQ
What is the Context7 MCP server?
It's an MCP server from Upstash that gives AI coding assistants current, version-specific documentation and code examples for libraries and frameworks. It works with any MCP client, including Claude Code, Cursor, VS Code and Codex.
Is Context7 free?
Context7 has a free plan. Per its plans page, a free account with an API key gets a monthly allowance of API calls, and paid plans add more. Check Context7's Plans & Pricing page for current allowances.
Do I need an API key for Context7?
No, but it's recommended. Without one you get lower rate limits. On remote connections you can sign in with OAuth instead, and the Claude Code plugin uses a browser sign-in with no key.
What tools does the Context7 MCP server provide?
Two: resolve-library-id, which finds a library's Context7 ID, and query-docs, which returns documentation and code examples for that ID.
What's the Context7 MCP server URL?
The hosted endpoint is https://mcp.context7.com/mcp. For OAuth, use https://mcp.context7.com/mcp/oauth.
Should I use the remote or local Context7 server?
Remote, unless you have a reason not to. It needs no Node.js and supports OAuth. Local runs the server process on your machine, but it still fetches docs from Context7's hosted service.
Key takeaways
- Context7 puts current library docs into your assistant's context, which cuts down on outdated code and made-up APIs.
- It exposes two tools:
resolve-library-idandquery-docs. Skip the first by naming a library ID like/vercel/next.js. npx ctx7 setupis the fastest install. For manual setup, the remote server athttps://mcp.context7.com/mcpis the simplest choice.- The API key is optional but raises your limits. OAuth works on remote connections; local needs a key.
- Treat the docs as community-sourced. Check what gets sent in the privacy docs before using it on sensitive code.
Getting an MCP server configured is usually where a good AI setup stalls. If you'd rather start from a configuration someone already got working, Taku mirrors a working AI setup into a desktop workspace and runs it, so you skip rebuilding their environment first. Taku is in Beta, and the Mac app is available now.