Context7 MCP for Claude Code: Current, Version-Matched Docs Instead of Outdated API Code (2-Minute Setup)

Context7 MCP: Current library docs in Claude Code

Last Verified: October 2026 — commands and setup modes checked against the upstash/context7 docs

Claude Code writes the code with confidence, you run it, and it fails: the method was renamed a few versions ago, or the config flag no longer exists. It answers from training data by default, so library APIs, framework syntax, and CLI flags can be months or years out of date.

Context7 fixes that by fetching current, version-matched documentation for whatever library you’re actually using, on demand, instead of relying on what the model memorized during training. Setup takes about 2 minutes.

How it works

Youask in plain English
Claude Codepicks the right tool
Context7 MCPRemote (HTTP) · sign-in: None to start
Real data backCurrent, version-matched library documentation

Measured by us · October 22, 2026

Windows 11 laptop (build 26200), Node 24.18.1. Our own script sent the two requests any MCP client makes to learn what a server offers (initialize, then tools/list) and timed the answer. No Claude Code session, no account, no API key.

What we checkedResult
Server versionContext7 4.4.3
Tools it adds2: resolve-library-id, query-docs
Size of the tool definitions5.2 KB, about 1,330 tokens
Time to answer0.5 s (hosted, nothing to download)
Change since our October 3 runSame tools; definitions about 7% larger (1,240 → 1,330 tokens)

Tokens are estimated as characters ÷ 4, the same way as in our other measured posts; we didn’t run a tokenizer. This is what the server costs when it loads, not a whole session, and Claude Code’s tool search can defer MCP tool definitions until they’re needed, so treat it as the worst case.

Quick Start

Connect the remote server (no local install needed):

claude mcp add --scope user --transport http context7 https://mcp.context7.com/mcp

Restart Claude Code, then ask something like “show me a FastAPI example with async endpoints” — if it’s working, the answer will reference current syntax instead of guessing. Total time: about 2 minutes.

Prefer a guided setup? npx ctx7 setup --claude signs you in, creates a free API key, and writes the MCP entry plus a Context7 rule and skill for Claude Code in one go.

⚡ Copy This Prompt: Let Claude Code Install and Verify It For You

Skip Steps 1-3 below and hand the whole thing to the agent instead:

You have access to the `claude mcp` CLI in this project. Do the following and report back — do not tell me it's done unless step 3 actually confirms it:

1. Run `claude mcp list` to see what's already configured.
2. Add Context7: `claude mcp add --scope user --transport http context7 https://mcp.context7.com/mcp`
3. Run `claude mcp list` again and confirm context7 shows as Connected.
4. Prove it works: use the context7 tools to look up current documentation for [NAME A LIBRARY YOU ACTUALLY USE, e.g. "Next.js" or "Prisma"] and summarize one recent API detail. If step 3 or 4 fails, tell me the exact error instead of reporting success.

This works because Claude Code can run its own CLI commands and then immediately use the newly connected server — so it proves it can actually pull fresh docs instead of just confirming the config exists.

Context7's homepage, captured October 2026.
Context7’s homepage, captured October 2026.
On this page (8 sections)
  1. Before You Add Context7
  2. Step-by-Step Setup
  3. What Each Piece Does
  4. MCP or CLI + Skills? The Lower-Token Option
  5. Verify It’s Actually Pulling Fresh Docs
  6. Common Mistakes to Avoid
  7. Q&A
  8. Official Resources

Before You Add Context7

Requirement Why You Need It Time
Claude Code installed Provides the claude mcp command used to register the server 0 min
Nothing else for basic use The remote server works unauthenticated at low volume 0 min
A free API key (optional) Removes rate limits and unlocks private-repo lookups — get one at context7.com/dashboard ~1 min

Step-by-Step Setup

Prefer to do it by hand instead of delegating to the agent? Here’s the manual version.

Step 1 — Add the remote server

~1 min

--scope user makes it available in every project on your machine, not just the current one:

claude mcp add --scope user --transport http context7 https://mcp.context7.com/mcp
Terminal: claude mcp add --scope user --transport http context7 https://mcp.context7.com/mcp; then claude mcp list
Real run, October 2026, no API key: Context7 connects straight away.

Step 2 — Add an API key to raise the rate limit (optional)

~1 min

Get a free key at context7.com/dashboard, then pass it as a header on the same command:

claude mcp add --scope user --header "CONTEXT7_API_KEY: YOUR_API_KEY" --transport http context7 https://mcp.context7.com/mcp

Step 3 — Or run it locally via npx instead

~1 min

If you’d rather not send lookups to the hosted endpoint, run the same server as a local stdio process:

claude mcp add --scope user context7 -- npx -y @upstash/context7-mcp --api-key YOUR_API_KEY

Step 4 — Restart and use it

~1 min

Run claude to start a fresh session, then just ask a normal question about a library — Context7 kicks in automatically when it’s relevant, no special syntax required.

Terminal connected to a fresh open book, with an old dusty book set aside
Current, version-matched docs instead of whatever the model remembers.

What Each Piece Does

Piece What It Does
Remote HTTP endpoint (mcp.context7.com/mcp) Hosted server, no local process to keep running
CONTEXT7_API_KEY header Raises your rate limit and enables private-repo documentation lookups
Local npx alternative Same tools, self-hosted — useful if you can’t send traffic to the hosted endpoint
--scope user Makes the server available in every project on your machine, not just one repo

MCP or CLI + Skills? The Lower-Token Option

Context7 now ships two ways to plug into Claude Code. ctx7 setup asks which one you want:

ModeCommandWhat Gets InstalledPick It If
MCP servernpx ctx7 setup --mcp --claudeThe MCP entry, a Context7 rule, and a context7-mcp skillYou want Claude to call Context7 tools natively
CLI + Skillsnpx ctx7 setup --cli --claudeA docs skill in ~/.claude/skills that tells Claude to run ctx7 library and ctx7 docs. No MCP serverYou’re trimming context: no MCP tool definitions sit in every session

Add --project to configure the current repo only (the default is global). If you’re counting tokens, see what actually cut our Claude Code token usage.

Verify It’s Actually Pulling Fresh Docs

claude mcp list
✔ context7    Connected
✘ context7    Failed to connect

“Connected” only confirms the handshake. The real test is asking about a library you know has changed recently and checking the answer reflects that:

What's the current recommended way to set up middleware in [a framework you use]? Use Context7 to check current docs before answering, and tell me which version the docs you pulled are for.

If the answer cites a specific version and matches what’s actually in that library’s current docs (not what an older training cutoff would guess), it’s working end to end.

Common Mistakes to Avoid

  • Assuming it’s used automatically every time. Claude decides when a query needs current docs versus when its own knowledge is sufficient — if you want to force it, say “use Context7” explicitly in the prompt.
  • Hitting rate limits on the free unauthenticated tier. Add an API key (Step 2) if you’re using it heavily — it’s free and takes about a minute.
  • Confusing this with a general web search tool. It’s scoped to library/framework/API documentation, not general current events or arbitrary web content.
  • Not restarting after adding the server. Claude Code needs a fresh session or an /mcp panel refresh to pick up a newly added server.

Q&A

Do I need an API key to use it at all?

No — it works unauthenticated at low volume. A free key from context7.com/dashboard just raises the rate limit and adds private-repo access.

How is this different from just asking Claude directly?

Claude’s own knowledge has a training cutoff and can be wrong about recent API changes. Context7 fetches the library’s actual current documentation at query time, so the answer reflects what’s true right now, not what was true when the model was trained.

Does it work for any library?

It covers a large and growing index of popular libraries and frameworks. For very obscure or brand-new packages, coverage may be incomplete — in that case Claude falls back to its own knowledge.

Can I use Context7 without MCP?

Yes. npx ctx7 setup --cli --claude installs a skill that has Claude call the ctx7 CLI for docs instead of registering an MCP server. Same docs, without MCP tool definitions in every session.

Can I remove it later?

Yes — claude mcp remove context7 deletes it from the config.

Official Resources

Comments

2 responses to “Context7 MCP for Claude Code: Current, Version-Matched Docs Instead of Outdated API Code (2-Minute Setup)”

  1. […] They already have their own dedicated setup guides — see Playwright MCP, GitHub MCP, and Context7 MCP. […]

  2. […] need library docs? Our Context7 MCP setup is the better tool for that. Firecrawl is for everything else on the […]