
Context7 MCP-任何提示的最新代码文档
❌ 无上下文7
LLM依赖于您使用的库的过时或通用信息。你得到:
- ❌ 代码示例已经过时,并且基于一年前的训练数据
- ❌ 甚至不存在的幻觉API
- ❌ 旧软件包版本的通用答案
✅ 与上下文7
Context7MCP直接从源代码中提取最新的、特定于版本的文档和代码示例,并将其直接放置在您的提示符中。
添加 use context7 根据您的提示(或 制定规则 自动调用):
Create a Next.js middleware that checks for a valid JWT in cookies
and redirects unauthenticated users to `/login`. use context7Configure a Cloudflare Worker script to cache
JSON API responses for five minutes. use context7Context7将最新的代码示例和文档直接提取到LLM的上下文中。
- 1.️⃣ 自然地写下你的提示
- 2.️⃣ 告诉LLM
use context7(或 制定规则 一次) - 3.️⃣ 获取可用代码答案
没有标签切换,没有不存在的幻觉API,没有过时的代码生成。
\[!注意\] 此存储库托管Context7 MCP服务器的源代码。支持组件——API后端、解析引擎和爬网引擎——是私有的,不属于本版本。
📚 添加项目
查看我们的 项目添加指南 学习如何将您喜爱的库添加(或更新)到Context7。
🛠️ 安装
需求
- Node.js>=v18.0.0
- Cursor、Claude Code、VSCode、Windsurf或其他MCP客户端
- Context7 API密钥(可选)适用于更高的费率限制和私人存储库(通过在 context7.com/dashboard)
\[!提示\] 推荐的发布设置:向自动调用上下文添加规则7 安装Context7(见下面的说明)后,通过添加规则来增强您的工作流程,这样您就不必键入use context7在每一个提示。在MCP客户端的规则部分定义一个简单的规则,以便在任何代码问题上自动调用Context7: - 对于Windsurf,在.windsurfrules文件 - 对于光标,从Cursor Settings > Rules部分 - 对于克劳德代码,在CLAUDE.md文件 - 或MCP客户端中的等效物 示例规则: ``txt 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.`` 从那时起,您将在任何相关对话中获得Context7的文档,而无需键入任何额外内容。您可以更改规则以匹配您的用例。
Installing via Smithery
通过以下方式自动为任何客户端安装Context7 MCP服务器 史密瑟里:
npx -y @smithery/cli@latest install @upstash/context7-mcp --client --key 你可以在 Smithery.ai网页.
Install in Cursor
首选 Settings -> Cursor Settings -> MCP -> Add new global MCP server
将以下配置粘贴到游标中 ~/.cursor/mcp.json 文件是推荐的方法。您还可以通过创建以下内容在特定项目中安装 .cursor/mcp.json 在您的项目文件夹中。看 光标MCP文档 了解更多信息。
从Cursor 1.0开始,您可以单击下面的安装按钮进行即时一键安装。
游标远程服务器连接

{
"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"]
}
}
}Install in Claude Code
运行此命令。看 克劳德代码MCP文档 了解更多信息。
Claude Code远程服务器连接
claude mcp add --transport http context7 https://mcp.context7.com/mcp --header "CONTEXT7_API_KEY: YOUR_API_KEY"克劳德代码本地服务器连接
claude mcp add context7 -- npx -y @upstash/context7-mcp --api-key YOUR_API_KEYInstall in Amp
在终端中运行此命令。看 Amp MCP文档 了解更多信息。
没有API密钥(基本用法)
amp mcp add context7 https://mcp.context7.com/mcp使用API密钥(更高的利率限制和私人回购)
amp mcp add context7 --header "CONTEXT7_API_KEY=YOUR_API_KEY" https://mcp.context7.com/mcpInstall in Windsurf
将此添加到您的Windsurf MCP配置文件中。看 Windsurf MCP文件 了解更多信息。
Windsurf远程服务器连接
{
"mcpServers": {
"context7": {
"serverUrl": "https://mcp.context7.com/mcp",
"headers": {
"CONTEXT7_API_KEY": "YOUR_API_KEY"
}
}
}
}Windsurf本地服务器连接
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
}
}
}Install in VS Code
将此添加到您的VS Code MCP配置文件中。看 VS代码MCP文档 了解更多信息。
VS代码远程服务器连接
"mcp": {
"servers": {
"context7": {
"type": "http",
"url": "https://mcp.context7.com/mcp",
"headers": {
"CONTEXT7_API_KEY": "YOUR_API_KEY"
}
}
}
}VS代码本地服务器连接
"mcp": {
"servers": {
"context7": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
}
}
}Install in Cline
您可以通过以下方式轻松安装Context7 Cline MCP服务器市场 按照以下说明:
- 打开 克莱恩.
- 点击汉堡菜单图标(☰)进入 MCP服务器 部分。
- 使用搜索栏 市场 选项卡查找 _背景7_.
- 点击 安装 按钮。
或者您可以直接编辑MCP服务器配置:
- 打开 克莱恩.
- 点击汉堡菜单图标(☰)进入 MCP服务器 部分。
- 选择 远程服务器 选项卡。
- 点击 编辑配置 按钮。
- 将context7添加到
mcpServers:
{
"mcpServers": {
"context7": {
"url": "https://mcp.context7.com/mcp",
"type": "streamableHttp",
"headers": {
"Authorization": "Bearer YOUR_API_KEY"
}
}
}
}Install in Zed
它可以通过以下方式安装 Zed扩展 或者你可以把它添加到你的Zed中 settings.json。参见 Zed上下文服务器文档 了解更多信息。
{
"context_servers": {
"Context7": {
"source": "custom",
"command": "npx",
"args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
}
}
}Install in Augment Code
要在增强代码中配置Context7 MCP,您可以使用图形界面或手动配置。
A.使用增强代码UI
- 点击汉堡菜单。
- 选择 设置.
- 导航到 工具 部分。
- 点击 +添加MCP 按钮。
- 输入以下命令:
npx -y @upstash/context7-mcp@latest- 命名MCP: 背景7.
- 点击 添加 按钮。
添加MCP服务器后,您可以直接在Augment code中开始使用Context7的最新代码文档功能。
______________________________________________________________________
B.手动配置
- 按Cmd/Ctrl Shift P或转到增强面板中的汉堡包菜单
- 选择编辑设置
- 在“高级”下,单击settings.json中的“编辑”
- 将服务器配置添加到
mcpServers数组中augment.advanced对象
"augment.advanced": {
"mcpServers": [
{
"name": "context7",
"command": "npx",
"args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
}
]
}添加MCP服务器后,重新启动编辑器。如果您收到任何错误,请检查语法以确保不缺少右括号或逗号。
Install in Kilo Code
您可以在中配置Context7 MCP服务器 基洛代码 使用UI或通过编辑项目的MCP配置文件。
Kilo Code支持两个配置级别:
- 全局MCP配置 --存储在
mcp_settings.json - 项目级MCP配置 --存储在
.kilocode/mcp.json(推荐)
如果在这两个地方都定义了服务器 项目级配置会覆盖全局配置.
______________________________________________________________________
通过Kilo Code用户界面进行配置
- 打开 基洛代码.
- 点击 设置 右上角的图标。
- 导航到 设置→ MCP服务器.
- 点击 添加服务器.
- 选择 HTTP服务器 (流式HTTP传输)。
- 输入详细信息:
统一资源定位符 https://mcp.context7.com/mcp
标头→ 添加标题栏
- 密钥:
Authorization - 价值:
Bearer YOUR_API_KEY
- 点击 保存.
- 确保服务器切换为 启用.
- 如果需要,请单击 刷新MCP服务器 以重新加载配置。
______________________________________________________________________
手动配置(.kilocode/mcp.json)
要在项目级别配置服务器(建议用于团队环境),请创建以下文件:
.kilocode/mcp.json:
{
"mcpServers": {
"context7": {
"type": "streamable-http",
"url": "https://mcp.context7.com/mcp",
"headers": {
"Authorization": "Bearer YOUR_API_KEY"
},
"alwaysAllow": [],
"disabled": false
}
}
}将YOUR_API_KEY替换为实际的Context7 API键。
保存文件后:
- 打开设置→ MCP服务器
- 单击刷新MCP服务器
Kilo Code将自动检测并加载配置。
Install in Google Antigravity
将此添加到您的反重力MCP配置文件中。看 反重力MCP文档 了解更多信息。
谷歌反重力远程服务器连接
{
"mcpServers": {
"context7": {
"serverUrl": "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"]
}
}
}Install in Roo Code
将此添加到Roo Code MCP配置文件中。看 Roo代码MCP文档 了解更多信息。
Roo代码远程服务器连接
{
"mcpServers": {
"context7": {
"type": "streamable-http",
"url": "https://mcp.context7.com/mcp",
"headers": {
"CONTEXT7_API_KEY": "YOUR_API_KEY"
}
}
}
}Roo代码本地服务器连接
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
}
}
}Install in Gemini CLI
看 Gemini CLI配置 了解详情。
- 打开Gemini CLI设置文件。位置是
~/.gemini/settings.json(其中~是您的主目录)。 - 将以下内容添加到
mcpServers对象在你settings.json文件:
{
"mcpServers": {
"context7": {
"httpUrl": "https://mcp.context7.com/mcp",
"headers": {
"CONTEXT7_API_KEY": "YOUR_API_KEY",
"Accept": "application/json, text/event-stream"
}
}
}
}或者,对于本地服务器:
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
}
}
}如果 mcpServers 对象不存在,请创建它。
Install in Qwen Coder
看 Qwen编码器MCP配置 了解详情。
- 打开Qwen编码器设置文件。位置是
~/.qwen/settings.json(其中~是您的主目录)。 - 将以下内容添加到
mcpServers对象在你settings.json文件:
{
"mcpServers": {
"context7": {
"httpUrl": "https://mcp.context7.com/mcp",
"headers": {
"CONTEXT7_API_KEY": "YOUR_API_KEY",
"Accept": "application/json, text/event-stream"
}
}
}
}或者,对于本地服务器:
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
}
}
}如果 mcpServers 对象不存在,请创建它。
Install in Claude Desktop
远程服务器连接
打开Claude Desktop,导航到“设置”>“连接器”>“添加自定义连接器”。输入名称如下 Context7 远程MCP服务器URL为 https://mcp.context7.com/mcp.
本地服务器连接
打开Claude Desktop开发人员设置并编辑您的 claude_desktop_config.json 文件以添加以下配置。看 克劳德桌面MCP文档 了解更多信息。
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
}
}
}Install in Opencode
将其添加到您的Opencode配置文件中。看 开放代码MCP文档 了解更多信息。
Opencode远程服务器连接
"mcp": {
"context7": {
"type": "remote",
"url": "https://mcp.context7.com/mcp",
"headers": {
"CONTEXT7_API_KEY": "YOUR_API_KEY"
},
"enabled": true
}
}Opencode本地服务器连接
{
"mcp": {
"context7": {
"type": "local",
"command": ["npx", "-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"],
"enabled": true
}
}
}Install in OpenAI Codex
看 OpenAI Codex 了解更多信息。
将以下配置添加到OpenAI Codex MCP服务器设置中:
本地服务器连接
[mcp_servers.context7]
args = ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
command = "npx"
startup_timeout_ms = 20_000远程服务器连接
[mcp_servers.context7]
url = "https://mcp.context7.com/mcp"
http_headers = { "CONTEXT7_API_KEY" = "YOUR_API_KEY" }可选故障排除-仅当您看到启动“请求超时”或“找不到程序”时。大多数用户可以忽略这一点。 - 第一次尝试:增加startup_timeout_ms到40_000然后重试。 - Windows快速修复(绝对npx路径+显式环境变量): ``toml [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`- macOS快速修复(使用Node+安装包入口点):`toml [mcp_servers.context7] command = "/Users/yourname/.nvm/versions/node/v22.14.0/bin/node" args = ["/Users/yourname/.nvm/versions/node/v22.14.0/lib/node_modules/@upstash/context7-mcp/dist/index.js", "--transport", "stdio", "--api-key", "YOUR_API_KEY" ]`备注:更换yourname使用您的操作系统用户名。明确设置APPDATA和SystemRoot是必不可少的,因为这些是必需的npx` 在Windows上,但默认情况下不会由某些版本的OpenAI Codex mcp客户端设置。
Install in JetBrains AI Assistant
看 JetBrains AI助手文档 了解更多详情。
- 在JetBrains IDE中,请访问
Settings->Tools->AI Assistant->Model Context Protocol (MCP) - 点击
+ Add. - 点击
Command在对话框的左上角,从列表中选择As JSON选项 - 添加此配置并单击
OK
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
}
}
}- 点击
Apply以保存更改。 - 同样的方式,可以为JetBrains Junie添加context7
Settings->Tools->Junie->MCP Settings
Install in Kiro
看 Kiro模型上下文协议文档 了解详情。
- 导航
Kiro>MCP Servers - 通过单击添加新的MCP服务器
+ Add按钮。 - 粘贴下面给出的配置:
{
"mcpServers": {
"Context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"],
"env": {},
"disabled": false,
"autoApprove": []
}
}
}- 点击
Save以应用更改。
Install in Trae
使用手动添加功能并填写该MCP服务器的JSON配置信息。 有关更多详细信息,请访问 Trae文件.
Trae远程服务器连接
{
"mcpServers": {
"context7": {
"url": "https://mcp.context7.com/mcp"
}
}
}Trae本地服务器连接
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
}
}
}Using Bun or Deno
使用这些替代方案与其他运行时一起运行本地Context7 MCP服务器。这些示例适用于支持通过命令+args启动本地MCP服务器的任何客户端。
包子
{
"mcpServers": {
"context7": {
"command": "bunx",
"args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
}
}
}迪诺
{
"mcpServers": {
"context7": {
"command": "deno",
"args": [
"run",
"--allow-env=NO_DEPRECATION,TRACE_DEPRECATION",
"--allow-net",
"npm:@upstash/context7-mcp"
]
}
}
}Using Docker
如果你更喜欢在Docker容器中运行MCP服务器:
- 构建Docker镜像:
首先,创建一个 Dockerfile 在项目根目录中(或您喜欢的任何位置):
Click to see Dockerfile content
FROM node:18-alpine
WORKDIR /app
# Install the latest version globally
RUN npm install -g @upstash/context7-mcp
# Expose default port if needed (optional, depends on MCP client interaction)
# EXPOSE 3000
# Default command to run the server
CMD ["context7-mcp"]然后使用标签(例如。, context7-mcp). 确保Docker桌面(或Docker守护进程)正在运行。 在保存的同一目录中运行以下命令 Dockerfile:
docker build -t context7-mcp .- 配置您的MCP客户端:
更新MCP客户端的配置以使用Docker命令。
_cline_mcp_settings.json示例:_
{
"mcpServers": {
"Сontext7": {
"autoApprove": [],
"disabled": false,
"timeout": 60,
"command": "docker",
"args": ["run", "-i", "--rm", "context7-mcp"],
"transportType": "stdio"
}
}
}_注意:这是一个示例配置。请参阅本自述中前面的MCP客户端的具体示例(如Cursor、VS Code等),以调整结构(例如。, mcpServers 对比 servers).此外,请确保图像名称在 args 匹配期间使用的标签 docker build 命令。_
Install Using the Desktop Extension
Install in Windows
Windows上的配置与Linux或macOS略有不同(_Cline 在示例中使用_).同样的原则也适用于其他编辑;请参阅配置 command 和 args.
{
"mcpServers": {
"github.com/upstash/context7-mcp": {
"command": "cmd",
"args": ["/c", "npx", "-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"],
"disabled": false,
"autoApprove": []
}
}
}Install in Amazon Q Developer CLI
将此添加到您的Amazon Q Developer CLI配置文件中。看 Amazon Q Developer CLI文档 了解更多详情。
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
}
}
}Install in Warp
看 Warp模型上下文协议文档 了解详情。
- 导航
Settings>AI>Manage MCP servers. - 通过单击添加新的MCP服务器
+ Add按钮。 - 粘贴下面给出的配置:
{
"Context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"],
"env": {},
"working_directory": null,
"start_on_launch": true
}
}- 点击
Save以应用更改。
Install in Copilot Coding Agent
将Context7与Copilot编码代理结合使用
将以下配置添加到 mcp 复制品编码代理配置文件存储库的部分->设置->复制品->编码代理->MCP配置:
{
"mcpServers": {
"context7": {
"type": "http",
"url": "https://mcp.context7.com/mcp",
"headers": {
"CONTEXT7_API_KEY": "YOUR_API_KEY"
},
"tools": ["get-library-docs", "resolve-library-id"]
}
}
}有关更多信息,请参阅 .
Install in Copilot CLI
- 打开Copilot CLI MCP配置文件。位置是
~/.copilot/mcp-config.json(其中~是您的主目录)。 - 将以下内容添加到
mcpServers对象在你mcp-config.json文件:
{
"mcpServers": {
"context7": {
"type": "http",
"url": "https://mcp.context7.com/mcp",
"headers": {
"CONTEXT7_API_KEY": "YOUR_API_KEY"
},
"tools": ["get-library-docs", "resolve-library-id"]
}
}
}或者,对于本地服务器:
{
"mcpServers": {
"context7": {
"type": "local",
"command": "npx",
"tools": ["get-library-docs", "resolve-library-id"],
"args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
}
}
}如果 mcp-config.json 文件不存在,请创建它。
Install in LM Studio
看 LM Studio MCP支持 了解更多信息。
一键安装:

手动设置:
- 导航到
Program(右侧)>Install>Edit mcp.json. - 粘贴下面给出的配置:
{
"mcpServers": {
"Context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
}
}
}- 点击
Save以应用更改。 - 在下面的右侧打开/关闭MCP服务器
Program,或单击聊天框底部的插件图标。
Install in Visual Studio 2022
您可以按照以下步骤在Visual Studio 2022中配置Context7 MCP Visual Studio MCP服务器文档.
将此添加到Visual Studio MCP配置文件中(请参阅 Visual Studio文档 详细信息):
{
"inputs": [],
"servers": {
"context7": {
"type": "http",
"url": "https://mcp.context7.com/mcp",
"headers": {
"CONTEXT7_API_KEY": "YOUR_API_KEY"
}
}
}
}或者,对于本地服务器:
{
"mcp": {
"servers": {
"context7": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
}
}
}
}有关更多信息和故障排除,请参阅 Visual Studio MCP服务器文档.
Install in Crush
将此添加到您的Crush配置文件中。看 粉碎MCP文档 了解更多信息。
粉碎远程服务器连接(HTTP)
{
"$schema": "https://charm.land/crush.json",
"mcp": {
"context7": {
"type": "http",
"url": "https://mcp.context7.com/mcp",
"headers": {
"CONTEXT7_API_KEY": "YOUR_API_KEY"
}
}
}
}粉碎本地服务器连接
{
"$schema": "https://charm.land/crush.json",
"mcp": {
"context7": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
}
}
}Install in BoltAI
打开应用程序的“设置”页面,导航到“插件”,然后输入以下JSON:
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
}
}
}保存后,进入聊天室 get-library-docs 后面是您的Context7文档ID(例如。, get-library-docs /nuxt/ui).更多信息请访问 BoltAI的文档网站对于iOS上的BoltAI, 请参阅本指南.
Install in Rovo Dev CLI
通过运行以下命令编辑Rovo Dev CLI MCP配置-
acli rovodev mcp配置示例-
远程服务器连接
{
"mcpServers": {
"context7": {
"url": "https://mcp.context7.com/mcp"
}
}
}本地服务器连接
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
}
}
}Install in Zencoder
要在Zencoder中配置Context7 MCP,请执行以下步骤:
- 转到Zencoder菜单(…)
- 从下拉菜单中,选择代理工具
- 点击添加自定义MCP
- 从下面添加名称和服务器配置,并确保点击安装按钮
{
"command": "npx",
"args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
}添加MCP服务器后,您可以轻松地继续使用它。
Install in Qodo Gen
看 Qodo Gen文档 了解更多详情。
- 在VSCode或IntelliJ中打开Qodo Gen聊天面板。
- 单击“连接更多工具”。
- 单击+添加新MCP。
- 添加以下配置:
Qodo Gen本地服务器连接
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
}
}
}Qodo Gen远程服务器连接
{
"mcpServers": {
"context7": {
"url": "https://mcp.context7.com/mcp"
}
}
}Install in Perplexity Desktop
看 用于困惑的本地和远程MCP 了解更多信息。
- 导航
Perplexity>Settings - 选择
Connectors. - 点击
Add Connector. - 选择
Advanced. - 输入服务器名称:
Context7 - 将以下JSON粘贴到文本区域:
{
"args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"],
"command": "npx",
"env": {}
}- 点击
Save.
Install in Factory
Factory的droid通过其CLI支持MCP服务器。看 工厂MCP文件 了解更多信息。
工厂远程服务器连接(HTTP)
在终端中运行以下命令:
droid mcp add context7 https://mcp.context7.com/mcp --type http --header "CONTEXT7_API_KEY: YOUR_API_KEY"或者没有API密钥(基本用法和速率限制):
droid mcp add context7 https://mcp.context7.com/mcp --type http工厂本地服务器连接(Stdio)
在终端中运行以下命令:
droid mcp add context7 "npx -y @upstash/context7-mcp" --env CONTEXT7_API_KEY=YOUR_API_KEY配置后,Context7工具将在您的droid会话中可用。类型 /mcp 在droid中管理服务器、进行身份验证和查看可用工具。
Install in Emdash
破折号 是一个用于并行运行多个编码代理的编排层。提供者无关,工作树隔离,本地优先。Emdash支持Context7 MCP,为您的代理启用Context7。
Emdash提供什么:
- 全局切换:设置→ MCP → “启用上下文7 MCP”
- 启用每个工作区:ProviderBar中的Context7按钮(默认情况下为禁用)。第一次单击可将其用于该工作区。再次单击将禁用它。
- ProviderBar:Context7按钮显示状态、简短说明和文档链接
你还需要做什么: 配置您的编码代理(Codex、Claude Code、Cursor等)以连接到Context7 MCP。Emdash不会修改代理的配置。请参阅上述代理的MCP配置部分(例如OpenAI Codex、Claude Code、Cursor)。
看 Emdash存储库 了解更多信息。
🔨 可用工具
Context7 MCP提供了LLM可以使用的以下工具:
resolve-library-id:将常规库名称解析为与Context7兼容的库ID。
- libraryName (必填):要搜索的图书馆名称
get-library-docs:使用与Context7兼容的库ID获取库的文档。
- context7CompatibleLibraryID (必填):精确的Context7兼容库ID(例如。, /mongodb/docs, /vercel/next.js) - topic (可选):将文档集中在特定主题上(例如,“路由”、“钩子”) - page (可选,默认1):分页页码(1-10)。如果上下文不够,请尝试使用相同主题的page=2、page=3等。
🛟 Tips
添加规则
避免打字 use context7 在每个提示中,您都可以向MCP客户端添加一个规则,该规则会自动调用Context7来解决与代码相关的问题。看 安装部分中推荐的设置 详细说明和示例规则。
使用库Id
如果您已经确切地知道要使用哪个库,请将其Context7 ID添加到提示中。这样,Context7-MCP服务器就可以跳过库匹配步骤,直接继续检索文档。
Implement basic authentication with Supabase. use library /supabase/supabase for API and docs.斜线语法告诉MCP工具要为哪个库加载文档。
HTTPS代理
如果您使用HTTP代理,Context7将使用标准 https_proxy / HTTPS_PROXY 环境变量。
💻 发展
克隆项目并安装依赖项:
bun i构建:
bun run build运行服务器:
bun run dist/index.jsCLI参数
context7-mcp 接受以下CLI标志:
--transport–使用交通工具(stdio默认情况下)。使用http用于远程HTTP服务器或stdio为了地方融合。--port–使用时要监听的端口http运输(默认3000).--api-key–用于身份验证的API密钥(或设置CONTEXT7_API_KEYenv变量)。您可以通过在上创建帐户来获取API密钥 context7.com/dashboard.
HTTP传输和端口8080的示例:
bun run dist/index.js --transport http --port 8080stdio传输的另一个例子:
bun run dist/index.js --transport stdio --api-key YOUR_API_KEY环境变量
您可以使用 CONTEXT7_API_KEY 环境变量,而不是传递 --api-key 旗帜。这有助于:
- 将API密钥安全地存储在
.env文件 - 与使用dotenv的MCP服务器设置集成
- 更喜欢环境变量配置的工具
注: 这 --api-key 当同时提供CLI标志和环境变量时,CLI标志优先于环境变量。
.env文件示例:
# .env
CONTEXT7_API_KEY=your_api_key_here使用环境变量的MCP配置示例:
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp"],
"env": {
"CONTEXT7_API_KEY": "YOUR_API_KEY"
}
}
}
}Local Configuration Example
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["tsx", "/path/to/folder/context7/src/index.ts", "--api-key", "YOUR_API_KEY"]
}
}
}Testing with MCP Inspector
npx -y @modelcontextprotocol/inspector npx @upstash/context7-mcp🚨 故障排除
Module Not Found Errors
如果你遇到 ERR_MODULE_NOT_FOUND,尝试使用 bunx 而不是 npx:
{
"mcpServers": {
"context7": {
"command": "bunx",
"args": ["-y", "@upstash/context7-mcp"]
}
}
}这通常可以解决以下环境中的模块解析问题: npx 无法正确安装或解析软件包。
ESM Resolution Issues
对于以下错误 Error: Cannot find module 'uriTemplate.js',试试 --experimental-vm-modules 标志:
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "--node-options=--experimental-vm-modules", "@upstash/context7-mcp@1.0.6"]
}
}
}TLS/Certificate Issues
使用 --experimental-fetch 标记以绕过TLS相关问题:
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "--node-options=--experimental-fetch", "@upstash/context7-mcp"]
}
}
}General MCP Client Errors
- 尝试添加
@latest到包名称 - 使用
bunx作为替代方案npx - 考虑使用
deno作为另一种选择 - 确保您使用的是Node.js v18或更高版本以获得本机获取支持
⚠️ 免责声明
1-Context7项目是由社区贡献的,虽然我们努力保持高质量,但我们无法保证所有图书馆文档的准确性、完整性或安全性。Context7中列出的项目由其各自的所有者开发和维护,而不是由Context7开发和维护。如果您遇到任何可疑、不恰当或可能有害的内容,请使用项目页面上的“报告”按钮立即通知我们。我们认真对待所有报告,并将及时审查标记的内容,以维护我们平台的完整性和安全性。通过使用Context7,您承认您可以自行决定并承担风险。
2-此存储库托管MCP服务器的源代码。支持组件——API后端、解析引擎和爬网引擎——是私有的,不属于本版本。
🤝 联系我们
保持更新并加入我们的社区:
📺 情境7媒体
- 更好的堆栈:“免费工具使光标智能10倍”
- Cole Medin:“这是人工智能编码助理的最佳MCP服务器”
- 收入流冲浪者:“情境7+顺序思维MCP:这是AGI吗?”
- Julian Goldie SEO:“上下文7:新的MCP AI代理更新”
- JeredLu:“Context 7 MCP:立即获取文档+VS代码设置”
- 收入流冲浪者:“Context7:将改变人工智能编码的新MCP服务器”
- AICodeKing:“Context7+临床和房间代码:这款MCP服务器使Cline的效率提高了100倍!”
- Sean Kochel:“Vibe编码荣耀的5台MCP服务器(只需插入即可)”
⭐ 星迹

📄 许可证
麻省理工学院
