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
- Claude Code CLI installed
- (Recommended) Free API key from context7.com/dashboard
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 theclaude mcp add command.
- Local Server (Recommended)
- Remote Server
Local connection runs the MCP server on your machine using
npx.Global Installation
Install Context7 for all Claude Code sessions:Replace
YOUR_API_KEY with your actual API key from context7.com/dashboardProject-Specific Installation
Install Context7 for the current project only (omit--scope user):Benefits
- Maximum privacy (runs entirely on your machine)
- Works offline after initial package download
- Full control over server lifecycle
- Recommended by Claude Code team
Automated Setup
Use the Context7 CLI for automated setup:- Authenticates via OAuth
- Generates an API key
- Configures the MCP server via
claude mcp add - Sets up recommended rules in
CLAUDE.md
Verify Installation
List MCP Servers
Check that Context7 is installed:You should see
context7 in the list of configured servers.Add a Rule (Recommended)
To avoid typinguse 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
CreateCLAUDE.md in your project root:
CLAUDE.md
Managing Installation
Update Context7
For local installations usingnpx, Context7 automatically uses the latest version. For pinned versions:
Remove Context7
View Configuration
Troubleshooting
MCP server not listed
MCP server not listed
- Verify the installation command completed successfully
- Run
claude mcp listto check registered servers - Try removing and reinstalling:
claude mcp remove context7then reinstall
Authentication errors
Authentication errors
- Verify your API key is correct (should start with
ctx7sk) - Ensure the API key is properly quoted in the command
- Try regenerating your API key at context7.com/dashboard
- For remote connections, check the header name is
CONTEXT7_API_KEY
Local server fails to start
Local server fails to start
- Ensure Node.js is installed:
node --version - Clear npx cache:
npx clear-npx-cache - Test manual execution:
npx -y @upstash/context7-mcp - Check Claude Code logs for error messages
Remote connection fails
Remote connection fails
- Verify internet connectivity
- Check that the URL is correct:
https://mcp.context7.com/mcp - Test the endpoint:
curl https://mcp.context7.com/ping - Ensure firewall allows HTTPS connections
Rate limit errors
Rate limit errors
- Get a free API key at context7.com/dashboard
- Check your usage and quota on the dashboard
- Consider upgrading to a paid plan at context7.com/plans
Tools not being invoked
Tools not being invoked
- Add
use context7explicitly to your prompt - Check that your
CLAUDE.mdrule is properly formatted - Verify Context7 server is running:
claude mcp list - Try restarting Claude Code
Advanced Configuration
Using Environment Variables
Store your API key in an environment variable: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