Enhanced PR Comments Resolver MCP Server
Fetches GitHub PR comments and intelligently applies fixes directly in workspace files, supporting automatic issue resolution with smart pattern recognition.
README
š Enhanced PR Comments Resolver - MCP Server v2.1
A comprehensive Model Context Protocol (MCP) server that not only fetches GitHub PR comments but also intelligently applies and fixes them directly in your workspace files. This enhanced version includes smart pattern recognition, similar comment linking, and automated issue resolution capabilities optimized for Cursor IDE.
⨠Enhanced Features
š Comprehensive Comment Processing
- Fetches all types of PR comments (issue, review, and general comments)
- Intelligent comment analysis and categorization
- Priority-based comment filtering (High/Medium/Low priority)
- Actionable vs non-actionable comment detection
- š§ Smart pattern recognition across similar comments
- š Comment linking for consistent fixes across files
šÆ Direct File Modification & Intelligent Fixing
- Apply comments directly to files in your current workspace
- š¤ Automatic issue resolution based on comment content
- š "Apply everywhere" support for project-wide changes
- Intelligent workspace detection (Git repos, package.json, pyproject.toml, etc.)
- Safe file operations with optional automatic backups
- Batch processing of multiple comments
- Dry-run mode for testing changes
- š§ Smart fixes for: imports, naming, types, formatting, removal, and more
š§ Enhanced Prompt Generation
- Cursor IDE optimized prompts with enhanced formatting
- Multiple format types: Cursor, JSON, Markdown, Structured
- Context-aware suggestions with file path resolution
- Intelligent action categorization (Bug Fix, Refactor, Style, etc.)
- Enhanced code context with syntax highlighting
š Comment Embedding
- Embed PR comments as hidden comments directly in source files
- Track applied suggestions with metadata
- Reference original comment URLs and authors
- Maintain audit trail of changes
š§ Workspace Intelligence
- Automatic workspace root detection
- Project structure analysis
- Language detection and file type support
- Intelligent file path resolution
š Installation
-
Clone or download this repository
-
Install dependencies using uv (recommended):
cd pr-comments-resolver uv syncOr using pip:
pip install -r requirements.txt -
Set up GitHub token (see GitHub Token Setup section)
š GitHub Token Setup
Why You Need a GitHub Token
- Higher Rate Limits: 5,000 requests/hour vs 60 requests/hour
- Private Repository Access: Access private repos with proper permissions
- Better Error Handling: More detailed API responses
Getting a GitHub Token
- Go to GitHub Settings > Developer settings > Personal access tokens
- Click "Generate new token (classic)"
- Select scopes:
public_repo(andrepofor private repositories) - Copy the token immediately
Setting Up the Token
Method 1: Environment Variable (Recommended)
export GITHUB_TOKEN="your_token_here"
Method 2: MCP Client Configuration
For Cursor (add to your MCP settings):
{
"mcpServers": {
"pr-comments-resolver": {
"command": "python",
"args": ["/path/to/pr-comments-resolver/main.py"],
"env": {
"GITHUB_TOKEN": "your_token_here"
}
}
}
}
š Quick Start
┠ONE-CLICK WORKFLOW (RECOMMENDED) ⨠NEW!
# Complete everything in one go - no redundant API calls!
complete_pr_workflow("https://github.com/owner/repo/pull/123", dry_run=True)
# Apply everything after preview
complete_pr_workflow("https://github.com/owner/repo/pull/123", dry_run=False)
This unified tool:
- š Sets up workspace automatically
- š„ Fetches PR comments (with smart caching)
- š Embeds comments in files
- š§ Intelligently fixes all issues
- š Links similar patterns across files
- š Applies "everywhere" comments to all PR files
š§ INDIVIDUAL TOOLS (If you need granular control)
Step 1: Embed PR Comments
# In Cursor IDE, use the MCP tool to embed comments in files
resolve_pr_comments("https://github.com/owner/repo/pull/123", dry_run=True)
Step 2: Intelligent Fix & Check
# Automatically check and fix issues mentioned in comments
check_and_fix_applied_comments("https://github.com/owner/repo/pull/123", dry_run=True)
# Apply the fixes
check_and_fix_applied_comments("https://github.com/owner/repo/pull/123", dry_run=False)
Step 3: Focus on Specific Files
# Check and fix comments for a specific file
check_specific_file_comments("https://github.com/owner/repo/pull/123", "src/components/Button.tsx", dry_run=False)
What You Get
The system will automatically:
- šÆ Embed comments at the right locations in your code
- š Detect similar patterns across multiple comments
- š§ Apply fixes intelligently based on comment content
- š Handle "everywhere" comments across all PR files
- š Link related comments for consistent fixes
Example embedded comment:
/**
* PR Comment from @reviewer: you can use theme token here
* Comment ID: 123456
* Line: ~42
*/
const color = '#ff0000'; // ā This will be automatically fixed!
After running check_and_fix_applied_comments:
const color = theme.colors.primary; // ā Automatically fixed!
š® Usage
Running the MCP Server
python main.py
Available Tools
š Core Functionality
detect_workspace
Automatically detect and analyze your current workspace.
{
"tool": "detect_workspace",
"arguments": {}
}
set_workspace_path
Set a custom workspace path for file operations.
{
"tool": "set_workspace_path",
"arguments": {
"workspace_path": "/path/to/your/project"
}
}
fetch_pr_comments_tool
Fetch all comments from a GitHub PR with enhanced processing.
{
"tool": "fetch_pr_comments_tool",
"arguments": {
"pr_url": "https://github.com/owner/repo/pull/123"
}
}
complete_pr_workflow š NEW! (RECOMMENDED)
Complete PR comment resolution workflow in one step with smart caching.
{
"tool": "complete_pr_workflow",
"arguments": {
"pr_url": "https://github.com/owner/repo/pull/123",
"workspace_path": "/optional/custom/path",
"dry_run": true
}
}
What it does:
- š Sets up workspace (auto-detected or custom)
- š„ Fetches PR comments (with 5min smart caching)
- š Embeds comments in files at correct locations
- š§ Intelligently fixes all detected issues
- š Links similar comments for consistent fixes
- š Applies "everywhere" comments across all PR files
resolve_pr_comments ⨠NEW!
Embed PR comments directly in your source files at specific locations.
{
"tool": "resolve_pr_comments",
"arguments": {
"pr_url": "https://github.com/owner/repo/pull/123",
"dry_run": true
}
}
check_and_fix_applied_comments ⨠NEW!
Intelligently check and fix issues mentioned in PR comments after they're applied.
{
"tool": "check_and_fix_applied_comments",
"arguments": {
"pr_url": "https://github.com/owner/repo/pull/123",
"dry_run": true
}
}
Features:
- š Links similar comments across files
- š Applies "everywhere" comments to all PR files
- š§ Intelligent pattern recognition and fixing
- šÆ Handles imports, naming, types, formatting, and more
check_specific_file_comments ⨠NEW!
Check and fix comments for a specific file.
{
"tool": "check_specific_file_comments",
"arguments": {
"pr_url": "https://github.com/owner/repo/pull/123",
"file_path": "src/components/Button.tsx",
"dry_run": true
}
}
š ļø Utility Tools
clear_pr_cache ⨠NEW!
Clear cached PR comments data to force fresh API calls.
{
"tool": "clear_pr_cache",
"arguments": {
"pr_url": "https://github.com/owner/repo/pull/123"
}
}
Cache Features:
- š Smart caching with 5-minute TTL
- šļø Clear specific PR cache or all cached data
- ā” Eliminates redundant API calls within the same session
- š Automatic cache invalidation
šÆ Enhanced Prompt Generation
generate_cursor_prompt
Generate optimized prompts for Cursor IDE with intelligent formatting.
{
"tool": "generate_cursor_prompt",
"arguments": {
"pr_url": "https://github.com/owner/repo/pull/123",
"format_type": "cursor"
}
}
Format Types:
"cursor"- Optimized for Cursor IDE with enhanced formatting"json"- Structured JSON format for automated processing"markdown"- Clean markdown format for documentation"structured"- Advanced structured format with metadata
š§ Direct File Modification
apply_pr_comments
Apply all actionable PR comments directly to your workspace files.
{
"tool": "apply_pr_comments",
"arguments": {
"pr_url": "https://github.com/owner/repo/pull/123",
"dry_run": true
}
}
apply_single_comment
Apply a specific comment to a file.
{
"tool": "apply_single_comment",
"arguments": {
"pr_url": "https://github.com/owner/repo/pull/123",
"comment_id": "987654321",
"dry_run": false
}
}
š Comment Integration
embed_comments_in_files
Embed PR comments as hidden comments directly in source files.
{
"tool": "embed_comments_in_files",
"arguments": {
"pr_url": "https://github.com/owner/repo/pull/123"
}
}
get_file_context
Get enhanced context around specific lines in files.
{
"tool": "get_file_context",
"arguments": {
"file_path": "src/main.py",
"line_number": 42,
"context_lines": 10
}
}
šÆ Intelligent Comment Processing
Comment Categorization
The server automatically categorizes comments by:
- Priority Levels: š“ HIGH, š” MEDIUM, š¢ LOW, āŖ REVIEW
- Action Types: š BUG_FIX, š§ REFACTOR, ā ADD_FEATURE, ā REMOVE, šØ STYLE, ā” OPTIMIZE, š DISCUSS
Supported Actions
- Variable/function renaming
- Import statement additions
- Typo corrections
- Docstring additions
- Type hint improvements
- Code removal/cleanup
- Style formatting
š Example Workflows
1. Quick PR Review Analysis
# 1. Detect workspace
detect_workspace()
# 2. Generate Cursor-optimized prompt
generate_cursor_prompt("https://github.com/owner/repo/pull/123", "cursor")
# 3. Review the generated prompt in Cursor
2. Apply Comments to Workspace
# 1. Test changes with dry run
apply_pr_comments("https://github.com/owner/repo/pull/123", dry_run=true)
# 2. Apply actual changes
apply_pr_comments("https://github.com/owner/repo/pull/123", dry_run=false)
# 3. Embed comments for reference
embed_comments_in_files("https://github.com/owner/repo/pull/123")
3. Selective Comment Application
# 1. Fetch all comments
fetch_pr_comments_tool("https://github.com/owner/repo/pull/123")
# 2. Apply specific high-priority comment
apply_single_comment("https://github.com/owner/repo/pull/123", "comment_id", false)
š Safety Features
File Safety
- Automatic Backups: Creates timestamped backups before modifications
- Dry Run Mode: Test changes without modifying files
- Error Recovery: Graceful handling of file operation errors
- Encoding Detection: Handles multiple file encodings safely
Change Validation
- Syntax Preservation: Maintains code syntax and structure
- Incremental Changes: Makes focused, atomic modifications
- Change Tracking: Adds metadata comments for audit trails
- Rollback Support: Easy restoration from backups
šØ Enhanced Cursor Integration
The generated prompts are specifically optimized for Cursor IDE with:
- Visual Hierarchy: Enhanced formatting with emojis and structure
- Code Context: Syntax-highlighted code blocks with line numbers
- Action Guidance: Step-by-step implementation instructions
- Priority Indicators: Clear visual priority and action type indicators
- File Navigation: Direct file paths and line number references
š Response Format
All tools return comprehensive JSON responses with:
{
"success": true,
"workspace_path": "/path/to/workspace",
"pr_info": {
"owner": "username",
"repo": "repository",
"pr_number": 123,
"url": "https://github.com/username/repository/pull/123"
},
"results": {
"total_comments": 15,
"actionable_comments": 8,
"successful": 6,
"failed": 0,
"skipped": 2
},
"details": [...]
}
š Development
Project Structure
pr-comments-resolver/
āāā main.py # Enhanced MCP server with all tools
āāā modules/
ā āāā __init__.py # Module initialization
ā āāā prompt_generator.py # Enhanced prompt generation
ā āāā file_manager.py # Workspace and file operations
āāā pyproject.toml # Dependencies and project config
āāā README.md # This file
āāā uv.lock # Dependency lock file
Dependencies
httpx- Async HTTP client for GitHub APImcp[cli]- Model Context Protocol frameworkaiofiles- Async file operationspathlib2- Enhanced path handling (Python < 3.11)
Development Setup
# Install development dependencies
uv sync --dev
# Run linting
black .
flake8 .
mypy .
# Run tests
pytest
š Migration from v1.0
If you're upgrading from the basic version:
- Backup your current setup
- Update dependencies:
uv sync - New tools available: All file modification and prompt generation tools
- Enhanced responses: More detailed JSON responses with workspace context
- Workspace detection: Automatic detection replaces manual path setting
š¤ Contributing
- Fork the repository
- Create a feature branch
- Make your changes with tests
- Ensure code quality (black, flake8, mypy)
- Submit a pull request
š License
This project is open source. Please check the license file for details.
š Troubleshooting
Common Issues
Workspace not detected
# Manually set workspace path
set_workspace_path("/path/to/your/project")
File not found errors
- Ensure you're running from the correct directory
- Check file paths are relative to workspace root
- Verify files exist in the detected workspace
Permission errors
- Ensure write permissions in workspace directory
- Check GitHub token has appropriate repository permissions
Rate limiting
- Set up GitHub token for higher limits
- Implement delays between batch operations
Debug Mode
Enable detailed logging by setting environment variable:
export LOG_LEVEL=DEBUG
python main.py
š What's New in v2.0
- ā Direct file modification with intelligent change application
- ā Enhanced Cursor prompts with visual formatting and context
- ā Workspace intelligence with automatic detection
- ā Comment embedding in source files for reference
- ā Batch processing with progress tracking
- ā Safety features including backups and dry-run mode
- ā Modular architecture for easier maintenance
- ā Comprehensive error handling and validation
- ā Multiple prompt formats for different use cases
- ā Enhanced metadata and tracking capabilities
Transform your PR review workflow with intelligent automation! š
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.