ai newsDi., 27. Okt.
EilmeldungGPT-6.1 Terra vs Sol: Maxing Out the Budget Model Costs More Than Dialing Down the Pro

Context7 in Claude Code: setup, keeping the API key out of your repo, and fixing 401s

Context7 gives Claude Code current, version-specific library docs through two tools, resolve-library-id and query-docs . The hosted server at https://mcp.context7.com/mcp needs no local Node.js; an API key is optional, but Upstash recommends a free one for higher rate limits. Your library names and

dev.toDienstag 15:34 · 27.10.3 Min. Lesezeit
Bild: dev.to

Posted on Oct 27 • Originally published at agenttaskatlas.com

Context7 gives Claude Code current, version-specific library docs through two tools, resolve-library-id and query-docs. The hosted server at https://mcp.context7.com/mcp needs no local Node.js; an API key is optional, but Upstash recommends a free one for higher rate limits. Your library names and queries are sent to Context7's hosted service, whose backend is private.

The steps below summarize the official docs (the Context7 README, Context7's Claude Code page and troubleshooting page, and the Claude Code docs on MCP and permissions ), checked on 2026-10-27. They are based on the official docs, not hands-on tested; if something differs on your version, the linked docs win. The original version of this guide lives at AgentTask Atlas: How to connect the Context7 MCP server to Claude Code.

Nothing for the hosted server except outbound HTTPS. For an API key, create one in the Context7 dashboard (context7.com/dashboard); keys start with ctx7sk. The local npx server needs Node.js 20 or newer, and the ctx7 setup CLI needs Node.js 22.13 or newer.

npx ctx7 setup --claude Enter fullscreen mode Exit fullscreen mode It signs you in with an OAuth device flow (a link and short code you can open on any device, so it also works over SSH), generates an API key and lets you choose CLI + skill mode or MCP mode. Undo it later with npx ctx7 remove.

Run these inside Claude Code, restart it, then open /mcp, select Context7 and finish the browser sign-in:

/plugin marketplace add upstash/context7 /plugin install context7@context7-marketplace Enter fullscreen mode Exit fullscreen mode No API key is needed, and the plugin does not read CONTEXT7_API_KEY, so use the next step on headless, SSH or CI hosts.

export CONTEXT7_API_KEY = "YOUR_API_KEY" # better: load it from your secret manager or shell profile claude mcp add --scope user --header "Authorization: Bearer $CONTEXT7_API_KEY " --transport http context7 https://mcp.context7.com/mcp Enter fullscreen mode Exit fullscreen mode --scope user makes it available in every project and stores it in ~/.claude.json, outside your repository. To skip the key and sign in with OAuth instead, use https://mcp.context7.com/mcp/oauth without the header and authenticate from /mcp.

Claude Code expands ${VAR} in the url and headers of a project's.mcp.json, so each teammate sets CONTEXT7_API_KEY in their own environment and the file stays secret-free:

{ "mcpServers": { "context7": { "type": "http", "url": "https://mcp.context7.com/mcp", "headers": { "Authorization": "Bearer ${CONTEXT7_API_KEY}" } } } } Enter fullscreen mode Exit fullscreen mode Claude Code asks each person to approve project-scoped servers the first time.

claude mcp add --env CONTEXT7_API_KEY = " $CONTEXT7_API_KEY " --transport stdio context7 -- npx -y @upstash/context7-mcp Enter fullscreen mode Exit fullscreen mode Pass the key with --env instead of --api-key on the command line. Keep --transport stdio between --env and the server name: if the name comes right after --env, the CLI reads it as another KEY=value pair.

claude mcp list claude mcp get context7 # in a session: use context7 with /vercel/next.js for app router setup Enter fullscreen mode Exit fullscreen mode claude mcp list should show context7 as connected. Adding the library ID ( /owner/repo ) skips the lookup step.

Quelle: dev.to (dev.to). Original öffnen