Context7 MCP
$ context7-mcp 官方出品 低风险Context7 直接从开源仓库抓取最新且按版本区分的文档与代码示例给编码 Agent 使用,减少过时 API 幻觉。可通过 npx -y @upstash/context7-mcp 本地运行,支持 --transport(stdio|http)、--port 与可选的 --api-key 以提升速率限制。
npm install -g @upstash/context7-mcp context7-mcp 专为 MCP 文档检索而设计(resolve-library-id 与 get-library-docs)。
Agent 友好度体检单
当前为静态评估(本机尚未安装或尚未运行探针)。可在本地运行 npm run data:probe 并提交 data/probes/ 升级为实测证据。
FCRS-1.0 六维评分拆解
支持无交互启动与 --transport stdio|http、--port、--api-key 参数,提供清晰的两步式 MCP 文档查询工具。
--transport (stdio|http),--port,--api-key, and--help
严格只读的文档检索工具集,不涉及本地文件修改或远程写入。
- Read-only
resolve-library-idandget-library-docstools
跨平台支持,一条 npx -y @upstash/context7-mcp 命令即可运行,也支持远程托管端点。
- Published on npm (
@upstash/context7-mcp) with zero-config anonymous tier
按需获取最新框架版本文档,显著减少训练数据过期造成的 API 幻觉。
- Version-specific doc snippets tailored to coding agent context
Upstash 官方仓库(upstash/context7),采用 MIT 开源协议且生态采用率高。
- Official Upstash repo under MIT license
GitHub 与 context7.com 提供针对 Cursor、Claude Code、Codex 与 CLI 参数的清晰指引。
- Official docs on GitHub and
context7.com
安全边界、鉴权与放权指南
支持匿名限流调用;可选 API Key 可通过 --api-key 或 MCP 宿主环境变量(CONTEXT7_API_KEY)配置。
MIT 开源 MCP 服务;提供免费公共额度,如需更高速率限制可使用 API Key 套餐。
# Context7 MCP Agent Rules - Read-only documentation server: safe to query library IDs and versioned docs freely. - Pass Context7 API keys via environment variables or host config rather than committing `--api-key` flags.
Agent 高频安全命令配方
只读查询(安全推荐)
npx -y @upstash/context7-mcp --help
展示 --transport、--port 与 --api-key 选项,不启动服务。
npx -y @upstash/context7-mcp --transport http --port 8080
在 8080 端口以本地 HTTP 传输提供只读库文档检索工具。
核心优势
- + 纯只读工具集,完全杜绝编码辅助过程中的意外副作用。
- + 无需 API Key 即可直接通过
npx -y @upstash/context7-mcp开箱使用。 - + 大幅减少快速迭代框架的版本 API 幻觉。
注意事项与踩坑点
- ! 需要联网访问 Upstash 的 Context7 索引服务。
- ! 以常驻 MCP 服务(
stdio/http)模式工作,而非向标准输出打印--json的单次查询 CLI。