git回购简报
一个MCP(模型上下文协议)服务器,为公共GitHub存储库生成结构化简报。获取全面的存储库信息,包括概述、关键文件、发行说明和活动快照。
特性
- 报告概述:获取存储库元数据(名称、描述、星号、叉号、语言、主题、许可证、时间戳)
- 提取密钥文件:获取关键文件的内容(README.md、LICENSE、package.json、pyproject.toml)
- release_notes:获取包含标签名称、描述和日期的最新发行说明
- 活动_快照:获取活动指标(上次提交、未解决问题/PR、贡献者计数)
安装
npm install
npm run build用法
作为MCP服务器(stdio模式)
# Run directly
npm start
# Or after building
node dist/cli.js作为HTTP服务器
npm start -- --http
# or
HTTP_PORT=3001 node dist/cli.js --httpMCP客户端配置
添加到您的MCP客户端配置中(例如,Claude Desktop):
{
"mcpServers": {
"git-repo-brief": {
"command": "node",
"args": ["/path/to/git-repo-brief/dist/cli.js"]
}
}
}工具
报告概述
获取GitHub存储库的全面概述。
输入:
{
"repo_url": "https://github.com/owner/repo"
}输出:
{
"ok": true,
"data": {
"name": "repo",
"full_name": "owner/repo",
"description": "Repository description",
"stars": 1234,
"forks": 567,
"language": "TypeScript",
"topics": ["mcp", "github"],
"license": "MIT",
"created_at": "2023-01-01T00:00:00Z",
"updated_at": "2024-01-01T00:00:00Z",
"default_branch": "main",
"homepage": "https://example.com",
"owner": {
"login": "owner",
"avatar_url": "https://github.com/owner.png",
"type": "User"
}
},
"meta": {
"source": "https://api.github.com/repos/owner/repo",
"retrieved_at": "2024-01-15T10:00:00Z",
"pagination": { "next_cursor": null },
"warnings": []
}
}提取密钥文件
从存储库中获取关键文件的内容。
输入:
{
"repo_url": "https://github.com/owner/repo",
"paths": ["README.md", "package.json"]
}输出:
{
"ok": true,
"data": {
"files": [
{
"path": "README.md",
"content": "# Project\n\nDescription...",
"size": 1234,
"encoding": "utf-8"
},
{
"path": "package.json",
"content": "{\"name\": \"project\"}",
"size": 456,
"encoding": "utf-8"
}
],
"default_branch": "main"
},
"meta": {
"retrieved_at": "2024-01-15T10:00:00Z",
"warnings": []
}
}release_notes
从存储库获取最新发行说明。
输入:
{
"repo_url": "https://github.com/owner/repo",
"limit": 5
}输出:
{
"ok": true,
"data": {
"releases": [
{
"tag_name": "v1.0.0",
"name": "Version 1.0.0",
"body": "## Changes\n- Feature A\n- Bug fix B",
"published_at": "2024-01-01T00:00:00Z",
"prerelease": false,
"draft": false,
"html_url": "https://github.com/owner/repo/releases/tag/v1.0.0"
}
],
"total_count": 1
},
"meta": {
"retrieved_at": "2024-01-15T10:00:00Z",
"pagination": { "next_cursor": null },
"warnings": []
}
}活动_快照
获取最近存储库活动的快照。
输入:
{
"repo_url": "https://github.com/owner/repo"
}输出:
{
"ok": true,
"data": {
"last_commit_date": "2024-01-14T15:30:00Z",
"last_commit_message": "fix: resolve parsing issue",
"open_issues_count": 25,
"open_prs_count": 8,
"contributors_count": 42,
"watchers_count": 100,
"has_wiki": true,
"has_discussions": true
},
"meta": {
"retrieved_at": "2024-01-15T10:00:00Z",
"warnings": []
}
}HTTP API终结点
在HTTP模式下运行时:
GET /health-健康检查GET /tools-列出可用工具POST /tools/repo_overview-获取存储库概述POST /tools/extract_key_files-提取关键文件POST /tools/release_notes-获取发行说明POST /tools/activity_snapshot-获取活动快照
HTTP请求示例
curl -X POST http://localhost:3000/tools/repo_overview \
-H "Content-Type: application/json" \
-d '{"repo_url": "https://github.com/microsoft/vscode"}'配置
环境变量
| 变量 | 默认值 | 描述 |
|---|---|---|
GITHUB_TOKEN | - | GitHub个人访问令牌(可选,将速率限制从每小时60个请求增加到5000个请求) |
REQUEST_DELAY_MS | 100 | 速率限制请求之间的延迟 |
REQUEST_TIMEOUT_MS | 30000 | 请求超时(毫秒) |
TRANSPORT_MODE | stdio | 传输模式: stdio 或 http |
HTTP_PORT | 3000 | HTTP服务器端口(使用HTTP传输时) |
速率限制
服务器实现了礼貌的速率限制:
- 请求之间的默认延迟为100ms
- 妥善处理GitHub API速率限制响应
- 可选GitHub令牌支持更高的速率限制
响应格式
所有回复均遵循标准信封格式:
成功响应
{
"ok": true,
"data": { ... },
"meta": {
"source": "optional API URL",
"retrieved_at": "ISO-8601 timestamp",
"pagination": { "next_cursor": null },
"warnings": []
}
}错误响应
{
"ok": false,
"error": {
"code": "INVALID_INPUT | UPSTREAM_ERROR | RATE_LIMITED | TIMEOUT | PARSE_ERROR | INTERNAL_ERROR",
"message": "Human readable message",
"details": { ... }
},
"meta": {
"retrieved_at": "ISO-8601 timestamp"
}
}发展
# Install dependencies
npm install
# Run in development mode
npm run dev
# Run tests
npm test
# Run tests with coverage
npm run test:coverage
# Type check
npm run typecheck
# Build
npm run build测试
# Run all tests
npm test
# Run tests in watch mode
npm run test:watch
# Run with coverage
npm run test:coverage许可证
麻省理工学院
