AgentTask Atlas

Guides · Claude Code

How to connect the Context7 MCP server to Claude Code

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.

Steps summarize the official docs linked below, checked 2026-10-27. Client UIs change; if a menu name differs, the linked docs win.

  1. 1. Check what you need

    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.

  2. 2. Fastest: let ctx7 set it up

    Context7's own setup command for Claude Code. 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.

    npx ctx7 setup --claude
  3. 3. Or install the Context7 plugin

    The plugin connects Claude Code to the hosted server with no Node.js, npm or npx. Run these inside Claude Code, restart it, then open /mcp, select Context7 and finish the browser sign-in. 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.

    /plugin marketplace add upstash/context7
    /plugin install context7@context7-marketplace
  4. 4. Manual: add the hosted server with your key from an env var

    This is the remote command from Context7's client docs, with the key read from your shell instead of typed into the command. --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.

    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
  5. 5. Share it with the team in .mcp.json without committing the key

    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. Keep "type": "http". Claude Code asks each person to approve project-scoped servers the first time.

    {
      "mcpServers": {
        "context7": {
          "type": "http",
          "url": "https://mcp.context7.com/mcp",
          "headers": {
            "Authorization": "Bearer ${CONTEXT7_API_KEY}"
          }
        }
      }
    }
  6. 6. Or run it locally over stdio

    The local server reads CONTEXT7_API_KEY from its environment, so pass it 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. Everything after -- is passed to npx untouched.

    claude mcp add --env CONTEXT7_API_KEY="$CONTEXT7_API_KEY" --transport stdio context7 -- npx -y @upstash/context7-mcp
  7. 7. Check the connection and try it

    claude mcp list should show context7 as ✔ Connected, and /mcp shows its tool count. Then ask for docs; add the library ID (/owner/repo) to skip the lookup step. To make Claude Code use Context7 without being asked, Context7 suggests a rule in CLAUDE.md (ctx7 setup installs a skill that does this for you).

    claude mcp list
    claude mcp get context7
    # in a session:
    use context7 with /vercel/next.js for app router setup

Good to know

Troubleshooting

Only errors documented in the official docs; each fix links to its source.

Rate-limit errors
Add a free API key from context7.com/dashboard as an Authorization: Bearer header (remote) or CONTEXT7_API_KEY / --api-key (local). source ↗
401 Unauthorized, and claude mcp list shows ✘ Failed to connect
Check the key starts with ctx7sk and the header reads exactly Authorization: Bearer <key>. Claude Code reports a rejected configured header as a failed connection rather than offering OAuth; remove the header (and use the /mcp/oauth URL) if you want to sign in instead. source ↗
claude mcp list warns about a missing variable
CONTEXT7_API_KEY isn't set in the shell that launched Claude Code, so the literal ${CONTEXT7_API_KEY} text is sent. Export it before starting claude, or add a ${VAR:-default} fallback. source ↗
ERR_MODULE_NOT_FOUND or Cannot find module 'uriTemplate.js' with the local server
Use Node.js 20+ and @upstash/context7-mcp@latest, try bunx or deno instead of npx, or skip local Node entirely with the hosted URL. source ↗
Request timeouts on Windows or macOS (local server)
Point the command at the full path of node and the installed package's dist/index.js, or use the hosted server. source ↗
404 Not Found for a library
Library IDs look like /owner/repo or /owner/repo/version; let resolve-library-id find it first. source ↗
Nothing connects behind a corporate proxy
Set https_proxy / HTTPS_PROXY (in the server's env for stdio), then check curl https://mcp.context7.com/ping returns pong. source ↗
MCP server context7 already exists in local config
A server with that name is already in that scope; run claude mcp remove context7 first, or add it under a different scope. source ↗

Sources

Catalog verdict

From the AgentTask Atlas catalog entry (verified 2026-10-26). Based on official docs, not hands-on tested. New to MCP in Claude Code? Start with the general How to add an MCP server to Claude Code.

Ask the catalog from inside Claude Code: the AgentTask Atlas MCP server is free, read-only and needs no account.

Compare by task: Databases & SQL · Git & GitHub repos · Code review · CI/CD · Infra & deploy · Debugging & observability · Library docs & research · Web fetching & scraping · Frontend & UI · Local files · Docs & writing · Build AI apps · Planning & reasoning · Utilities

⚠ No independent security audit: entries summarize official sources only. Review permissions and code before installing.