Configuration
Context7 MCP Server supports various configuration options for authentication, transport, and behavior customization.Authentication
Context7 supports two authentication methods: API Key and OAuth 2.0.API Key Authentication
API key authentication is the simplest method and works with both local and remote connections.Getting an API Key
- Visit context7.com/dashboard
- Sign up or log in
- Generate a new API key
- API keys start with the prefix
ctx7sk
Free API keys provide higher rate limits than anonymous access. Paid plans offer professional and enterprise limits.
Passing API Keys
There are multiple ways to provide your API key:- Command Line Flag
- Environment Variable
- HTTP Header
Pass the API key directly via the Pros: Simple and explicit
Cons: API key visible in config file
--api-key flag:Cons: API key visible in config file
OAuth 2.0 Authentication
OAuth provides secure, token-based authentication for remote connections.Requirements
- Remote HTTP connection only (not available for local stdio)
- MCP client must support MCP OAuth specification
Configuration
Change the endpoint from/mcp to /mcp/oauth:
OAuth Endpoints
Context7 implements OAuth 2.0 Protected Resource Metadata (RFC 9728): Protected Resource Metadata:profile- Access to user profile informationemail- Access to user email address
header- Bearer token in Authorization header
OAuth vs API Key
API Key
Best for:
- Local connections
- Simple setup
- Single-user environments
- Testing and development
- Works with both local and remote
- Simple configuration
- Direct access
- Manual key management
- No automatic refresh
OAuth 2.0
Best for:
- Remote connections
- Team environments
- Enterprise deployments
- Enhanced security
- Automatic token refresh
- Revocable access
- Scoped permissions
- Remote only
- Requires OAuth support
Transport Configuration
Context7 MCP Server supports two transport modes.stdio (Local)
Standard input/output transport for local connections. Configuration:- Runs on your local machine
- Communicates via stdin/stdout
- Default transport mode
- Maximum privacy
HTTP (Remote)
HTTP transport for remote server connections. Configuration:- Can run locally or remotely
- RESTful HTTP API
- Supports OAuth
- Scalable for teams
/mcp- Anonymous/API key access/mcp/oauth- OAuth 2.0 protected access/ping- Health check/.well-known/oauth-protected-resource- OAuth metadata/.well-known/oauth-authorization-server- OAuth server metadata
Environment Variables
Context7 MCP Server reads the following environment variables:Your Context7 API key. Get one at context7.com/dashboardFormat: Starts with
Example:
ctx7skExample:
ctx7sk_abc123xyz789Override the Context7 API base URL.Default:
Example:
https://context7.com/apiExample:
https://api.context7.comOverride the MCP resource URL for OAuth.Default:
Example:
https://mcp.context7.comExample:
https://custom-mcp.example.comOverride the OAuth authorization server URL.Default:
Example:
https://context7.comExample:
https://auth.example.comHTTP/HTTPS proxy URL for outgoing requests.Aliases:
Example:
https_proxy, HTTP_PROXY, http_proxyExample:
http://proxy.example.com:8080Command Line Options
When running Context7 MCP Server locally:Transport type to use.Options:
Example:
stdio, httpExample:
--transport httpPort for HTTP transport (only valid with
--transport http).Example: --port 8080API key for authentication (only valid with
--transport stdio).Example: --api-key ctx7sk_abc123Valid Option Combinations
Proxy Configuration
Context7 automatically detects and uses proxy settings from environment variables:HTTPS_PROXYhttps_proxyHTTP_PROXYhttp_proxy
Rate Limits
Context7 applies rate limits based on your authentication:Anonymous (No API Key)
- Limited requests per hour
- Suitable for testing only
- May encounter 429 errors during heavy use
Free API Key
- Higher rate limits
- Suitable for regular development
- Generous quota for individual developers
Paid Plans
- Professional rate limits
- Enterprise-grade quotas
- Priority support
Handling Rate Limits
When you hit rate limits, you’ll receive:- Add a free API key if using anonymous access
- Wait for rate limit window to reset
- Upgrade to a paid plan
Security Best Practices
Recommended Practices
- Use environment variables for API keys
- Add to .gitignore:
- Rotate keys regularly from the dashboard
- Use OAuth for team environments
- Never share API keys in prompts or queries
What Not to Send
Do not include in your queries:- API keys, passwords, or credentials
- Personal identifiable information (PII)
- Proprietary or confidential code
- Customer data
- Security tokens
Troubleshooting
Invalid API key error
Invalid API key error
- Verify key starts with
ctx7sk - Check for extra spaces or quotes
- Regenerate key from dashboard
- Ensure key is active (not revoked)
Rate limit errors
Rate limit errors
- Add API key if using anonymous access
- Wait for rate limit window to reset
- Upgrade plan at context7.com/plans
- Reduce request frequency
Connection errors
Connection errors
For HTTP transport:
- Check internet connectivity
- Verify URL is correct
- Test endpoint:
curl https://mcp.context7.com/ping - Check firewall settings
- Verify proxy configuration
- Ensure Node.js is installed
- Clear npx cache:
npx clear-npx-cache - Test manually:
npx -y @upstash/context7-mcp
OAuth errors
OAuth errors
- Ensure using
/mcp/oauthendpoint - Verify client supports MCP OAuth spec
- Check OAuth is only for remote (HTTP) transport
- Try API key authentication instead
Next Steps
Tools Reference
Explore available MCP tools
All Clients
See all supported MCP clients