Context7
v1.0.0verified为任意库拉取最新文档与代码示例,减少过时 API 幻觉。
Install
agent-store add context7将运行命令:npx -y @upstash/context7-mcp
README

<img alt="Install in VS Code (npx)" src="https://img.shields.io/badge/Install%20in%20VS%20Code-0098FF?style=for-the-badge&logo=visualstudiocode&logoColor=white">
Context7 MCP - Up-to-date Code Docs For Any Prompt
❌ Without Context7
LLMs rely on outdated or generic information about the libraries you use. You get:
- ❌ Code examples are outdated and based on year-old training data
- ❌ Hallucinated APIs that don't even exist
- ❌ Generic answers for old package versions
✅ With Context7
Context7 MCP pulls up-to-date, version-specific documentation and code examples straight from the source — and places them directly into your prompt.
Add use context7 to your prompt (or set up a rule to auto-invoke):
Create a Next.js middleware that checks for a valid JWT in cookies
and redirects unauthenticated users to `/login`. use context7
Configure a Cloudflare Worker script to cache
JSON API responses for five minutes. use context7
Context7 fetches up-to-date code examples and documentation right into your LLM's context.
- 1️⃣ Write your prompt naturally
- 2️⃣ Tell the LLM to
use context7(or set up a rule once) - 3️⃣ Get working code answers
No tab-switching, no hallucinated APIs that don't exist, no outdated code generation.
[!NOTE] This repository hosts the source code of Context7 MCP server. The supporting components — API backend, parsing engine, and crawling engine — are private and not part of this release.
📚 Adding Projects
Check out our project addition guide to learn how to add (or update) your favorite libraries to Context7.
🛠️ Installation
Requirements
- Node.js >= v18.0.0
- Cursor, Claude Code, VSCode, Devin Desktop or another MCP Client
- Context7 API Key (Optional) for higher rate limits and private repositories (Get yours by creating an account at context7.com/dashboard)
<details> <summary><b>Installing via Smithery</b></summary>[!TIP] Recommended Post-Setup: Add a Rule to Auto-Invoke Context7
After installing Context7 (see instructions below), enhance your workflow by adding a rule so you don't have to type
use context7in every prompt. Define a simple rule in your MCP client's rule section to automatically invoke Context7 on any code question:
- For Devin Desktop, in
.devin/rules/directory- For Cursor, from
Cursor Settings > Rulessection- For Claude Code, in
CLAUDE.mdfile- Or the equivalent in your MCP client
Example Rule:
Always use context7 when I need code generation, setup or configuration steps, or library/API documentation. This means you should automatically use the Context7 MCP tools to resolve library id and get library docs without me having to explicitly ask.From then on, you'll get Context7's docs in any related conversation without typing anything extra. You can alter the rule to match your use cases.
To install Context7 MCP Server for any client automatically via Smithery:
npx -y @smithery/cli@latest install @upstash/context7-mcp --client <CLIENT_NAME> --key <YOUR_SMITHERY_KEY>
You can find your Smithery key in the Smithery.ai webpage.
</details> <details> <summary><b>Install in Cursor</b></summary>Go to: Settings -> Cursor Settings -> MCP -> Add new global MCP server
Pasting the following configuration into your Cursor ~/.cursor/mcp.json file is the recommended approach. You may also install in a specific project by creating .cursor/mcp.json in your project folder. See Cursor MCP docs for more info.
Since Cursor 1.0, you can click the install button below for instant one-click installation.
Cursor Remote Server Connection
{
"mcpServers": {
"context7": {
"url": "https://mcp.context7.com/mcp",
"headers": {
"CONTEXT7_API_KEY": "YOUR_API_KEY"
}
}
}
}
Cursor Local Server Connection
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
}
}
}
</details>
<details>
<summary><b>Install in Claude Code</b></summary>
Run this command. See Claude Code MCP docs for more info.
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
</details> <details> <summary><b>Install in Amp</b></summary>Remove
--scope userto install for the current project only.
Run this command in your terminal. See Amp MCP docs for more info.
Without API Key (Basic Usage)
amp mcp add context7 https://mcp.context7.com/mcp
With API Key (Higher Rate Limits & Private Repos)
amp mcp add context7 --header "CONTEXT7_API_KEY=YOUR_API_KEY" https://mcp.context7.com/mcp
</details>
<details>
<summary><b>Install in Devin Desktop</b></summary>
Add this to your Devin Desktop MCP config file. See Devin Desktop MCP docs for more info.
Devin Desktop Remote Server Connection
{
"mcpServers": {
"context7": {
"serverUrl": "https://mcp.context7.com/mcp",
"headers": {
"CONTEXT7_API_KEY": "YOUR_API_KEY"
}
}
}
}
Devin Desktop Local Server Connection
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
}
}
}
</details>
<details>
<summary><b>Install in VS Code</b></summary>
<img alt="Install in VS Code (npx)" src="https://img.shields.io/badge/VS_Code-VS_Code?style=flat-square&label=Install%20Context7%20MCP&color=0098FF"> <img alt="Install in VS Code Insiders (npx)" src="https://img.shields.io/badge/VS_Code_Insiders-VS_Code_Insiders?style=flat-square&label=Install%20Context7%20MCP&color=24bfa5">
Add this to your VS Code MCP config file. See VS Code MCP docs for more info.
VS Code Remote Server Connection
"mcp": {
"servers": {
"context7": {
"type": "http",
"url": "https://mcp.context7.com/mcp",
"headers": {
"CONTEXT7_API_KEY": "YOUR_API_KEY"
}
}
}
}
VS Code Local Server Connection
"mcp": {
"servers": {
"context7": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
}
}
}
</details>
<details>
<summary>
<b>Install in Cline</b>
</summary>
You can easily install Context7 through the Cline MCP Server Marketplace by following these instructions:
- Open Cline.
- Click the hamburger menu icon (☰) to enter the MCP Servers section.
- Use the search bar within the Marketplace tab to find Context7.
- Click the Install button.
Or you can directly edit MCP servers configuration:
- Open Cline.
- Click the hamburger menu icon (☰) to enter the MCP Servers section.
- Choose Remote Servers tab.
- Click the Edit Configuration button.
- Add context7 to
mcpServers:
{
"mcpServers": {
"context7": {
"url": "https://mcp.context7.com/mcp",
"type": "streamableHttp",
"headers": {
"Authorization": "Bearer YOUR_API_KEY"
}
}
}
}
</details>
<details>
<summary><b>Install in Zed</b></summary>
It can be installed via Zed Extensions or you can add this to your Zed settings.json. See Zed Context Server docs for more info.
{
"context_servers": {
"Context7": {
"source": "custom",
"command": "npx",
"args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
}
}
}
</details>
<details>
<summary><b>Install in Augment Code</b></summary>
To configure Context7 MCP in Augment Code, you can use either the graphical interface or manual configuration.
A. Using the Augment Code UI
-
Click the hamburger menu.
-
Select Settings.
-
Navigate to the Tools section.
-
Click the + Add MCP button.
-
Enter the following command:
npx -y @upstash/context7-mcp@latest -
Name the MCP: Context7.
-
Click the Add button.
Once the MCP server is added, you can start using Context7's up-to-date code documentation features directly within Augment Code.
B. Manual Configuration
- Press Cmd/Ctrl Shift P or go to the hamburger menu in the Augment panel
- Select Edit Settings
- Under Advanced, click Edit in settings.json
- Add the server configuration to the
mcpServersarray in theaugment.advancedobject
"augment.advanced": {
"mcpServers": [
{
"name": "context7",
"command": "npx",
"args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
}
]
}
Once the MCP server is added, restart your editor. If you receive any errors, check the syntax to make sure closing brackets or commas are not missing.
</details> <details> <summary><b>Install in Kilo Code</b></summary>You can configure the Context7 MCP server in Kilo Code using either the UI or by editing your project's MCP configuration file.
Kilo Code supports two configuration levels:
- Global MCP Configuration — stored in
mcp_settings.json - Project-level MCP Configuration — stored in
.kilocode/mcp.json(recommended)
If a server is defined in both places, the project-level configuration overrides the global one.
Configure via Kilo Code UI
- Open Kilo Code.
- Click the Settings icon in the top-right corner.
- Navigate to Settings → MCP Servers.
- Click Add Server.
- Choose HTTP Server (Streamable HTTP Transport).
- Enter the details:
URL
https://mcp.context7.com/mcp
Headers → Add Header
- Key:
Authorization - Value:
Bearer YOUR_API_KEY
- Click Save.
- Ensure the server toggle is enabled.
- If needed, click Refresh MCP Servers to reload the configuration.
Manual Configuration (.kilocode/mcp.json)
To configure the server at the project level (recommended for team environments), create the following file:
.kilocode/mcp.json:
{
"mcpServers": {
"context7": {
"type": "streamable-http",
"url": "https://mcp.context7.com/mcp",
"headers": {
"Authorization": "Bearer YOUR_API_KEY"
},
"alwaysAllow": [],
"disabled": false
}
}
}
Replace YOUR_API_KEY with your actual Context7 API key.
After saving the file:
-
Open Settings → MCP Servers
-
Click Refresh MCP Servers
Kilo Code will automatically detect and load the configuration.
</details> <details> <summary><b>Install in Google Antigravity</b></summary>Add this to your Antigravity MCP config file. See Antigravity MCP docs for more info.
Google Antigravity Remote Server Connection
{
"mcpServers": {
"context7": {
"serverUrl": "https://mcp.context7.com/mcp",
"headers": {
"CONTEXT7_API_KEY": "YOUR_API_KEY"
}
}
}
}
Google Antigravity Local Server Connection
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
}
}
}
</details>
<details>
<summary><b>Install in Roo Code</b></summary>
Add this to your Roo Code MCP configuration file. See Roo Code MCP docs for more info.
Roo Code Remote Server Connection
{
"mcpServers": {
"context7": {
"type": "streamable-http",
"url": "https://mcp.context7.com/mcp",
"headers": {
"CONTEXT7_API_KEY": "YOUR_API_KEY"
}
}
}
}
Roo Code Local Server Connection
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
}
}
}
</details>
<details>
<summary><b>Install in Gemini CLI</b></summary>
See Gemini CLI Configuration for details.
- Open the Gemini CLI settings file. The location is
~/.gemini/settings.json(where~is your home directory). - Add the following to the
mcpServersobject in yoursettings.jsonfile:
{
"mcpServers": {
"context7": {
"httpUrl": "https://mcp.context7.com/mcp",
"headers": {
"CONTEXT7_API_KEY": "YOUR_API_KEY",
"Accept": "application/json, text/event-stream"
}
}
}
}
Or, for a local server:
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
}
}
}
If the mcpServers object does not exist, create it.
See Qwen Coder MCP Configuration for details.
- Open the Qwen Coder settings file. The location is
~/.qwen/settings.json(where~is your home directory). - Add the following to the
mcpServersobject in yoursettings.jsonfile:
{
"mcpServers": {
"context7": {
"httpUrl": "https://mcp.context7.com/mcp",
"headers": {
"CONTEXT7_API_KEY": "YOUR_API_KEY",
"Accept": "application/json, text/event-stream"
}
}
}
}
Or, for a local server:
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
}
}
}
If the mcpServers object does not exist, create it.
Remote Server Connection
Open Claude Desktop and navigate to Settings > Connectors > Add Custom Connector. Enter the name as Context7 and the remote MCP server URL as https://mcp.context7.com/mcp.
Local Server Connection
Open Claude Desktop developer settings and edit your claude_desktop_config.json file to add the following configuration. See Claude Desktop MCP docs for more info.
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
}
}
}
</details>
<details>
<summary><b>Install in Opencode</b></summary>
Add this to your Opencode configuration file. See Opencode MCP docs for more info.
Opencode Remote Server Connection
"mcp": {
"context7": {
"type": "remote",
"url": "https://mcp.context7.com/mcp",
"headers": {
"CONTEXT7_API_KEY": "YOUR_API_KEY"
},
"enabled": true
}
}
Opencode Local Server Connection
{
"mcp": {
"context7": {
"type": "local",
"command": ["npx", "-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"],
"enabled": true
}
}
}
</details>
<details>
<summary><b>Install in OpenAI Codex</b></summary>
See OpenAI Codex for more information.
Add the following configuration to your OpenAI Codex MCP server settings:
Local Server Connection
[mcp_servers.context7]
args = ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
command = "npx"
startup_timeout_ms = 20_000
Remote Server Connection
[mcp_servers.context7]
url = "https://mcp.context7.com/mcp"
http_headers = { "CONTEXT7_API_KEY" = "YOUR_API_KEY" }
Optional troubleshooting — only if you see startup "request timed out" or "not found program". Most users can ignore this.
- First try: increase
startup_timeout_msto40_000and retry.- Windows quick fix (absolute
npxpath + explicit env):[mcp_servers.context7] command = "C:\\Users\\yourname\\AppData\\Roaming\\npm\\npx.cmd" args = [ "-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY" ] env = { SystemRoot="C:\\Windows", APPDATA="C:\\Users\\yourname\\AppData\\Roaming" } startup_timeout_ms = 40_000 `
版本历史
- v1.0.0latest7/8/2026
用户评价
暂无评价登录后可发表评价。