AI-PR-Review-MCP
Integration with Bitbucket to automatically review pull requests, post inline and general comments, and respond to /assistant commands in PR comments.
Integration with GitHub to automatically review pull requests, post inline and general comments, and respond to /assistant commands in PR comments.
Integration with Google's Gemini as a language model for generating code reviews.
Integration with OpenAI's language models (e.g., GPT-4) to generate comprehensive code reviews.
Integration with Perplexity AI as a language model for generating code reviews.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@AI-PR-Review-MCPreview PR #42 in my-org/my-repo"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
PR Review MCP Server with Multi-LLM Support & Interactive Webhook Integration
A comprehensive Model Context Protocol (MCP) server that provides automated pull request reviews using multiple LLM providers (OpenAI, Claude, Gemini, Groq, Perplexity) with both GitHub and Bitbucket integration, featuring real-time webhook processing and interactive AI assistant commands.
Features
🤖 Multi-LLM Support: OpenAI, Claude, Gemini, Groq, Perplexity
🔧 Multi-Platform: GitHub and Bitbucket integration
🖥️ Web UI: User-friendly interface for PR reviews
📡 MCP Server: Compatible with VS Code, Cursor, and other MCP clients
🔍 Review Types: Comprehensive, Security, Performance, Style reviews
⚡ Real-time: Instant PR analysis and feedback
🔔 Webhook Integration: Automatic PR review on creation/updates
💬 Interactive Commands: AI assistant responds to
/assistantcommands in PR comments📝 Commit-wise Analysis: Individual commit review with inline comments
🛡️ Security Analysis: Dedicated security vulnerability scanning
Related MCP server: devflow-mcp
Prerequisites
Python 3.8+
Git
API keys for your preferred LLM providers
GitHub Personal Access Token (with
repoandpull_requestsscopes)(Optional) Bitbucket App Password
Public URL for webhook endpoints (use ngrok, cloudflared, or similar for local development)
Quick Start
1. Clone and Setup
git clone <repository-url>
cd mcp-pr-review
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt2. Environment Configuration
Copy the example environment file and configure it:
cp .env.example .envEdit .env with your API keys:
# GitHub Configuration
GITHUB_TOKEN=your_github_token_here
# Bitbucket Configuration (Optional)
BITBUCKET_USERNAME=your_bitbucket_username
BITBUCKET_APP_PASSWORD=your_bitbucket_app_password
# LLM Provider API Keys (Add at least one)
OPENAI_API_KEY=your_openai_key_here
ANTHROPIC_API_KEY=your_claude_key_here
GOOGLE_API_KEY=your_gemini_key_here
GROQ_API_KEY=your_groq_key_here
PERPLEXITY_API_KEY=your_perplexity_key_here
# Default LLM Provider
DEFAULT_LLM_PROVIDER=openai3. Run the Services
Option A: Complete System (MCP + Web UI + Webhooks)
python scripts/run_server.pyOption B: Individual Services
# MCP Server only
python src/mcp_server.py
# Web UI only
python ui/app.py
# Webhook servers only
python bitbucket_webhook_server.py # Port 8050
python github_webhook_server.py # Port 8051This will start:
✅ MCP Server (stdio mode)
✅ Web UI at http://localhost:8080
✅ Bitbucket Webhook at http://localhost:8050/bitbucket-webhook
✅ GitHub Webhook at http://localhost:8051/github-webhook
4. Webhook Setup
For Local Development
# Expose webhooks publicly using cloudflared
cloudflared tunnel --url http://localhost:8050 # For Bitbucket
cloudflared tunnel --url http://localhost:8051 # For GitHubBitbucket Webhook Configuration
Go to your Bitbucket repository → Settings → Webhooks
Add webhook with URL:
https://your-domain.com/bitbucket-webhookSelect these events:
pullrequest:createdpullrequest:updatedpullrequest:comment_createdpullrequest:comment_updated
GitHub Webhook Configuration
Go to your GitHub repository → Settings → Webhooks
Add webhook with URL:
https://your-domain.com/github-webhookSelect these events:
pull_request(opened, synchronize, reopened)issue_comment(created, edited)
Usage
1. Automatic Webhook Reviews
Once webhooks are configured, the system automatically:
Reviews new PRs when created
Re-reviews PRs when updated with new commits
Analyzes each commit individually with inline comments
Posts both general and inline feedback
2. Interactive AI Assistant Commands
Use these commands in PR comments to interact with the AI assistant:
Basic Commands
/assistantTriggers a full re-review of the entire PR
Get Suggestions
/assistant suggestion
/assistant suggestion for error handling
/assistant suggestion optimize performanceExplain Changes
/assistant explain
/assistant explain the database changes
/assistant explain why this approach was chosenSecurity Analysis
/assistant securityAvailable Response Types
🤖 Full PR Review: Complete re-analysis with inline comments
💡 Code Suggestions: Targeted improvement recommendations
📖 Change Explanation: Detailed explanation of changes
🔒 Security Analysis: Security vulnerability assessment
3. Web UI
Select repository provider (GitHub/Bitbucket)
Choose LLM provider
Enter repository details:
Owner:
microsoft(for microsoft/vscode)Repo:
vscodePR Number:
123
Click "Review Pull Request"
4. MCP Integration (VS Code/Cursor)
Add to your MCP configuration:
VS Code (.vscode/settings.json):
{
"mcpServers": {
"pr-review-server": {
"command": "python",
"args": ["src/mcp_server.py"],
"cwd": "/path/to/mcp-pr-review",
"env": {
"GITHUB_TOKEN": "your_github_token",
"OPENAI_API_KEY": "your_openai_key"
}
}
}
}Cursor (mcp.json):
{
"mcpServers": {
"pr-review-server": {
"command": "python",
"args": ["src/mcp_server.py"],
"cwd": "/path/to/mcp-pr-review",
"env": {
"GITHUB_TOKEN": "your_github_token",
"OPENAI_API_KEY": "your_openai_key"
}
}
}
}Project Structure
mcp-pr-review/
├── README.md
├── requirements.txt
├── .env.example
├── bitbucket_webhook_server.py # Bitbucket webhook listener
├── github_webhook_server.py # GitHub webhook listener
├── config/
│ ├── settings.py
│ └── llm_providers.json
├── src/
│ ├── mcp_server.py # Main MCP server
│ ├── models/
│ │ ├── pr_data.py # PR data models
│ │ └── review_result.py # Review result models
│ ├── providers/ # LLM provider implementations
│ │ ├── base_provider.py
│ │ ├── openai_provider.py
│ │ ├── claude_provider.py
│ │ └── ...
│ ├── services/ # Core services
│ │ ├── llm_service.py
│ │ ├── github_service.py
│ │ ├── bitbucket_service.py
│ │ ├── base_repo_service.py
│ │ ├── repo_service_factory.py
│ │ └── config_service.py
│ └── utils/
│ └── logger.py
├── ui/
│ ├── app.py # FastAPI web interface
│ ├── templates/
│ └── static/
└── scripts/
└── run_server.py # Server launcherReview Types & Features
Automatic Review Features
Commit-wise Analysis: Each commit reviewed individually
Inline Comments: Specific suggestions on code lines
General Comments: Overall PR assessment
Multi-file Support: Reviews across all changed files
Review Types
Comprehensive: Full code review covering all aspects
Security: Focus on vulnerabilities and security best practices
Performance: Analyze performance implications and optimizations
Style: Code style, consistency, and best practices
Interactive Features
Command Recognition: Responds to
/assistantcommands in commentsContext-Aware: Understands specific requests (e.g., "explain database changes")
Threaded Replies: Responses appear as comment replies
Multi-Platform: Works on both GitHub and Bitbucket
API Endpoints
Webhook Endpoints
POST /bitbucket-webhook- Handles Bitbucket PR and comment eventsPOST /github-webhook- Handles GitHub PR and comment events
Web UI Endpoints
GET /- Main review interfacePOST /api/review- Manual PR review APIGET /api/providers- List available LLM providersGET /debug/providers- Debug provider information
Getting API Keys
GitHub Token
Go to GitHub → Settings → Developer settings → Personal access tokens
Generate new token (classic)
Select scopes:
repo(full repository access),pull_requestsCopy the token to your
.envfile
LLM Provider Keys
Anthropic (Claude): https://console.anthropic.com/
Google (Gemini): https://ai.google.dev/
Perplexity: https://www.perplexity.ai/settings/api
Bitbucket App Password (Optional)
Bitbucket → Personal settings → App passwords
Create app password with permissions: Repositories (Read), Pull requests (Read/Write)
Use your Bitbucket username (not email) + app password
Troubleshooting
Common Issues
"No module named 'config'" error:
# Make sure you're in the project root directory cd mcp-pr-review python scripts/run_server.pyWebhook not receiving events:
Verify webhook URL is publicly accessible
Check webhook event configuration in repository settings
Review webhook server logs for errors
Assistant commands not working:
Ensure comment events are enabled in webhook configuration
Verify the comment contains
/assistantat the beginningCheck authentication credentials
GitHub 401 Unauthorized:
Verify your GitHub token has
repoandpull_requestsscopesCheck token hasn't expired
Bitbucket 401 Unauthorized:
Use Bitbucket username (not email)
Use App Password (not login password)
Ensure app password has repository and PR permissions
Debug Commands
# Test imports
python -c "from src.services.llm_service import LLMService; print('✓ Imports work')"
# Check providers
curl http://localhost:8080/api/providers
# Debug endpoint
curl http://localhost:8080/debug/providers
# Test webhook endpoints
curl -X POST http://localhost:8050/bitbucket-webhook -H "Content-Type: application/json" -d '{}'
curl -X POST http://localhost:8051/github-webhook -H "Content-Type: application/json" -d '{}'Required Permissions
GitHub Token Scopes
repo- Full repository accesspull_requests- PR read/write access
Bitbucket App Password Permissions
Repositories: Read
Pull requests: Read, Write
Development
Adding New LLM Providers
Create provider class in
src/providers/Implement
BaseProviderinterfaceAdd to
LLMService._initialize_providers()Update configuration files
Adding New Assistant Commands
Update
parse_assistant_command()functionAdd new command handler function
Update help text and documentation
Extending Webhook Functionality
Add new event types in webhook handlers
Extend repository service classes for additional API endpoints
Add new review types or analysis methods
Example Workflows
Workflow 1: Automatic Review
Developer creates/updates PR
Webhook triggers automatic review
System posts general comment and inline suggestions
Developer receives feedback instantly
Workflow 2: Interactive Assistant
Developer comments:
/assistant suggestion for error handlingAssistant analyzes PR focusing on error handling
Assistant replies with specific suggestions
Developer can ask follow-up questions
Workflow 3: Security Review
Developer comments:
/assistant securityAssistant performs security-focused analysis
Assistant reports potential vulnerabilities
Developer addresses security concerns
Contributing
Fork the repository
Create a feature branch
Make your changes
Add tests if applicable
Test webhook functionality with ngrok/cloudflared
Submit a pull request
License
MIT License - see LICENSE file for details
Support
Issues: Create an issue on GitHub
Discussions: Use GitHub Discussions for questions
Documentation: Check the
docs/folder for detailed guidesWebhook Testing: Use ngrok or cloudflared for local webhook testing
Note: This project requires at least one LLM provider API key to function. For webhook functionality, you'll also need publicly accessible URLs. Start with OpenAI for the most reliable experience, then add other providers and webhook integration as needed.
Sources [1] base_repo_service.py https://ppl-ai-file-upload.s3.amazonaws.com/web/direct-files/attachments/81348741/9928a771-5197-4379-a7c3-155d3c647bcb/base_repo_service.py [2] bitbucket_service.py https://ppl-ai-file-upload.s3.amazonaws.com/web/direct-files/attachments/81348741/1e7d4876-9ef7-43cd-9d99-82c91cd08fc5/bitbucket_service.py [3] bitbucket_webhook_server.py https://ppl-ai-file-upload.s3.amazonaws.com/web/direct-files/attachments/81348741/5137e542-49d9-4e21-90db-0b5dc396c475/bitbucket_webhook_server.py
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/AshishChandpa/AI-PR-Review-MCP'
If you have feedback or need assistance with the MCP directory API, please join our Discord server