Context7 MCP

Context7 API Key Setup

A configuration and troubleshooting guide for using a Context7 API key with Claude Code, Cursor, Codex, and other MCP clients.

Last updated: June 22, 2026

Feature Comparison

ClientRecommended setupKey placement
Claude Code localRun the local @upstash/context7-mcp server with --api-keyCLI argument or local secret wrapper.
Claude Code remoteUse the remote HTTP endpoint with CONTEXT7_API_KEY headerHeader value, not committed config.
CursorAdd context7 to Cursor mcp.json or use one-click install if availableargs with --api-key or local env handling.
Codex or VS Code MCPUse the client-supported MCP config or extension settingLocal config, environment variable, or secure client setting.
Direct Context7 APISend Authorization: Bearer CONTEXT7_API_KEYServer-side environment variable.

Create The Key

Open the Context7 dashboard, create a named API key, and copy it immediately. Use names such as Claude Code, Cursor, Codex, or VS Code so you can revoke one client without disturbing the others.

  • Treat the key like a password.
  • Store it in a local secret manager or environment variable.
  • Do not paste it into public repos, screenshots, shared issues, or docs.
  • Rotate the key if it was committed or shared.

Claude Code Setup

For Claude Code, choose local stdio when you want the server to run through npx on your machine. Choose remote HTTP when your MCP client supports headers and you prefer the hosted endpoint.

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

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

Cursor Setup

For Cursor, add a context7 server to the MCP configuration and restart or reload MCP tools after changing the file.

{
  "mcpServers": {
    "context7": {
      "command": "npx",
      "args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
    }
  }
}

Codex And Direct API Notes

For Codex or VS Code MCP clients, use the client-specific MCP configuration path or extension setting. For direct HTTP API requests, send the key as a bearer token from server-side code.

Authorization: Bearer CONTEXT7_API_KEY

Troubleshooting Checklist

Most Context7 API key problems are caused by copying the key incorrectly, using the wrong auth location for the transport, or editing a config file that the client is not actually reading.

  • Confirm the key starts with the expected Context7 key prefix from the dashboard.
  • Regenerate the key if you did not copy it when it was first shown.
  • Use CONTEXT7_API_KEY as a header for remote MCP HTTP connections.
  • Use --api-key for local @upstash/context7-mcp stdio connections.
  • Restart the client after changing MCP config.
  • If npx fails, fix Node or PATH before changing the Context7 key.

FAQ

Where do I get a Context7 API key?

Create it in the Context7 dashboard from the API Keys section, then copy it immediately because keys are shown only once.

Does Context7 work without an API key?

Some Context7 MCP usage may work without a key under basic limits, but an API key is recommended for higher limits and predictable authenticated setup.

Why does Context7 say unauthorized?

Check whether the key was copied correctly, whether the client is using the right auth method for local versus remote MCP, and whether the edited config file is the one the client reads.

Should I put a Context7 API key in mcp.json?

For personal local config it can work, but shared repositories should keep keys out of committed config and use environment variables or client secret settings instead.