Azure DevOps PR Reviewer MCP Server

Azure DevOps PR Reviewer MCP Server

An MCP server for automated code reviews on Azure DevOps pull requests, enabling AI assistants to fetch PR details, validate requirements, post inline comments, and set review votes.

Category
访问服务器

README

Azure DevOps PR Reviewer MCP Server

License: MIT

A Model Context Protocol (MCP) server for automated code reviews on Azure DevOps Pull Requests. This server enables AI assistants like Claude and Kiro to review PRs, validate requirements, post inline comments, and manage the review workflow automatically.

Features

  • Get PR Information: Fetch complete PR details including changed files with full content
  • Validate PRs: Run comprehensive validation checks (status, reviewers, checklist, work items)
    • Smart reviewer validation: Only checks required reviewers, skips optional reviewers
  • Post Findings: Create inline comments on specific lines in PR files
    • Enhanced diff analysis with multiple fallback strategies for accurate line mapping
  • Set Review Votes: Approve, reject, or request changes on PRs
  • List PRs: Browse open pull requests in repositories

Recent Improvements

  • Enhanced Diff Computation: Added intelligent fallback mechanism that computes changed lines from file contents when Azure DevOps API doesn't provide change blocks. This ensures reliable line number mapping for inline comments even in edge cases.
  • Smarter Reviewer Validation: The validation now focuses only on required reviewers and properly skips optional reviewers, providing more accurate PR approval status.

Installation

Prerequisites

  • Python 3.10 or higher
  • Azure DevOps Personal Access Token (PAT) with Code (Read & Write) permissions
  • Git installed on your system

Setup

  1. Clone this repository:
git clone https://github.com/MalinduDilshan/azdo-code-review-mcp.git
cd azdo-code-review-mcp
  1. Install dependencies:
pip install -r requirements.txt
  1. Create a .env file in the project root:
# Azure DevOps Configuration
AZURE_DEVOPS_ORG=your-organization
AZURE_DEVOPS_PROJECT=your-project
AZURE_DEVOPS_PAT=your-personal-access-token
AZURE_DEVOPS_URL=https://dev.azure.com
AZURE_DEVOPS_USER_DISPLAY_NAME=Your Name
AZURE_DEVOPS_USER_EMAIL=your.email@example.com

# Optional: Skip specific reviewer groups
SKIP_REVIEWER_GROUPS=Group1,Group2

# Optional: Skip validations and jump directly to code review
SKIP_VALIDATIONS=false

Usage

With Kiro AI Assistant

Add to your .kiro/settings/mcp.json:

{
  "mcpServers": {
    "azure-devops-reviewer": {
      "command": "python",
      "args": ["-m", "mcp.server"],
      "cwd": "/path/to/azdo-code-review-mcp",
      "env": {
        "AZURE_DEVOPS_ORG": "your-org",
        "AZURE_DEVOPS_PROJECT": "your-project",
        "AZURE_DEVOPS_PAT": "your-pat"
      }
    }
  }
}

With Claude Desktop

Add to your Claude Desktop configuration:

MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json Windows: %APPDATA%\Claude\claude_desktop_config.json

{
  "mcpServers": {
    "azure-devops-reviewer": {
      "command": "python",
      "args": ["-m", "src.mcp.server"],
      "cwd": "/path/to/azdo-code-review-mcp",
      "env": {
        "AZURE_DEVOPS_ORG": "your-org",
        "AZURE_DEVOPS_PROJECT": "your-project",
        "AZURE_DEVOPS_PAT": "your-pat"
      }
    }
  }
}

Standalone Usage

from src.azure_devops import AzureDevOpsConnector

# Initialize connector
connector = AzureDevOpsConnector(
    organization="my-org",
    project="my-project",
    pat="my-personal-access-token"
)

# Get PR information
pr_info = connector.get_pr_info(pr_number=123, repo_name="my-repo")

# Post a comment
connector.post_inline_comment(
    pr_number=123,
    repo_name="my-repo",
    file_path="/src/main.py",
    line_number=42,
    comment_text="Consider adding error handling here"
)

# Set review vote
connector.set_pr_review_vote(
    pr_number=123,
    repo_name="my-repo",
    vote=10  # 10 = Approved, -5 = Waiting for Author
)

Available Tools

get_pr

Fetch PR information and all changed files with content in one call.

Parameters:

  • pr_url (optional): Full Azure DevOps PR URL
  • organization, project, repository, pr_number (alternative to pr_url)

validate_pr

Run comprehensive PR validation checks including status, reviewers, checklist items, and linked work items.

Note: Reviewer validation intelligently focuses on required reviewers only, skipping optional reviewers for more accurate approval status.

Parameters:

  • Same as get_pr

post_findings

Post code review findings as inline comments on specific lines.

Note: Enhanced with robust diff computation that uses multiple fallback strategies to ensure accurate line number mapping, even when Azure DevOps API change blocks are unavailable.

Parameters:

  • PR identification (same as get_pr)
  • findings: Array of objects with:
    • file_path: Path to file in PR
    • line_number: Line number for comment
    • comment: Review comment text
    • severity: (optional) "error", "warning", or "info"

set_vote

Set your review vote on the PR.

Parameters:

  • PR identification (same as get_pr)
  • vote: -10 (Rejected), -5 (Waiting for Author), 0 (No Vote), 5 (Approved with Suggestions), 10 (Approved)

list_prs

List open pull requests in a repository.

Parameters:

  • organization, project, repository

Configuration Options

Environment Variable Required Default Description
AZURE_DEVOPS_ORG Yes - Your Azure DevOps organization name
AZURE_DEVOPS_PROJECT Yes - Default project name
AZURE_DEVOPS_PAT Yes - Personal Access Token with Code (Read & Write) permissions
AZURE_DEVOPS_URL No https://dev.azure.com Base URL for Azure DevOps
AZURE_DEVOPS_USER_DISPLAY_NAME No - Display name for review comments
AZURE_DEVOPS_USER_EMAIL No - Email for review comments
SKIP_REVIEWER_GROUPS No - Comma-separated list of reviewer groups to skip
SKIP_VALIDATIONS No false Skip validation checks and go directly to review

Creating an Azure DevOps PAT

  1. Go to your Azure DevOps organization
  2. Click on User Settings (top right) → Personal Access Tokens
  3. Click "New Token"
  4. Set a name and expiration
  5. Under "Scopes", select:
    • Code: Read & Write
    • Work Items: Read (if using work item validation)
  6. Click "Create" and copy the token immediately

Project Structure

azdo-code-review-mcp/
├── src/
│   ├── azure_devops/      # Core Azure DevOps integration
│   │   ├── base.py        # Base connector with auth
│   │   ├── connector.py   # Main connector class
│   │   ├── models.py      # Data models
│   │   ├── pr_info.py     # PR information retrieval
│   │   ├── pr_diff.py     # Diff analysis
│   │   ├── pr_comments.py # Comment posting
│   │   └── pr_review.py   # Review and voting
│   ├── mcp/               # MCP server implementation
│   │   ├── server.py      # Main MCP server
│   │   ├── schemas.py     # Tool schemas
│   │   └── tools/         # Tool handlers
│   │       ├── get_pr.py
│   │       ├── validate_pr.py
│   │       ├── post_findings.py
│   │       ├── set_vote.py
│   │       └── list_prs.py
│   └── config.py          # Configuration management
├── tests/
│   └── test_server.py     # Component tests
├── .github/               # GitHub Actions and templates
├── .env.example           # Example environment file
├── requirements.txt       # Python dependencies
└── README.md             # This file

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Troubleshooting

Common Issues

"Authentication failed"

  • Verify your PAT is correct and hasn't expired
  • Ensure the PAT has Code (Read & Write) permissions
  • Check that the organization and project names are correct

"Line number out of range"

  • The server validates line numbers against the actual diff using multiple fallback strategies
  • Changed lines are now computed from file contents when API change blocks are unavailable
  • Ensure you're commenting on lines that were actually changed in the PR

"Cannot find PR"

  • Verify the PR number, repository name, and project are correct
  • Check that the PR exists and is accessible with your PAT

Support

For issues, questions, or contributions, please use the GitHub Issues page.

Acknowledgments

Built with the Model Context Protocol by Anthropic.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选