home / mcp / context7 mcp server
Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
Configuration
View docs{
"mcpServers": {
"upstash-context7": {
"url": "https://mcp.context7.com/mcp",
"headers": {
"CONTEXT7_API_KEY": "YOUR_API_KEY"
}
}
}
}Context7 MCP provides up-to-date, library-specific code documentation and examples directly in your prompts. It helps your coding assistants fetch current APIs, versioned docs, and concrete code snippets without leaving your editor or re-asking for sources.
You can enable Context7 MCP in your prompts to automatically fetch the latest library docs and code examples. Use cases include generating setup steps, finding correct API usage, and getting version-aware guidance without manual lookup.
Prerequisites: ensure you have Node.js and npm installed on your machine. You can verify by running node -v and npm -v in your terminal.
{
"mcpServers": {
"context7": {
"url": "https://mcp.context7.com/mcp",
"headers": {
"CONTEXT7_API_KEY": "YOUR_API_KEY"
}
}
}
}{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
}
}
}Set up Context7 MCP for your coding agents by running the setup command. This authenticates you, generates an API key, and configures the MCP server and rules for your agents. You can target a specific agent with setup options.
If you use OAuth, point your client to the OAuth endpoint to obtain tokens and enable secure access. For local connections using stdio transport, use API key authentication instead.
Protect your CONTEXT7_API_KEY. Use environment isolation and do not commit keys to public repositories. Rotate keys if you suspect exposure.
If prompts fail to fetch docs, verify your API key, confirm the MCP URL, and ensure the library you request exists in Context7. You can also configure a rule in your MCP client to automatically invoke Context7 for coding questions.
Context7 MCP supports multiple clients and configurations. The remote HTTP configuration is the default approach, while local stdio connections provide a backend-ready option for development environments.
Context7 MCP exposes a pair of core tools to assist your prompts:
- resolve-library-id: Converts a library name into a Context7-compatible library ID to locate the right docs.
- query-docs: Fetches documentation for a specific library by library ID to return precise, context-aware information.
Resolves a general library name into a Context7-compatible library ID to rank results by relevance.
Retrieves documentation for a library using a Context7-compatible library ID.