GitHub PR Reviewer MCP Server
Provides tools to fetch pull request diffs, analyze changed Go code, run tests, and post review comments or reviews to GitHub pull requests.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
GitHub PR Reviewer MCP Server
An MCP (Model Context Protocol) server that provides automated code review capabilities for Go repositories. This server enables Claude to analyze pull requests, run tests, perform static analysis, and post review comments to GitHub.
Features
š Static Code Analysis: Run golangci-lint, gofmt, and go vet on Go code
ā Automated Testing: Execute Go tests with coverage analysis
š PR Diff Analysis: Fetch and analyze GitHub PR changes
š¬ Review Comments: Automatically post review feedback to GitHub
š¤ Comprehensive Review: End-to-end PR review workflow orchestration
Related MCP server: GitHub Code Review Assistant
Architecture
āāāāāāāāāāāāāāāāāāā
ā ā
ā Claude.ai / ā
ā Claude Desktop ā
ā ā
āāāāāāāāāā¬āāāāāāāāā
ā MCP Protocol
ā
āāāāāāāāāā¼āāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā GitHub PR Reviewer MCP Server ā
ā ā
ā Tools: ā
ā ⢠github_pr_analyze_code ā
ā ⢠github_pr_run_tests ā
ā ⢠github_pr_get_diff ā
ā ⢠github_pr_post_review ā
ā ⢠github_pr_comprehensive_review ā
āāāāāāāāāā¬āāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā
āāāāāāāāāāāāāāāā¬āāāāāāāāāāāāāāā
ā ā ā
āāāāāā¼āāāā āāāāāā¼āāāāā āāāāā¼āāāāāā
ā GitHub ā ā Local ā ā Go ā
ā API ā ā Files ā ā Tools ā
āāāāāāāāāā āāāāāāāāāāā āāāāāāāāāāāPrerequisites
System Requirements
Python 3.10 or higher
Go 1.20 or higher (for Go project analysis)
Git
Go Tools Installation
Install required Go analysis tools:
# Install golangci-lint
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
# Ensure Go tools are in PATH
export PATH=$PATH:$(go env GOPATH)/binGitHub Authentication
You need a GitHub Personal Access Token with the following permissions:
repo(for private repositories)pull_requests:write(for posting comments)
Create a token at: https://github.com/settings/tokens
Installation
1. Clone the Repository
git clone https://github.com/yourusername/github-pr-reviewer-mcp.git
cd github-pr-reviewer-mcp2. Install Python Dependencies
# Create a virtual environment (recommended)
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt3. Set Environment Variables
# Set your GitHub token
export GITHUB_TOKEN="ghp_your_token_here"For persistent configuration, add to ~/.bashrc or ~/.zshrc:
echo 'export GITHUB_TOKEN="ghp_your_token_here"' >> ~/.bashrc
source ~/.bashrc4. Configure Claude Desktop
Add the server to your Claude Desktop configuration file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
Linux: ~/.config/Claude/claude_desktop_config.json
{
"mcpServers": {
"github-pr-reviewer": {
"command": "python",
"args": ["/absolute/path/to/github-pr-reviewer-mcp/github_pr_mcp.py"],
"env": {
"GITHUB_TOKEN": "ghp_your_token_here"
}
}
}
}Replace /absolute/path/to/github-pr-reviewer-mcp/ with the actual path.
5. Restart Claude Desktop
After updating the configuration, restart Claude Desktop for changes to take effect.
Usage
Available Tools
1. github_pr_analyze_code
Analyze Go code for quality issues using static analysis tools.
Parameters:
file_path(string): Path to Go file or directoryanalysis_type(string): "lint", "fmt", "vet", or "all"response_format(string): "markdown" or "json"
Example:
Can you analyze the code in /path/to/myproject/main.go?2. github_pr_run_tests
Run Go tests with optional coverage analysis.
Parameters:
package_path(string): Go package path (default: "./...")verbose(bool): Enable verbose outputcoverage(bool): Generate coverage reportresponse_format(string): "markdown" or "json"
Example:
Run tests on my Go project at /path/to/myproject with coverage3. github_pr_get_diff
Fetch the diff for a GitHub pull request.
Parameters:
owner(string): Repository ownerrepo(string): Repository namepr_number(int): Pull request numberresponse_format(string): "markdown" or "json"
Example:
Show me the diff for PR #123 in owner/repo4. github_pr_post_review
Post a review comment to a GitHub pull request.
Parameters:
owner(string): Repository ownerrepo(string): Repository namepr_number(int): Pull request numberbody(string): Review comment textevent(string): "COMMENT", "APPROVE", or "REQUEST_CHANGES"commit_id(string, optional): Specific commit to review
Example:
Post a review comment to PR #123 in owner/repo saying "LGTM! Great work on the refactoring."5. github_pr_comprehensive_review
Perform comprehensive automated review of a GitHub pull request.
Parameters:
owner(string): Repository ownerrepo(string): Repository namepr_number(int): Pull request numberlocal_path(string, optional): Local path to cloned repositoryrun_tests(bool): Whether to run testspost_comments(bool): Auto-post review to GitHubresponse_format(string): "markdown" or "json"
Example:
Review PR #456 in myorg/myrepo. The local clone is at /home/user/myrepo. Run tests and post the review.Example Workflows
Workflow 1: Quick Static Analysis
User: Analyze the Go code in my-project/handlers/api.go
Claude will:
1. Use github_pr_analyze_code tool
2. Run golangci-lint, gofmt, and go vet
3. Return formatted results with any issues foundWorkflow 2: Test a Local Change
User: Run tests on my Go project at /home/user/awesome-app with coverage
Claude will:
1. Use github_pr_run_tests tool
2. Execute tests with coverage
3. Return test results and coverage percentagesWorkflow 3: Review a GitHub PR
User: Review PR #42 in acme/rocket-engine. Local copy is at /home/user/rocket-engine.
Claude will:
1. Use github_pr_get_diff to fetch PR changes
2. Identify changed Go files
3. Use github_pr_analyze_code on each changed file
4. Use github_pr_run_tests to run the test suite
5. Generate comprehensive review summary
6. Optionally post review to GitHub (if requested)Workflow 4: Complete Automated Review
User: Do a full automated review of PR #789 in myorg/backend-api, local path is /projects/backend-api, and post the results.
Claude will:
1. Use github_pr_comprehensive_review tool
2. Fetch PR diff
3. Analyze all changed Go files
4. Run full test suite
5. Generate review with recommendations
6. Post review comment to GitHub PRConfiguration
Environment Variables
Variable | Required | Description |
| Yes | GitHub Personal Access Token |
Tool-Specific Settings
You can customize analysis behavior by modifying the MCP server code:
# In github_pr_mcp.py
# Change default golangci-lint settings
lint_result = _run_command(
["golangci-lint", "run", "--config", ".golangci.yml", str(file_path)]
)
# Adjust test timeout
result = subprocess.run(
cmd,
timeout=600 # 10 minutes instead of 5
)Troubleshooting
Issue: "GITHUB_TOKEN environment variable not set"
Solution: Ensure the token is set in Claude Desktop config:
{
"mcpServers": {
"github-pr-reviewer": {
"env": {
"GITHUB_TOKEN": "ghp_your_actual_token"
}
}
}
}Issue: "golangci-lint: command not found"
Solution: Install golangci-lint and ensure it's in PATH:
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
export PATH=$PATH:$(go env GOPATH)/binIssue: MCP server not appearing in Claude Desktop
Solution:
Verify the config file path is correct for your OS
Check JSON syntax (use a JSON validator)
Ensure the Python script path is absolute
Restart Claude Desktop completely
Check Claude Desktop logs for errors
Issue: Tests failing with "no Go files in package"
Solution: Ensure you're running tests from the correct directory:
Set
local_pathparameter to repository rootCheck that test files exist and have
_test.gosuffix
Development
Running Tests
# Run Python tests
python -m pytest tests/
# Test MCP server directly
python github_pr_mcp.pyAdding New Tools
To add a new analysis tool:
Define a Pydantic input model
Create a helper function for the operation
Add an
@mcp.tooldecorated functionUpdate documentation
Example:
class NewToolInput(BaseModel):
param: str = Field(..., description="Parameter description")
@mcp.tool(name="github_pr_new_tool")
async def new_tool(params: NewToolInput) -> str:
"""Tool description."""
# Implementation
passCode Style
This project follows:
PEP 8 for Python code
Type hints for all functions
Pydantic models for input validation
Comprehensive docstrings
Security Best Practices
Never commit tokens: Keep
GITHUB_TOKENin environment variables onlyUse minimal permissions: Grant only necessary GitHub token scopes
Validate inputs: All inputs are validated via Pydantic models
Limit file access: Server only reads/writes to specified directories
Timeout operations: All commands have reasonable timeouts
Contributing
Contributions are welcome! Please:
Fork the repository
Create a feature branch
Add tests for new functionality
Ensure code passes linting
Submit a pull request
License
MIT License - see LICENSE file for details
Support
For issues and questions:
GitHub Issues: https://github.com/yourusername/github-pr-reviewer-mcp/issues
MCP Documentation: https://modelcontextprotocol.io/
Anthropic Discord: https://discord.gg/anthropic
Changelog
v1.0.0 (2025-02-07)
Initial release
Static code analysis support (golangci-lint, gofmt, go vet)
Test execution with coverage
GitHub PR integration
Comprehensive review workflow
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogā¦
This server cannot be deployed
Maintenance
Related MCP Connectors
Screens public GitHub repos and PRs to generate risk maps, findings, and merge-readiness signals.
GitHub security scanning, code audit, and workflow automation for repositories.
Monitor third-party API changes in GitHub repos, map breaks to files, open reviewable auto-fix PRs.
Diff gatekeeper, pre-merge review, unicode safety, SMT prover, dependency advisor.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables automated GitHub Pull Request reviews using local Ollama, Cursor CLI, or Gemini CLI as AI providers. Supports customizable review prompts, comprehensive PR analysis, and optional auto-posting of reviews to GitHub.5MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to perform comprehensive GitHub pull request code reviews, including analysis of code patterns, complexity, and security issues, while managing review comments and ensuring compliance with team coding standards.2MIT
- FlicenseAqualityDmaintenanceEnables analysis of GitHub Pull Requests, including details, diff, file lists, and review tracking.3-
- FlicenseAqualityDmaintenanceEnables fetching Pull Request diffs from GitHub and posting inline review comments directly on PRs, either as pending drafts or published immediately.2-