关于 renCosta2025-context7fork
Context7 MCP 为编码助手提供最新的、按版本区分的库文档和代码示例。开发者可在提示词中加入 `use context7`,让服务获取源站参考内容并放入大模型上下文。
主要功能
- 01获取最新的库文档
- 02提供特定版本的代码示例
- 03将参考资料加入大模型上下文
- 04支持本地运行或远程连接
适用场景
- 01为指定库版本生成代码
- 02开发功能时核对 API
- 03减少对过时文档的依赖
MCP 相关
该 MCP 服务向 MCP 客户端提供文档和代码示例,支持 Cursor、Claude Code 和 VS Code 等客户端。可通过本地 stdio 或远程 HTTP 连接。
配置
远程服务无需本地安装。选择你使用的客户端,复制配置或使用一键安装。
https://server.smithery.ai/@renCosta2025/context7fork/mcpclaude mcp add --transport http ai-smithery-rencosta2025-context7fork https://server.smithery.ai/@renCosta2025/context7fork/mcp{"mcpServers":{"ai-smithery-rencosta2025-context7fork":{"type":"http","url":"https://server.smithery.ai/@renCosta2025/context7fork/mcp"}}}在 Cursor 中打开{"servers":{"ai-smithery-rencosta2025-context7fork":{"type":"http","url":"https://server.smithery.ai/@renCosta2025/context7fork/mcp"}}}在 VS Code 中打开{"mcpServers":{"ai-smithery-rencosta2025-context7fork":{"type":"http","url":"https://server.smithery.ai/@renCosta2025/context7fork/mcp"}}}{"mcpServers":{"ai-smithery-rencosta2025-context7fork":{"serverUrl":"https://server.smithery.ai/@renCosta2025/context7fork/mcp"}}}命令在终端中运行;JSON 粘贴到对应客户端的 MCP 配置后重启。需要授权的服务会在首次连接时提示登录。
https://server.smithery.ai/@renCosta2025/context7fork/mcp需要授权工具
详细介绍

Context7 MCP - 为任何提示词提供最新代码文档
❌ 不使用 Context7
大模型依赖关于你所用库的过时或通用信息。你会遇到:
- ❌ 代码示例已经过时,基于一年前的训练数据
- ❌ 幻觉出的 API,甚至根本不存在
- ❌ 针对旧版软件包的通用回答
✅ 使用 Context7
Context7 MCP 会直接从源头获取最新的特定版本文档和代码示例,并将它们直接放入你的提示词中。
在 Cursor 中将 use context7 添加到提示词:
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 会将最新的代码示例和文档直接载入大模型的上下文。
- 1️⃣ 自然地编写提示词
- 2️⃣ 告诉大模型
use context7 - 3️⃣ 获取可用的代码答案
无需切换标签页,不会遇到不存在的幻觉 API,也不会生成过时代码。
📚 添加项目
查看我们的添加项目指南,了解如何将你喜欢的库添加到 Context7(或更新它们)。
🛠️ 安装
要求
- Node.js >= v18.0.0
- Cursor、Claude Code、VSCode、Windsurf 或其他 MCP 客户端
- Context7 API Key(可选,用于提高速率限制)(在 context7.com/dashboard 创建账户即可获取)
警告
SSE 协议弃用通知
Server-Sent Events(SSE)传输协议已弃用,其端点将在后续版本中移除。请改用 HTTP 或 stdio 传输方式。
通过 Smithery 安装
通过 Smithery 为任意客户端自动安装 Context7 MCP 服务:
npx -y @smithery/cli@latest install @upstash/context7-mcp --client <CLIENT_NAME> --key <YOUR_SMITHERY_KEY>
你可以在 Smithery.ai 网页 中找到你的 Smithery key。
在 Cursor 中安装
前往:Settings -> Cursor Settings -> MCP -> Add new global MCP server
建议将以下配置粘贴到 Cursor 的 ~/.cursor/mcp.json 文件中。你也可以在项目文件夹中创建 .cursor/mcp.json,以便在特定项目中安装。详情请参阅 Cursor MCP 文档。
从 Cursor 1.0 开始,你可以点击下方的安装按钮,即刻一键安装。
Cursor 远程服务连接
{
"mcpServers": {
"context7": {
"url": "https://mcp.context7.com/mcp",
"headers": {
"CONTEXT7_API_KEY": "YOUR_API_KEY"
}
}
}
}
Cursor 本地服务连接
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
}
}
}
在 Claude Code 中安装
运行此命令。详情请参阅 Claude Code MCP 文档。
Claude Code 远程服务连接
claude mcp add --transport http context7 https://mcp.context7.com/mcp --header "CONTEXT7_API_KEY: YOUR_API_KEY"
Claude Code 本地服务连接
claude mcp add context7 -- npx -y @upstash/context7-mcp --api-key YOUR_API_KEY
在 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"]
}
}
}
在 VS Code 中安装
将以下内容添加到你的 VS Code MCP 配置文件中。详情请参阅 VS Code MCP 文档。
VS Code 远程服务连接
"mcp": {
"servers": {
"context7": {
"type": "http",
"url": "https://mcp.context7.com/mcp",
"headers": {
"CONTEXT7_API_KEY": "YOUR_API_KEY"
}
}
}
}
VS Code 本地服务连接
"mcp": {
"servers": {
"context7": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
}
}
}
在 Cline 中安装
按照以下说明,通过 Cline MCP 服务市场 即可轻松安装 Context7:
- 打开 Cline。
- 点击汉堡菜单图标(☰),进入 MCP 服务 部分。
- 在 市场 选项卡的搜索栏中查找 Context7。
- 点击 安装 按钮。
或者,你也可以直接编辑 MCP 服务配置:
- 打开 Cline。
- 点击汉堡菜单图标(☰),进入 MCP 服务 部分。
- 选择 远程服务 选项卡。
- 点击 编辑配置 按钮。
- 将 context7 添加到
mcpServers:
{
"mcpServers": {
"context7": {
"url": "https://mcp.context7.com/mcp",
"type": "streamableHttp",
"headers": {
"Authorization": "Bearer YOUR_API_KEY"
}
}
}
}
在 Zed 中安装
你可以通过 Zed 扩展 安装,也可以将以下内容添加到 Zed 的 settings.json。更多信息请参阅 Zed Context Server 文档。
{
"context_servers": {
"Context7": {
"command": {
"path": "npx",
"args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
},
"settings": {}
}
}
}
在 Augment Code 中安装
要在 Augment Code 中配置 Context7 MCP,可以使用图形界面或手动配置。
A. 使用 Augment Code UI
-
点击汉堡菜单。
-
选择 设置。
-
前往 工具 部分。
-
点击 + 添加 MCP 按钮。
-
输入以下命令:
npx -y @upstash/context7-mcp@latest -
将 MCP 命名为:Context7。
-
点击 添加 按钮。
添加 MCP 服务后,你就可以直接在 Augment Code 中使用 Context7 提供的最新代码文档功能。
B. 手动配置
- 按 Cmd/Ctrl Shift P,或前往 Augment 面板中的汉堡菜单
- 选择编辑设置
- 在高级设置下,点击在 settings.json 中编辑
- 将服务配置添加到
augment.advanced对象中的mcpServers数组
"augment.advanced": {
"mcpServers": [
{
"name": "context7",
"command": "npx",
"args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
}
]
}
添加 MCP 服务后,重启编辑器。如果收到任何错误,请检查语法,确保没有遗漏右括号或逗号。
在 Roo Code 中安装
将以下内容添加到 Roo Code MCP 配置文件中。更多信息请参阅 Roo Code MCP 文档。
Roo Code 远程服务连接
{
"mcpServers": {
"context7": {
"type": "streamable-http",
"url": "https://mcp.context7.com/mcp",
"headers": {
"CONTEXT7_API_KEY": "YOUR_API_KEY"
}
}
}
}
Roo Code 本地服务连接
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
}
}
}
在 Gemini CLI 中安装
详情请参阅 Gemini CLI 配置。
- 打开 Gemini CLI 设置文件。文件位置为
~/.gemini/settings.json(其中~是你的主目录)。 - 将以下内容添加到
settings.json文件中的mcpServers对象:
{
"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 对象不存在,请创建它。
在 Claude Desktop 中安装
远程服务连接
打开 Claude Desktop,前往“设置”>“连接器”>“添加自定义连接器”。将名称设为 Context7,并将远程 MCP 服务 URL 设为 https://mcp.context7.com/mcp。
本地服务连接
打开 Claude Desktop 开发者设置,编辑 claude_desktop_config.json 文件并添加以下配置。更多信息请参阅 Claude Desktop MCP 文档。
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
}
}
}
在 Opencode 中安装
将以下内容添加到 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
}
}
}
在 OpenAI Codex 中安装
有关详细信息,请参阅 OpenAI Codex。
将以下配置添加到 OpenAI Codex MCP 服务设置中:
[mcp_servers.context7]
args = ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
command = "npx"
⚠️ Windows 注意事项
在 Windows 上,部分用户可能会遇到默认配置下请求超时的问题。 此时,请使用 Node.js 和已安装软件包的完整路径,显式配置 MCP 服务:
[mcp_servers.context7]
command = "C:\\Program Files\\nodejs\\node.exe"
args = [
"C:\\Users\\yourname\\AppData\\Roaming\\npm\\node_modules\\@upstash\\context7-mcp\\dist\\index.js",
"--transport",
"stdio",
"--api-key",
"YOUR_API_KEY"
]
或者,也可以使用以下配置:
[mcp_servers.context7]
command = "cmd"
args = [
"/c",
"npx",
"-y",
"@upstash/context7-mcp",
"--api-key",
"YOUR_API_KEY"
]
env = { SystemRoot="C:\\Windows" }
startup_timeout_ms = 20_000
这样可确保 Codex CLI 在 Windows 上稳定运行。
在 JetBrains AI Assistant 中安装
有关详细信息,请参阅 JetBrains AI Assistant 文档。
- 在 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保存更改。 - 同样,也可以在
Settings->Tools->Junie->MCP Settings中为 JetBrains Junie 添加 context7
在 Kiro 中安装
详情请参阅 Kiro Model Context Protocol 文档。
- 前往
Kiro>MCP Servers - 点击
+ Add按钮,添加新的 MCP 服务。 - 粘贴以下配置:
{
"mcpServers": {
"Context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"],
"env": {},
"disabled": false,
"autoApprove": []
}
}
}
- 点击
Save应用更改。
在 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"]
}
}
}
使用 Bun 或 Deno
使用这些替代方案,通过其他运行时运行本地 Context7 MCP 服务。这些示例适用于任何支持通过 command + args 启动本地 MCP 服务的客户端。
Bun
{
"mcpServers": {
"context7": {
"command": "bunx",
"args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
}
}
}
Deno
{
"mcpServers": {
"context7": {
"command": "deno",
"args": [
"run",
"--allow-env=NO_DEPRECATION,TRACE_DEPRECATION",
"--allow-net",
"npm:@upstash/context7-mcp"
]
}
}
}
使用 Docker
如果你更愿意在 Docker 容器中运行 MCP 服务:
-
构建 Docker 镜像:
首先,在项目根目录(或你喜欢的任何位置)创建一个
Dockerfile:点击查看 Dockerfile 内容
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 Desktop(或 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" } } }注意:这只是一个配置示例。请参阅本 README 前面针对你的 MCP 客户端(如 Cursor、VS Code 等)的具体示例,并据此调整结构(例如,使用
mcpServers还是servers)。另外,请确保args中的镜像名称与docker build命令中使用的标签一致。
使用桌面扩展安装
安装 mcpb 文件夹中的 context7.mcpb 文件,并将其添加到你的客户端中。更多信息请参阅 MCP bundles 文档。
在 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": []
}
}
}
在 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"]
}
}
}
在 Warp 中安装
详情请参阅 Warp Model Context Protocol 文档。
- 前往
Settings>AI>Manage MCP servers。 - 点击
+ Add按钮,添加新的 MCP 服务。 - 粘贴以下配置:
{
"Context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"],
"env": {},
"working_directory": null,
"start_on_launch": true
}
}
- 点击
Save应用更改。
在 Copilot Coding Agent 中安装
在 Copilot Coding Agent 中使用 Context7
将以下配置添加到 Copilot Coding Agent 配置文件的 mcp 部分:Repository->Settings->Copilot->Coding agent->MCP configuration:
{
"mcpServers": {
"context7": {
"type": "http",
"url": "https://mcp.context7.com/mcp",
"headers": {
"CONTEXT7_API_KEY": "YOUR_API_KEY"
},
"tools": ["get-library-docs", "resolve-library-id"]
}
}
}
更多信息请参阅 GitHub 官方文档。
在 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以应用更改。 - 在右侧
Program下切换 MCP 服务的开关,或点击聊天框底部的插头图标。
在 Visual Studio 2022 中安装
按照 Visual Studio MCP 服务文档 中的说明,即可在 Visual Studio 2022 中配置 Context7 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 服务文档。
在 Crush 中安装
将以下内容添加到 Crush 配置文件中。更多信息请参阅 Crush MCP 文档。
Crush 远程服务连接(HTTP)
{
"$schema": "https://charm.land/crush.json",
"mcp": {
"context7": {
"type": "http",
"url": "https://mcp.context7.com/mcp",
"headers": {
"CONTEXT7_API_KEY": "YOUR_API_KEY"
}
}
}
}
Crush 本地服务连接
{
"$schema": "https://charm.land/crush.json",
"mcp": {
"context7": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
}
}
}
在 BoltAI 中安装
打开应用的“Settings”页面,前往“Plugins”,然后输入以下 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,请参阅本指南。
在 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"]
}
}
}
在 Zencoder 中安装
按照以下步骤在 Zencoder 中配置 Context7 MCP:
- 前往 Zencoder 菜单 (...)
- 在下拉菜单中选择 Agent tools
- 点击 Add custom MCP
- 添加下方的名称和服务配置,并确保点击 Install 按钮
{
"command": "npx",
"args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
}
添加 MCP 服务后,即可继续使用。
在 Qodo Gen 中安装
详情请参阅 Qodo Gen 文档。
- 在 VSCode 或 IntelliJ 中打开 Qodo Gen 聊天面板。
- 点击 Connect more tools。
- 点击 + Add new 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"
}
}
}
在 Perplexity Desktop 中安装
更多信息请参阅 Perplexity 的本地和远程 MCP。
- 前往
Perplexity>Settings - 选择
Connectors。 - 点击
Add Connector。 - 选择
Advanced。 - 输入服务名称:
Context7 - 在文本区域中粘贴以下 JSON:
{
"args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"],
"command": "npx",
"env": {}
}
- 点击
Save。
Context7 MCP 提供以下供大模型使用的工具:
-
resolve-library-id:将通用库名称解析为 Context7 兼容的库 ID。libraryName(必填):要搜索的库名称
-
get-library-docs:使用 Context7 兼容的库 ID 获取库文档。context7CompatibleLibraryID(必填):准确的 Context7 兼容库 ID(例如,/mongodb/docs、/vercel/next.js)topic(可选):将文档聚焦于特定主题(例如,“routing”、“hooks”)tokens(可选,默认值为 5000):要返回的最大 token 数。小于 1000 的值会自动增至 1000。
🛟 提示
添加规则
如果不想在每个提示词中都添加 use context7,可以在 MCP 客户端的规则部分定义一条简单规则:
- 对于 Windsurf,在
.windsurfrules文件中 - 对于 Cursor,在
Cursor Settings > Rules部分 - 对于 Claude Code,在
CLAUDE.md文件中
也可以在 MCP 客户端中配置等效规则,让 Context7 自动处理任何代码问题。
规则示例
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 的文档,无需额外输入。你可以根据自己的使用场景调整规则。
使用库 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.js
CLI 参数
context7-mcp 接受以下 CLI 标志:
--transport <stdio|http>– 要使用的传输方式(默认值为stdio)。请注意,HTTP 传输会自动提供 HTTP 和 SSE 端点。--port <number>– 使用http传输时要监听的端口(默认值为3000)。--api-key <key>– 用于身份验证的 API 密钥。你可以在 context7.com/dashboard 创建账户以获取 API 密钥。
使用 HTTP 传输和端口 8080 的示例:
bun run dist/index.js --transport http --port 8080
使用 stdio 传输的另一个示例:
bun run dist/index.js --transport stdio --api-key YOUR_API_KEY
本地配置示例
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["tsx", "/path/to/folder/context7/src/index.ts", "--api-key", "YOUR_API_KEY"]
}
}
}
使用 MCP Inspector 进行测试
npx -y @modelcontextprotocol/inspector npx @upstash/context7-mcp
🚨 故障排除
找不到模块错误
如果遇到 ERR_MODULE_NOT_FOUND,请尝试使用 bunx 代替 npx:
{
"mcpServers": {
"context7": {
"command": "bunx",
"args": ["-y", "@upstash/context7-mcp"]
}
}
}
这通常可以解决在 npx 无法正确安装或解析软件包的环境中出现的模块解析问题。
ESM 解析问题
对于类似 Error: Cannot find module 'uriTemplate.js' 的错误,请尝试使用 --experimental-vm-modules 标志:
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "--node-options=--experimental-vm-modules", "@upstash/[email protected]"]
}
}
}
TLS/证书问题
使用 --experimental-fetch 标志绕过 TLS 相关问题:
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "--node-options=--experimental-fetch", "@upstash/context7-mcp"]
}
}
}
一般 MCP 客户端错误
- 尝试在软件包名称后添加
@latest - 使用
bunx作为npx的替代方案 - 考虑使用
deno作为另一种替代方案 - 确保使用 Node.js v18 或更高版本,以支持原生 fetch
Context7 项目由社区贡献。虽然我们努力维持高质量,但无法保证所有库文档的准确性、完整性或安全性。Context7 中列出的项目由各自的所有者开发和维护,而非由 Context7 开发和维护。如果您发现任何可疑、不当或可能有害的内容,请使用项目页面上的“举报”按钮立即通知我们。我们会认真对待所有举报,并及时审核被标记的内容,以维护平台的完整性和安全性。使用 Context7 即表示您知晓,使用行为由您自行决定并承担风险。
🤝 联系我们
关注最新动态,加入我们的社区:
- 📢 在 X 上关注我们,获取最新新闻和动态
- 🌐 访问我们的网站
- 💬 加入我们的 Discord 社区
📺 媒体报道
- Better Stack:“Free Tool Makes Cursor 10x Smarter”
- Cole Medin:“This is Hands Down the BEST MCP Server for AI Coding Assistants”
- Income Stream Surfers:“Context7 + SequentialThinking MCPs: Is This AGI?”
- Julian Goldie SEO:“Context7: New MCP AI Agent Update”
- JeredBlu:“Context 7 MCP: Get Documentation Instantly + VS Code Setup”
- Income Stream Surfers:“Context7: The New MCP Server That Will CHANGE AI Coding”
- AICodeKing:“Context7 + Cline & RooCode: This MCP Server Makes CLINE 100X MORE EFFECTIVE!”
- Sean Kochel:“5 MCP Servers For Vibe Coding Glory (Just Plug-In & Go)”
⭐ 星标历史
📄 许可证
MIT
评论
一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。