GitHub问题分类MCP服务器
为Archestra建造 --企业级MCP服务器,演示跨组织扩展的生产就绪AI自动化。
由Google Gemini AI支持的智能GitHub问题分类助手,作为模型上下文协议(MCP)服务器构建,具有双模操作和完全的MCP协议支持。旨在展示Archestra编排、保护和扩展AI代理的能力。
Archestra的主要亮点
- Archestra本土设计 --SSE/HTTP传输与Archestra的MCP网关无缝集成
- 生产就绪 --包括多阶段Docker构建、健康检查和Kubernetes清单
- 完整的MCP协议 --工具、资源、提示(演示完整的MCP功能)
- 真正的AI价值 --双模式操作服务于维护人员和贡献者
- 可观察和可管理 --内置指标、健康端点、结构化日志记录
演示
特性
双操作模式
维护模式 --全自动分诊
- 使用Google Gemini进行人工智能分类
- 自动标签应用(类型、优先级、复杂性)
- 结构化分诊总结评论
- 临时操作(重新运行安全)
贡献者模式 --问题发现和建议
- 按标签搜索和过滤未解决的问题
- 基于初学者友好度的智能排名
- 基于现有标签的复杂性估计
- 贡献者技能契合度评分
综合工具集
triage_issue--双模式分诊:全自动化(维护者)或问题搜索(贡献者)batch_triage--一次对存储库中的所有未解决问题进行分类triage_stats--存储库健康指标和分析
MCP资源
triage://stats/{owner}/{repo}--作为MCP资源的实时存储库统计
- 按类型、优先级、复杂性统计问题数量 - 稳定性指标(>30天不活动) - 平均发行年龄
MCP提示
常见工作流的预构建提示模板:
triage-issue--对特定问题进行分类find-beginner-issues--发现好的第一个问题repo-health-check--全面的存储库分析
Archestra平台集成
- SSE/HTTP传输 --与Archestra的MCP网关配合使用
- Docker支持 --具有多阶段构建的容器化部署
- Kubernetes就绪 --部署到Archestra编排器
- 健康检查 --内置
/health端点
高级功能
- 启发式替代 --P0检测崩溃/安全/数据丢失关键字
- 重试逻辑 --GitHub和Gemini速率限制的指数回退
- 混合错误处理 --性能下降,故障可控
- 了解费率限制 -尊重API配额(GitHub 5000/小时,Gemini 15 RPM)
为什么这对Archestra很重要
问题: 企业团队需要能够自动化问题分类等操作任务的人工智能代理,但在整个组织中部署人工智能是复杂的——需要安全管理、可观察性、可扩展性和治理。
解决方案: 此MCP服务器演示了Archestra如何解决此问题:
| 特点 | 优点 |
|---|---|
| SSE/HTTP传输 | 连接到Archestra的MCP网关进行集中管理 |
| Docker容器 | 在Archestra的基础设施中一致部署 |
| 健康检查 | Archestra自动监控服务器运行状况 |
| 结构化日志记录 | Archestra观察和审计人工智能运营 |
| 速率限制 | 服务器遵守API配额,而Archestra强制执行组织级控制 |
| 双模式操作 | 展示MCP服务器如何服务于不同的角色(维护者/贡献者) |
| 完整的MCP协议 | 工具、资源、提示展示了完整的MCP功能 |
结果: 团队使用Archestra将这个分流服务器部署到他们的GitHub企业,它自动管理代理部署、扩展、安全性和可观察性——所有这些都不需要定制的基础设施。
分类系统
类型
type-bug→ 功能损坏、崩溃、行为不正确type-feature→ 新功能请求type-enhancement→ 对现有功能的改进type-question→ 澄清请求
优先级
priority-p0→ 关键(生产中断、安全漏洞、数据丢失)priority-p1→ 高(主要用户面临错误,核心功能损坏)priority-p2→ 中等(中等问题或有用功能)priority-p3→ 低(略有改善,很高兴有)
复杂性
complexity-low→ 小改动、配置调整、UI修复complexity-medium→ 适度的逻辑变化或整合complexity-high→ 架构变更或跨系统影响
安装
先决条件
- Node.js 18+(带npm)
- GitHub个人访问令牌(PAT)
- Google Gemini API密钥
设置
- 克隆和安装依赖关系:
git clone https://github.com/DevAnuragT/autotriage_mcp.git
cd autotriage_mcp
npm install- 构建项目:
npm run build- 配置环境变量:
复制 .env.example 到 .env 并填写您的凭据:
cp .env.example .env编辑 .env:
# GitHub Personal Access Token
# Create at: https://github.com/settings/tokens
# Required scopes: repo (or public_repo for public repos)
GITHUB_TOKEN=ghp_your_github_token_here
# Google Gemini API Key
# Create at: https://aistudio.google.com/app/apikey
GOOGLE_API_KEY=your_google_api_key_here
# Optional: Gemini Model (default: gemini-1.5-flash)
# GEMINI_MODEL=gemini-1.5-flash获取API密钥
GitHub个人访问令牌:
- 首选https://github.com/settings/tokens
- 点击“生成新令牌”→ “生成新令牌(经典)”
- 选择范围:
- repo (用于私有存储库) - 或 public_repo (仅适用于公共存储库)
- 复制生成的令牌
Google Gemini API密钥:
- 首选https://aistudio.google.com/app/apikey
- 单击“创建API密钥”
- 复制生成的密钥
- 免费套餐有速率限制(Flash型号为15RPM)
用法
MCP客户端配置
将此服务器添加到您的MCP客户端配置中(例如,Claude Desktop、Cline):
克劳德桌面(~/Library/Application Support/Claude/claude_desktop_config.json 在macOS上):
{
"mcpServers": {
"github-triage": {
"command": "node",
"args": ["/absolute/path/to/autotriage_mcp/build/index.js"],
"env": {
"GITHUB_TOKEN": "ghp_your_github_token_here",
"GOOGLE_API_KEY": "your_google_api_key_here"
}
}
}
}或者使用npm全局安装:
npm install -g .然后在MCP客户端配置中:
{
"mcpServers": {
"github-triage": {
"command": "github-triage-server",
"env": {
"GITHUB_TOKEN": "ghp_your_github_token_here",
"GOOGLE_API_KEY": "your_google_api_key_here"
}
}
}
}使用工具
配置后 triage_issue 您的MCP客户端将提供该工具:
示例提示克劳德:
Triage issue #42 in the repository owner/repo-name该工具需要三个参数:
owner--GitHub存储库所有者/组织repo--GitHub存储库名称issue_number--分诊问题编号
发生了什么:
- 从GitHub获取问题详细信息
- 使用Gemini AI分析标题和正文
- 检查P0关键字(崩溃、安全、数据丢失)
- 按类型、优先级和复杂性分类
- 删除旧的分类标签(
type-*,priority-*,complexity-*) - 应用新标签
- 发布分流总结评论(如果尚未出现)
有效期: 对同一问题重新运行分类会更新标签,而不会重复注释。
输出示例
当您对问题进行分类时,该工具将:
- 贴标签 比如:
- type-bug - priority-p1 - complexity-medium
- 发表评论 比如:
🔎 Issue Triage Summary
**Type:** bug
**Priority:** P1
**Complexity:** Medium
**Reasoning:**
The issue describes a crash in the authentication module when users attempt to log in with
special characters in their password. This is a critical bug affecting core functionality.
**Suggested Next Steps:**
1. Review and assign to appropriate team member within 24 hours
2. Add to current sprint if capacity allows
3. Verify reproduction steps
4. Add relevant test cases to prevent regression
---
*This triage was performed automatically. Re-running will update labels without duplicating this comment.*🛠️ 所有工具
1. triage_issue --双模分流
维护模式 --全自动分诊
{
mode: "maintainer",
owner: "octocat",
repo: "hello-world",
issue_number: 42
}贡献者模式 --查找适合初学者的问题
{
mode: "contributor",
owner: "octocat",
repo: "hello-world",
labels: ["good first issue", "help wanted"],
limit: 10
}2. batch_triage --批量存储库分类
一次对存储库中的所有未解决问题进行分类:
{
owner: "octocat",
repo: "hello-world",
dry_run: false // Set to true to preview without applying labels
}输出: 汇总统计数据显示:
- 已分类的问题总数
- 按类型细分(bug、功能、文档等)
- 优先级分配(P0-P3)
- 复杂性分布(低/中/高)
速率限制: 自动节流以尊重:
- GitHub API:5000次请求/小时
- Gemini API:15次请求/分钟(免费层)
3. triage_stats --存储库健康指标
获取有关存储库未解决问题的全面统计数据:
{
owner: "octocat",
repo: "hello-world"
}提供的指标:
- 未决问题总数
- 按类型:bug、功能、文档、问题、其他
- 按优先级:P0(严重)、P1(高)、P2(中等)、P3(低)
- 按复杂性:低、中、高
- 初学者友好计数(第一期很好,需要帮助)
- 过期问题(超过30天未激活)
- 平均发行时间(天)
MCP资源
将实时存储库统计信息作为MCP资源访问:
triage://stats/{owner}/{repo}Claude Desktop中的示例:
Read the resource triage://stats/modelcontextprotocol/servers返回JSON,其中包含可由AI代理分析的全面健康指标。
MCP提示
常见工作流的预构建模板:
triage-issue
将特定问题与AI分类进行分类。
论据:
owner--存储库所有者repo--存储库名称issue_number--问题分类
find-beginner-issues
为新贡献者发现好的第一个问题。
论据:
owner--存储库所有者repo--存储库名称
repo-health-check
全面的存储库健康分析。
论据:
owner--存储库所有者repo--存储库名称
Claude Desktop中的用法:
Use the find-beginner-issues prompt for modelcontextprotocol/servers🐳 Archestra平台集成
此服务器是专门为在Archestra的平台上运行而构建的。以下是部署方法:
1.使用Archestra的MCP网关
Archestra配置(archestra-config.json):
{
"mcpServers": {
"github-triage": {
"url": "http://autotriage-mcp:3000/sse",
"transport": "sse",
"description": "GitHub issue triage powered by Gemini AI"
}
}
}2.Docker部署(本地测试)
塑造形象:
docker build -t autotriage-mcp:v1.1.0 .运行开发:
docker run -d \
-e GITHUB_TOKEN=$(cat ~/.github_token) \
-e GOOGLE_API_KEY=$(cat ~/.gemini_key) \
-e MCP_TRANSPORT=sse \
-p 3000:3000 \
--name autotriage-mcp \
autotriage-mcp:v1.1.0
# Verify it's running
curl http://localhost:3000/health使用docker compose在后台运行:
docker-compose up -d或者使用docker compose:
# Create .env file with GITHUB_TOKEN and GOOGLE_API_KEY
docker-compose up -d健康检查:
curl http://localhost:3000/healthSSE端点:
http://localhost:3000/sse3.Kubernetes部署(Archestra编排器)
此清单将服务器部署到Archestra的Kubernetes集群,并具有适当的秘密管理和可观察性:
先决条件:
- 运行在Archestra环境中的Kubernetes集群
- 已配置的秘密:
kubectl create secret generic github-credentials --from-literal=token=ghp_...
kubectl create secret generic gemini-credentials --from-literal=api-key=AIza...部署清单:
apiVersion: apps/v1
kind: Deployment
metadata:
name: autotriage-mcp
namespace: default
spec:
replicas: 2 # Archestra can scale based on load
selector:
matchLabels:
app: autotriage-mcp
template:
metadata:
labels:
app: autotriage-mcp
spec:
containers:
- name: mcp-server
image: registry.archestra.ai/autotriage-mcp:1.1.0
imagePullPolicy: Always
ports:
- containerPort: 3000
name: http
env:
- name: MCP_TRANSPORT
value: "sse"
- name: PORT
value: "3000"
- name: NODE_ENV
value: "production"
- name: GITHUB_TOKEN
valueFrom:
secretKeyRef:
name: github-credentials
key: token
- name: GOOGLE_API_KEY
valueFrom:
secretKeyRef:
name: gemini-credentials
key: api-key
livenessProbe:
httpGet:
path: /health
port: 3000
initialDelaySeconds: 10
periodSeconds: 30
timeoutSeconds: 5
readinessProbe:
httpGet:
path: /health
port: 3000
initialDelaySeconds: 5
periodSeconds: 10
resources:
requests:
cpu: "100m"
memory: "128Mi"
limits:
cpu: "500m"
memory: "512Mi"
---
apiVersion: v1
kind: Service
metadata:
name: autotriage-mcp-svc
spec:
selector:
app: autotriage-mcp
ports:
- port: 3000
targetPort: 3000
name: sse
type: ClusterIP部署到Archestra:
kubectl apply -f autotriage-deployment.yaml
# Verify deployment
kubectl get pods -l app=autotriage-mcp
kubectl logs -f deployment/autotriage-mcp
# Access via Archestra's MCP Gateway
# (Archestra handles the routing)此部署的好处:
- 自动缩放——Archestra根据需求缩放副本
- 健康监测——Kubernetes探测器为Archestra的可观察性提供信息
- 秘密管理——存储在Kubernetes secrets中的凭据
- 负载平衡--多个副本实现高可用性
- 滚动更新--零停机部署
- 资源管理——CPU/内存限制可防止成本失控
发展
监视模式(更改后自动重建):
npm run dev手动构建:
npm run build目录结构:
autotriage_mcp/
├── src/
│ ├── index.ts # MCP server and tool handler
│ ├── github.ts # GitHub API integration
│ ├── classifier.ts # Gemini AI classification
│ └── utils.ts # Retry logic utilities
├── build/ # Compiled JavaScript output
├── package.json
├── tsconfig.json
├── .env.example # Environment variable template
└── README.md建筑
混合错误处理
受控故障 (返回结构化错误响应):
- 输入无效(所有者格式错误,问题编号为负)
- 找不到资源(404-问题不存在)
- 身份验证失败(401/403-令牌无效)
- 速率限制(429-用重试逻辑处理)
意外故障 (抛出异常):
- 网络错误
- API服务不可用
- 内部服务器错误
- JSON解析错误
指数回退重试
自动重试GitHub和Gemini API的速率限制错误(429):
- 尝试1: 立即
- 尝试2: 等待1秒
- 尝试3: 等待2秒
- 尝试4: 等待4秒(最长)
P0关键字启发式
在调用Gemini之前,系统会检查关键关键字:
crash,security,vulnerability,data lossproduction down,critical bug,severeurgent,exploit,CVE-*
如果检测到,优先级将自动设置为 P0.
成本优化
- 双子座免费等级: Flash型号每分钟15个请求(RPM)
- 问题身体截短: 限制为2000个字符,以减少令牌使用
- 关键字预过滤: LLM调用前的P0检测可将API成本降低约20-40%
故障排除
“未设置GITHUB_TOKEN环境变量”
- 确保您已创建
.env在MCP客户端配置中文件或设置环境变量 - 验证令牌的作用域是否正确(
repo或public_repo)
“未设置GOOGLE_API_KEY环境变量”
- 确保您已将Gemini API密钥添加到
.env或MCP客户端配置 - 验证API密钥在https://aistudio.google.com/app/apikey
“超出费率限制”
- 服务器以指数回退方式自动重试
- 如果限制仍然存在,请等待几分钟后重试
- 免费等级:Gemini Flash型号为15RPM
“未找到问题”或“身份验证失败”
- 验证存储库所有者、名称和问题号是否正确
- 检查您的GitHub令牌是否可以访问存储库
- 对于私有仓库,请确保您的令牌具有
repo范围(不仅public_repo)
许可证
麻省理工学院
贡献
欢迎问题和拉取请求!此工具专为黑客马拉松和生产使用而设计。
______________________________________________________________________
这个工具是幂等的——重新运行分类更新标签,而不会重复注释。
