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.
README
Azure DevOps PR Reviewer MCP Server
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
- Clone this repository:
git clone https://github.com/MalinduDilshan/azdo-code-review-mcp.git
cd azdo-code-review-mcp
- Install dependencies:
pip install -r requirements.txt
- Create a
.envfile 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 URLorganization,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 PRline_number: Line number for commentcomment: Review comment textseverity: (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
- Go to your Azure DevOps organization
- Click on User Settings (top right) → Personal Access Tokens
- Click "New Token"
- Set a name and expiration
- Under "Scopes", select:
- Code: Read & Write
- Work Items: Read (if using work item validation)
- 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.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - 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.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.