Skip to main content

Claude Code Setup

Install Context7 MCP Server in Claude Code to access up-to-date documentation and code examples directly in your AI coding sessions.

Prerequisites

While Context7 works without an API key, we recommend getting a free API key for higher rate limits.

Installation Methods

Claude Code supports both local and remote MCP server connections via the claude mcp add command.

Automated Setup

Use the Context7 CLI for automated setup:
This command:
  • Authenticates via OAuth
  • Generates an API key
  • Configures the MCP server via claude mcp add
  • Sets up recommended rules in CLAUDE.md

Verify Installation

1

List MCP Servers

Check that Context7 is installed:
You should see context7 in the list of configured servers.
2

Start Claude Code Session

Start a new coding session:
3

Test with a Prompt

Try a prompt like:
You should see Context7 tools being invoked and documentation being retrieved.
To avoid typing use context7 in every prompt, add an automatic invocation rule to your CLAUDE.md file.

Global Rule

Create or edit ~/.config/claude/CLAUDE.md:
CLAUDE.md

Project-Specific Rule

Create CLAUDE.md in your project root:
CLAUDE.md

Managing Installation

Update Context7

For local installations using npx, Context7 automatically uses the latest version. For pinned versions:

Remove Context7

View Configuration

Troubleshooting

  1. Verify the installation command completed successfully
  2. Run claude mcp list to check registered servers
  3. Try removing and reinstalling: claude mcp remove context7 then reinstall
  1. Verify your API key is correct (should start with ctx7sk)
  2. Ensure the API key is properly quoted in the command
  3. Try regenerating your API key at context7.com/dashboard
  4. For remote connections, check the header name is CONTEXT7_API_KEY
  1. Ensure Node.js is installed: node --version
  2. Clear npx cache: npx clear-npx-cache
  3. Test manual execution: npx -y @upstash/context7-mcp
  4. Check Claude Code logs for error messages
  1. Verify internet connectivity
  2. Check that the URL is correct: https://mcp.context7.com/mcp
  3. Test the endpoint: curl https://mcp.context7.com/ping
  4. Ensure firewall allows HTTPS connections
  1. Get a free API key at context7.com/dashboard
  2. Check your usage and quota on the dashboard
  3. Consider upgrading to a paid plan at context7.com/plans
  1. Add use context7 explicitly to your prompt
  2. Check that your CLAUDE.md rule is properly formatted
  3. Verify Context7 server is running: claude mcp list
  4. Try restarting Claude Code

Advanced Configuration

Using Environment Variables

Store your API key in an environment variable:
Then install without specifying the key in the command:
The server will automatically read from the CONTEXT7_API_KEY environment variable.

Multiple Configurations

You can have different configurations for different projects:

Learn More

For more details on Claude Code MCP integration, see:

Next Steps

Configuration

Learn about advanced configuration options

Tools Reference

Explore available MCP tools