docs/resources/developer.mdx
This guide covers how to set up the Context7 MCP server locally for development and testing.
Clone the project and install dependencies:
git clone https://github.com/upstash/context7.git
cd context7
pnpm i
Build:
pnpm run build
Run the server:
node packages/mcp/dist/index.js
context7-mcp accepts the following CLI flags:
| Flag | Description | Default |
|---|---|---|
--transport <stdio|http> | Transport to use. Use http for remote HTTP server or stdio for local integration. | stdio |
--port <number> | Port to listen on when using http transport. | 3000 |
--api-key <key> | API key for authentication (or set CONTEXT7_API_KEY env var). | - |
HTTP transport on port 8080:
node packages/mcp/dist/index.js --transport http --port 8080
Stdio transport with API key:
node packages/mcp/dist/index.js --transport stdio --api-key YOUR_API_KEY
You can use the CONTEXT7_API_KEY environment variable instead of passing the --api-key flag. This is useful for:
.env files# .env
CONTEXT7_API_KEY=your_api_key_here
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp"],
"env": {
"CONTEXT7_API_KEY": "YOUR_API_KEY"
}
}
}
}
When developing locally, use this configuration to run from source:
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["tsx", "/path/to/folder/context7/src/index.ts", "--api-key", "YOUR_API_KEY"]
}
}
}
Test your setup using the MCP Inspector:
npx -y @modelcontextprotocol/inspector npx @upstash/context7-mcp
This opens an interactive inspector to verify Context7 tools are working correctly.