Getting Started
Clone the project and install dependencies:CLI Arguments
context7-mcp accepts the following CLI flags:
Get your API key by creating an account at context7.com/dashboard.
Examples
HTTP transport on port 8080:Authorization: Bearer YOUR_API_KEY. Set MCP_AUTH_ENFORCEMENT=observe to also accept requests without credentials on /mcp.
Opaque OAuth access tokens (oat_…) are checked against the Context7 API before each request is served (one check per token per minute on each replica; the cache is in memory, and a rejected token stays rejected for ten minutes). An expired or revoked token gets an HTTP 401 with a WWW-Authenticate challenge so MCP clients refresh it. Set MCP_OAUTH_TOKEN_VALIDATION=off to skip that check and forward the token unchecked.
OAuth JWT access tokens from the authorization server (OAUTH_AUTH_SERVER_URL) are verified locally: signature against its JWKS, issuer, a typ of at+jwt, and expiry with a minute of clock tolerance. Clerk ID tokens and session JWTs share that issuer but are not access tokens, so they are always rejected. The token’s aud must name this server (RESOURCE_URL origin, /mcp, or /mcp/oauth; override with a comma-separated MCP_OAUTH_ALLOWED_AUDIENCES). MCP_OAUTH_AUDIENCE_ENFORCEMENT=observe (default) admits a token with a missing or foreign audience and logs the OAuth client ID and audience, once per token every ten minutes; required answers HTTP 401.
Stdio transport with API key:
Environment Variables
You can use theCONTEXT7_API_KEY environment variable instead of passing the --api-key flag. This is useful for:
- Storing API keys securely in
.envfiles - Integration with MCP server setups that use dotenv
- Tools that prefer environment variable configuration