一个用于OpenDigger的模型上下文协议(MCP)服务器,通过工具和提示提供高级仓库分析和洞察。
# 设置
git clone https://github.com/X-lab2017/open-digger-mcp-server.git
# (可选)确保你在master分支上
git checkout master
cd open-digger-mcp-server && cd mcp-server
npm install
npm run build
# 启动服务器
npm start
[!IMPORTANT]
不要忘记配置Cursor(更新.path/.cursor/mcp.json中的路径)
预期输出:
OpenDigger MCP Server 正在运行(在stdio中)...
<br/>
[!IMPORTANT]
如果您使用的是Cursor AI IDE,您应该在左下角看到MCP服务器(open-digger-mcp)的通知。您应该启用它,现在您可以开始使用MCP服务器提供的工具和提示了。为了验证,请打开Cursor设置并检查MCP服务器部分→您应该在那里看到open-digger-mcp。
为了进一步确认服务器正常工作,您可以在Cursor中检查以下指标:
[!TIP] 请参阅
安装.md以获取详细的安装说明和不同IDE的配置选项。
| 序号 | 工具名称 | 描述 |
|---|---|---|
| 1 | get_open_digger_metric | 获取单个仓库的度量标准 |
| 2 | get_open_digger_metrics_batch | 批量操作多个度量标准 |
| 3 | compare_repositories | 多仓库比较分析 |
| 4 | analyze_trends | 时间段内的增长趋势分析 |
| 5 | get_ecosystem_insights | 生态系统分析及洞察 |
| 6 | server_health | 系统诊断和健康监控(测试版) |
repo_health_analysis - 综合仓库健康报告repo_comparison - 竞争性仓库分析developer_insights - 开发者活动和贡献分析openrank、stars、forks、contributors、participants、issues_new、issues_closed、pull_requests、commits、activitytechnical_fork、bus_factor、releases、inactive_contributors、maintainer_count、community_activitychange_requests、pull_requests_accepted、pull_requests_merged、issue_comments、issue_response_time、code_change_lines、developer_network使用compare_repositories工具比较microsoft/vscode和facebook/react
使用repo_health_analysis提示生成microsoft/vscode的健康报告
分析microsoft/vscode在过去两年内贡献者的增长趋势
启动服务器后,验证其是否正常工作:
# 在新的终端中
echo '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}' | node dist/index.js
预期响应应列出所有6个工具。
<br/># 缓存配置(推荐)
CACHE_TTL_SECONDS=300
# 可选的SSE服务器
SSE_PORT=3001
SSE_HOST=127.0.0.1
{
"mcpServers": {
"open-digger": {
"command": "node",
"args": ["/full/path/to/dist/index.js"],
"cwd": "/full/path/to/project",
"env": {
"CACHE_TTL_SECONDS": "300"
}
}
}
}
[!TIP] 将
/full/path/to/open-digger-mcp-server替换为您实际的项目目录路径。使用pwd获取当前目录路径。
npm run watch # 开发模式
npm run build # 编译TypeScript
npm run clean # 清理构建文件
npm run sse:test # 测试SSE服务器
[!TIP] 除了Cursor,您还可以使用其他MCP客户端,如VS Code、Claude Chat或官方的MCP Inspector。
服务器未出现在Cursor中:
.cursor/mcp.json中的绝对路径权限错误:
chmod +x dist/index.js
构建错误:
npm run clean
npm install
npm run build
缓存问题:
# 清除npm缓存
npm cache clean --force
# 重新构建
npm run clean && npm run build
git checkout -b feature/amazing-feature)git commit -m '添加惊人的功能')git push origin feature/amazing-feature)Apache-2.0许可证 - 详情请参阅LICENSE文件。