使用说明
Azure DevOps MCP服务器和CLI
一个基于TypeScript的工具,用于通过CLI或MCP(模型上下文协议)服务器管理Azure DevOps Pull请求。
特性
- 全面公关管理:获取、列出、更新、完成、放弃PR
- 代码审查:添加/删除审阅者、投票、管理评论
- 线程管理:创建线程、回复、解析、获取文件上下文
- 自动完成:使用合并选项设置或取消自动完成
- 审阅者统计数据:使用有趣的徽章汇总审阅者分配统计数据
- 双接口:用作AI助手的CLI工具或MCP服务器
安装
# Clone the repository
git clone https://github.com/YOUR_USERNAME/azure-devops-mcp.git
cd azure-devops-mcp
# Install dependencies
npm install
# Build
npm run build
# Install globally (optional)
npm run install-global
配置
创建 .env 项目根目录中的文件:
# Required
AZURE_DEVOPS_PAT=your-personal-access-token
# Optional defaults (can be overridden via CLI flags)
AZURE_DEVOPS_ORG=your-organization
AZURE_DEVOPS_PROJECT=your-project
AZURE_DEVOPS_REPO=your-repository
CLI使用情况
# List active PRs
azdo list-prs --org myorg --project myproject --repo myrepo
# Get PR details (by ID or URL)
azdo get-pr 123
azdo get-pr "https://dev.azure.com/org/project/_git/repo/pullrequest/123"
# Get comment threads
azdo get-threads 123 --status active
# Get file context for a thread
azdo get-thread-context 123 456 --lines 10
# Add a comment
azdo add-comment 123 --content "Looks good!"
azdo add-comment 123 --content "Consider refactoring" --file src/index.ts --line 42
# Reply to a thread
azdo reply-to-thread 123 456 --content "Fixed in latest commit"
# Resolve a thread
azdo resolve-thread 123 456 --status fixed
# Add/remove reviewers
azdo add-reviewer 123 user@example.com
azdo add-reviewer 123 user@example.com --optional
azdo remove-reviewer 123 user@example.com
# Vote on a PR
azdo vote 123 approve
azdo vote 123 approve-with-suggestions
azdo vote 123 wait-for-author
azdo vote 123 reject
azdo vote 123 reset
# Update PR title/description
azdo update-pr 123 --title "New title" --description "Updated description"
# Complete (merge) a PR
azdo complete-pr 123 --squash --delete-branch
# Abandon a PR
azdo abandon-pr 123
# Set auto-complete
azdo set-auto-complete 123 --enable --squash --delete-branch
azdo set-auto-complete 123 --disable
# Reviewer statistics
azdo reviewer-stats --org myorg
azdo reviewer-stats --org myorg --project myproject --json
azdo reviewer-stats --org myorg --discord-webhook "https://discord.com/api/webhooks/..."
MCP服务器使用情况
添加到您的MCP配置中(例如。, claude_desktop_config.json):
{
"mcpServers": {
"azure-devops": {
"command": "node",
"args": ["/path/to/azure-devops-mcp/dist/index.js"],
"env": {
"AZURE_DEVOPS_PAT": "your-pat-token",
"AZURE_DEVOPS_ORG": "your-org",
"AZURE_DEVOPS_PROJECT": "your-project",
"AZURE_DEVOPS_REPO": "your-repo"
}
}
}
}
可用的MCP工具
| 工具 | 说明 |
|---|---|
get_pr |
获取拉取请求的详细信息 |
list_prs |
使用筛选器列出拉取请求 |
get_threads |
获取PR上的评论帖子 |
get_thread_context |
获取线程的文件/行上下文 |
add_comment |
添加注释(常规或内联) |
reply_to_thread |
回复评论帖子 |
resolve_thread |
解析评论线程 |
delete_comment |
删除评论 |
add_reviewer |
向PR添加审阅者 |
remove_reviewer |
从PR中删除审阅者 |
vote |
对PR进行投票 |
update_pr |
更新PR标题/描述 |
complete_pr |
完成(合并)PR |
abandon_pr |
放弃公关 |
set_auto_complete |
设置或取消自动完成 |
reviewer_stats |
获取审阅者分配统计信息 |
审阅者统计数据
这 reviewer-stats 命令聚合了所有活动PR的审阅者分配,并包括有趣的徽章:
Reviewer Statistics (12 Active PRs)
Reviewer Required Approved Waiting for Author Rejected Unreviewed
---------------- -------- -------- ------------------ -------- ----------
Mike 5 3 1 0 1
Anna 4 4 0 0 0
Natalie 3 1 0 0 2
✨ Flawless: Anna has reviewed every single PR assigned. Respect.
徽章
| 徽章 | 状况 |
|---|---|
| 🦸 超级评论者 | 高流量+80%+完成率 |
| 🆘 需要备份 | 高容量+50%+未查看 |
| 😴 需要咖啡 | 低/中等量+70%+未经审查 |
| 🪑 Benchwarmer | 只分配了1个PR |
| ✨ 无瑕疵 | 所有PR均已审核(2+已分配) |
| 🚫 看门人 | 遭到拒绝 |
| ⏳ 等候室 | 2+个PR被封锁 |
| ⚡ 速度恶魔 | 中等音量+70%+完成 |
发展
# Watch mode
npm run dev
# Build
npm run build
# Run MCP server
npm start
# Run CLI
node dist/cli.js --help
许可证
麻省理工学院
