home / mcp / context7 mcp server
Provides up-to-date library documentation and code examples via MCP for immediate access in prompts.
Configuration
View docs{
"mcpServers": {
"upstash-context7": {
"url": "https://mcp.context7.com/mcp",
"headers": {
"CONTEXT7_API_KEY": "YOUR_API_KEY"
}
}
}
}Context7 MCP server injects up-to-date, version-specific code documentation and examples directly into your prompts. You can access current library docs, code snippets, and setup steps without leaving your coding environment, making it easier to integrate documentation into your workflow and reduce outdated guidance.
Use Context7 MCP to automatically fetch and incorporate library documentation and code examples into your prompts. You can enable it with a simple directive in your prompt or configure a rule in your MCP client to invoke Context7 for code-related questions, library lookups, or setup tasks. Context7 supports both remote HTTP connections (via an MCP URL and API key) and local stdio commands (using a local MCP process). When enabled, your prompts will include up-to-date docs and examples directly from the source.
Prerequisites: ensure you have Node.js and npm installed to run local MCP commands, or use your MCP client’s configuration to connect to the remote server.
Choose one of the following installation methods. Use the exact configurations shown to connect your MCP client to Context7.
{
"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"]
}
}
}Context7 also provides installation details for popular integrated development environments and agents. If you use Claude Code, Opencode, or Cursor for integration, you can connect them with their respective MCP pathways as shown in the following configurations.
# Claude Code Local Server Connection
claude mcp add --scope user context7 -- npx -y @upstash/context7-mcp --api-key YOUR_API_KEY
# Claude Code Remote Server Connection
claude mcp add --scope user --header "CONTEXT7_API_KEY: YOUR_API_KEY" --transport http context7 https://mcp.context7.com/mcp# Opencode Remote Server Connection
"mcp": {
"context7": {
"type": "remote",
"url": "https://mcp.context7.com/mcp",
"headers": {
"CONTEXT7_API_KEY": "YOUR_API_KEY"
},
"enabled": true
}
}
```
```json
# Opencode Local Server Connection
{
"mcp": {
"context7": {
"type": "local",
"command": ["npx", "-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"],
"enabled": true
}
}
}Context7 MCP supports OAuth 2.0 for clients that implement the MCP OAuth flow. To use OAuth, switch the endpoint from /mcp to /mcp/oauth in your client configuration for remote connections. For local stdio connections, use API key authentication as shown in the examples.
Add a rule in your MCP client to automatically invoke Context7 for library-related questions to minimize manual prompts. You can tailor the rule to fit your editor or IDE workflow.
If you know the exact library you want, specify its Context7 ID in your prompt to bypass the library-matching step and go straight to the relevant docs.
If you need documentation for a specific library version, mention the version in your prompt and Context7 will select the appropriate docs.
Resolves a general library name into a Context7-compatible library ID using the user's query and library name.
Fetches documentation for a library by library ID and user query to retrieve relevant docs.