abhinandanmishra1/mcp-server
If you are the rightful owner of mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
The GitHub PR Comment Resolver is a production-grade local MCP server designed to automate the resolution of GitHub PR review comments using LLM-based code resolution.
GitHub PR Comment Resolver - MCP Server
A production-grade local MCP (Model Context Protocol) server that automates the resolution of GitHub PR review comments by fetching comments via GitHub API and generating structured prompts for LLM-based code resolution.
šÆ Features
- FastAPI-based MCP Server with RESTful endpoints
- GitHub API Integration to fetch PR comments and file content
- Multi-format Prompt Generation (Cursor, JSON, Markdown)
- Bot Filtering and user-specific comment processing
- File Context Enhancement with diff hunks and code snippets
- CLI Interface for command-line usage
- Background Processing for automated change application
- Production-ready with proper error handling, logging, and configuration
š Quick Start
1. Installation
# Clone and setup
git clone <your-repo>
cd cursor-pr-fix
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
2. Configuration
# Copy environment template
cp .env.example .env
# Edit .env with your GitHub token
GITHUB_TOKEN=your_github_token_here
Get GitHub Token:
- Go to GitHub Settings > Developer settings > Personal access tokens
- Create new token with
repo
scope - Copy token to
.env
file
3. Usage Options
Option A: CLI (Recommended for first use)
# Generate Cursor-compatible prompt
python cli.py generate-prompt https://github.com/owner/repo/pull/123
# With options
python cli.py generate-prompt https://github.com/owner/repo/pull/123 \
--format-type cursor \
--skip-bots \
--dry-run
# Apply changes directly (placeholder implementation)
python cli.py apply-changes https://github.com/owner/repo/pull/123 --dry-run
# Check status
python cli.py status
Option B: MCP Server
# Start server
python cli.py start-server
# Or directly
python server.py
Server will run on http://127.0.0.1:8000
with API docs at /docs
Option C: API Calls
# Generate prompt via API
curl -X POST "http://127.0.0.1:8000/generate-cursor-task" \
-H "Content-Type: application/json" \
-d '{
"pr_url": "https://github.com/owner/repo/pull/123",
"format_type": "cursor",
"skip_bots": true
}'
š Project Structure
cursor-pr-fix/
āāā server.py # FastAPI MCP server
āāā cli.py # Command-line interface
āāā requirements.txt # Python dependencies
āāā .env.example # Environment variables template
āāā handlers/
ā āāā __init__.py
ā āāā github.py # GitHub API interactions
āāā prompt/
ā āāā __init__.py
ā āāā generator.py # Prompt generation logic
āāā utils/
ā āāā __init__.py
ā āāā file_manager.py # File operations and change application
āāā pr_prompts/ # Generated prompt files (auto-created)
š§ Configuration
Environment Variables
Variable | Description | Default |
---|---|---|
GITHUB_TOKEN | GitHub personal access token | Required |
SERVER_HOST | Server host address | 127.0.0.1 |
SERVER_PORT | Server port | 8000 |
LOG_LEVEL | Logging level | INFO |
API Endpoints
Endpoint | Method | Description |
---|---|---|
/ | GET | Health check |
/generate-cursor-task | POST | Generate structured prompts |
/apply-changes | POST | Apply suggestions to files |
/status | GET | Server status |
š Request/Response Format
Generate Prompt Request
{
"pr_url": "https://github.com/owner/repo/pull/123",
"dry_run": false,
"only_user": "username",
"skip_bots": true,
"auto_apply": false,
"format_type": "cursor"
}
Response
{
"success": true,
"message": "Generated prompt for 5 comments",
"comments_found": 5,
"prompt_file": "cursor_prompt_repo_123.txt",
"changes_applied": [],
"errors": []
}
šØ Output Formats
1. Cursor Format (Default)
Optimized for Cursor IDE with:
- Structured markdown sections
- Code context with syntax highlighting
- Actionable suggestions
- Best practices guidelines
2. JSON Format
Structured data for programmatic processing:
{
"task": "resolve_pr_comments",
"metadata": { ... },
"comments": [ ... ]
}
3. Markdown Format
Clean markdown for documentation or review.
š Workflow Integration
With Cursor IDE
-
Generate Prompt:
python cli.py generate-prompt <PR_URL>
-
Copy & Paste:
- Open generated
.txt
file - Copy content to Cursor chat
- Let LLM analyze and apply changes
- Open generated
-
Review Changes:
- LLM will explain reasoning
- Apply suggested modifications
- Review diffs before committing
Automated Workflow
# Generate and apply in one step (when implemented)
python cli.py generate-prompt <PR_URL> --auto-apply
š ļø Development
Adding Custom Handlers
-
New Comment Processors:
# In handlers/custom.py class CustomHandler: async def process_comment(self, comment: Dict) -> Dict: # Custom logic return processed_comment
-
New Prompt Formats:
# In prompt/generator.py async def _generate_custom_prompt(self, comments, pr_info): # Custom format implementation return formatted_prompt
Testing
# Test with dry run
python cli.py generate-prompt <PR_URL> --dry-run
# Check status
python cli.py status
# Test API
curl http://127.0.0.1:8000/status
š Security
- GitHub tokens are stored in environment variables
- No sensitive data in logs
- Rate limiting respected for GitHub API
- CORS configured for local development only
š Logging
Logs include:
- API request/response details
- GitHub API interactions
- File operation results
- Error details with context
Configure via LOG_LEVEL
environment variable.
š¤ Contributing
- Fork the repository
- Create feature branch
- Add tests for new functionality
- Submit pull request
š License
MIT License - see LICENSE file for details.
š Troubleshooting
Common Issues
-
GitHub Token Errors:
- Verify token has
repo
scope - Check token hasn't expired
- Ensure token is in
.env
file
- Verify token has
-
API Rate Limits:
- GitHub API has rate limits
- Server respects pagination
- Consider GitHub Apps for higher limits
-
File Not Found:
- Ensure PR branch files exist locally
- Check file paths in comments match local structure
Debug Mode
python cli.py --verbose generate-prompt <PR_URL>
For more help, check the /docs
endpoint when server is running.