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). The query string of an audience on an allowed host is ignored. MCP_OAUTH_AUDIENCE_ENFORCEMENT sets what a mismatch does: observe (default) admits a token with a missing or foreign audience; foreign answers HTTP 401 to a token issued for another server and still admits one with no aud; required answers 401 to both. Every mismatch is logged with the OAuth client ID, the audience and the outcome, once per token per hour on each replica.
The HTTP server is stateless — it creates a fresh server instance per request and keeps no session state. Session operations therefore have nothing to attach to: a GET or DELETE on /mcp is answered with 405 Method Not Allowed rather than opening a standalone Server-Sent Events stream. Server-Sent Events are used only to stream responses to POST requests, and keepalive heartbeats are disabled.
GET /ping answers {"status":"ok","message":"pong"} without reading any credential. It is a liveness check only: it does not validate an API key or OAuth token, and it does not consume request quota. A 200 from /ping says the server is up, not that the credential you sent with it is valid. To verify a key, make a real lookup such as query-docs: with an invalid key, the tool returns an error with the Context7 API’s message.
Stdio transport with API key:
Environment Variables
Withstdio transport, you can use the CONTEXT7_API_KEY environment variable instead of passing the --api-key flag. Set it in your shell or in the env block of your MCP client configuration. The server does not load .env files.