Azure PR MCP服务器
模型上下文协议(MCP)服务器,用于使用Azure CLI查看Azure DevOps Pull Request注释。
🔒 只读。
🤖 由AI为AI制造。
特性
- ✅ Azure CLI验证 -自动检查Azure CLI的可用性
- 🔐 身份验证处理 -验证Azure CLI身份验证状态
- 💬 PR评论检索 -获取带有完整元数据的PR评论
- 🔍 状态筛选 -按状态(活动、固定、关闭等)过滤评论
- 🧪 单元测试 -使用Vitest的全面测试覆盖率
先决条件
- Node.js >= 18
- pnpm >= 9.0.0
- Azure命令行界面 - 安装指南
- Azure DevOps组织 -通过pull请求访问Azure DevOps组织
安装
安装依赖项
pnpm install构建项目
pnpm buildAzure CLI安装程序
- 安装Azure命令行界面 (如果尚未安装):
- macOS: brew install azure-cli - Windows:从下载 微软文档 - Linux:关注 Linux安装指南
- 登录Azure:
az login- Azure DevOps扩展将自动安装 当你第一次使用服务器时。
用法
运行MCP服务器
服务器在stdio上运行,设计用于MCP客户端:
node dist/index.js可用工具
1. check_azure_cli
检查是否安装了Azure CLI以及用户是否经过身份验证。
输入:无
输出:
{
"cli_installed": true,
"cli_version": "2.50.0",
"authenticated": true,
"account": "user@example.com",
"devops_extension": true,
"status": "ready"
}2. get_pr_comments
使用可选的状态筛选从Azure DevOps Pull Request中检索注释。
输入:
pr_url(必填):完整的Azure DevOps PR URL
- 格式: https://dev.azure.com/{org}/{project}/_git/{repo}/pullrequest/{id} - 传统格式: https://{org}.visualstudio.com/{project}/_git/{repo}/pullrequest/{id}
status_filter(可选):按评论状态筛选
- 选项: active, fixed, closed, wontfix, pending, bydesign, unknown, system
输出:
{
"pr_url": "https://dev.azure.com/myorg/myproject/_git/myrepo/pullrequest/123",
"status_filter": "active",
"total_comments": 5,
"comments": [
{
"id": 1,
"thread_id": 100,
"author": "John Doe",
"author_email": "john.doe@example.com",
"content": "Please add error handling here",
"status": "active",
"thread_status": "active",
"comment_type": "text",
"published_date": "2025-11-20T10:30:00Z",
"last_updated_date": "2025-11-20T10:30:00Z"
}
]
}PR URL格式示例
https://dev.azure.com/myorg/myproject/_git/myrepo/pullrequest/123
https://myorg.visualstudio.com/myproject/_git/myrepo/pullrequest/456MCP客户端配置
VS代码与GitHub副本(用户级全局配置)
要跨所有工作区进行全局访问,请将服务器添加到用户级MCP配置中:
文件位置: ~/.config/Code/User/mcp.json (Linux/macOS)或 %APPDATA%\Code\User\mcp.json (Windows)
将此条目添加到 servers 对象:
{
"servers": {
"simple-azure-devops-mcp": {
"command": "node",
"type": "stdio",
"args": ["/absolute/path/to/azure-mcp/dist/index.js"]
}
}
}重要:替换 /absolute/path/to/azure-mcp/dist/index.js 使用构建项目的实际路径。
设置步骤:
- 构建项目:
pnpm build - 编辑
~/.config/Code/User/mcp.json并添加服务器配置 - 重新加载VS代码窗口(Cmd/Ctrl+Shift+P→ “开发人员:重新加载窗口”)
- 打开GitHub Copilot聊天
- MCP工具将在所有工作区中可用
VS代码与GitHub副本(工作区级别)
创建或编辑 .vscode/settings.json 为当前工作区自动启用MCP服务器:
{
"github.copilot.chat.mcp.enabled": true,
"github.copilot.chat.mcp.servers": {
"simple-azure-devops-mcp": {
"command": "node",
"args": ["${workspaceFolder}/dist/index.js"]
}
}
}设置步骤:
- 在VS Code中打开此工作区
- 确保项目建成:
pnpm build - 重新加载VS代码窗口(Cmd/Ctrl+Shift+P→ “开发人员:重新加载窗口”)
- 打开GitHub Copilot聊天
- MCP工具将自动可用
备注:确保您启用了GitHub Copilot,并且您的VS Code版本中提供了MCP支持。
VS代码(临床扩展)
- 安装Cline延长件 来自VS Code市场
- 打开临床设置 (单击Cline面板中的齿轮图标)
- 添加MCP服务器 在MCP服务器部分:
{
"mcpServers": {
"simple-azure-devops-mcp": {
"command": "node",
"args": ["/absolute/path/to/azure-mcp/dist/index.js"]
}
}
}重要:使用项目的绝对路径。例如:
- Linux/macOS:
/home/username/Code/azure-mcp/dist/index.js - 窗户:
C:\\Users\\username\\Code\\azure-mcp\\dist\\index.js
- 重新启动Cline 或重新加载VS代码
- 这些工具现在应该出现在Cline的可用工具中
VS代码设置位置
您还可以手动编辑Cline配置文件:
- Linux:
~/.config/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json - macOS:
~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json - 视窗:
%APPDATA%\Code\User\globalStorage\saoudrizwan.claude-dev\settings\cline_mcp_settings.json
克劳德桌面版
将此服务器添加到您的Claude Desktop配置中:
{
"mcpServers": {
"simple-azure-devops-mcp": {
"command": "node",
"args": ["/absolute/path/to/azure-mcp/dist/index.js"]
}
}
}配置文件位置:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - 视窗:
%APPDATA%\Claude\claude_desktop_config.json
发展
此项目使用 作为其官方套餐经理。 请对所有包管理操作使用pnpm,以确保一致性和适当的依赖关系解决。
运行测试
pnpm test运行覆盖率测试
pnpm test:coverage装订和格式化
此项目使用ESLint进行linting,使用Prettier进行代码格式化:
# Run linter
pnpm lint
# Fix linting issues automatically
pnpm lint:fix
# Format code with Prettier
pnpm format
# Check formatting without making changes
pnpm format:checkGit挂钩
Husky被配置为在预提交时运行lint stage,它会自动:
- 在暂存的TypeScript文件上运行ESLint并自动修复
- 使用Prettier格式化代码
这确保了提交前的代码质量和一致性。
开发观看模式
pnpm dev项目结构
azure-mcp/
├── src/
│ ├── index.ts # Main MCP server
│ ├── azure-cli.ts # Azure CLI utilities
│ ├── pr-comments.ts # PR comment retrieval logic
│ ├── azure-cli.test.ts # Tests for Azure CLI utilities
│ └── pr-comments.test.ts # Tests for PR comment parsing
├── dist/ # Compiled JavaScript (generated)
├── package.json # Package configuration
├── tsconfig.json # TypeScript configuration
├── vitest.config.ts # Vitest test configuration
└── README.md # This file评论状态类型
- 活跃的:评论线程处于活动状态,需要关注
- 固定的:问题已得到解决
- 关闭:线程已关闭
- 不予修复:问题不会得到解决
- 待定:等待行动
- 故意设计:行为是故意的
- 未知:状态未确定
- 系统:系统生成的评论
故障排除
找不到Azure CLI
Error: Azure CLI is not installed or not available in PATH解决方案:安装Azure CLI并确保它在您的PATH中。
未认证
Error: Not authenticated. Please run: az login解决方案:运行 az login 并完成认证流程。
Azure DevOps扩展缺失
服务器将自动尝试安装 azure-devops 扩展。如果失败:
az extension add --name azure-devopsPR URL格式无效
Error: Invalid Azure DevOps PR URL format解决方案:确保您的PR URL与以下格式之一匹配:
https://dev.azure.com/{org}/{project}/_git/{repo}/pullrequest/{id}https://{org}.visualstudio.com/{project}/_git/{repo}/pullrequest/{id}
贡献
- 复刻仓库
- 创建要素分支
- 进行更改
- 运行测试:
pnpm test - 提交拉取请求
许可证
麻省理工学院
