github-pr-mcp-server

denven/github-pr-mcp-server

3.2

If you are the rightful owner of github-pr-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.

An MCP server that integrates with GitHub PRs, CI/CD monitoring, and Slack notifications to automate development workflows.

Tools
  1. analyze_file_changes

    Retrieve git diff information and changed files.

  2. get_pr_templates

    List available PR templates.

  3. suggest_template

    Suggest the most appropriate PR template based on changes.

GitHub PR MCP Server for Claude Code

An MCP server that makes Claude Code team-aware and workflow-intelligent by integrating with GitHub PRs, CI/CD monitoring, and Slack notifications.

Overview

This project demonstrates how to build a comprehensive development automation system using MCP (Model Context Protocol) that transforms manual PR workflows into intelligent, automated processes.

Modules

The source code files are in .\starter folder for now.

Module 1: Smart PR Management

Build the foundation with three MCP tools:

  1. analyze_file_changes - Retrieve git diff information and changed files
  2. get_pr_templates - List available PR templates
  3. suggest_template - Allow Claude to suggest the most appropriate template

Module 2: GitHub Actions Workflow Integration

Extend the server with CI/CD monitoring:

  • Webhook server to receive GitHub Actions events
  • Tools for monitoring CI/CD status
  • MCP Prompts for consistent workflow patterns

Module 3: Slack Notification Integration

Complete the automation with team notifications:

  • Slack webhook tool for formatted messages
  • Intelligent notification prompts
  • Full integration of all MCP primitives

Setup

1. Install uv

Follow the official installation instructions at: https://docs.astral.sh/uv/getting-started/installation/

2. Install dependencies

# Install all dependencies
uv sync

# Or install with dev dependencies for testing
uv sync --all-extras

3. Start implementing!

Open server.py and follow the TODO comments to implement each tool.

Note: The starter code includes stub implementations that return "Not implemented" errors. This allows you to:

  • Run the server immediately
  • Test your setup with Claude
  • Replace each stub with your actual implementation
  • See helpful hints about what each tool should do

Design Philosophy

Instead of using rigid rules based on file extensions or patterns, your tools should provide Claude with raw git data and let Claude's intelligence determine:

  • What type of change is being made
  • Which template is most appropriate
  • How to customize the template for the specific changes

Getting Started

Module 1: Basic PR Tools

  1. Open server.py and implement the three tools following the TODO comments

  2. Test with: uv run pytest test_server.py -v

  3. Configure in Claude Code:

    claude mcp add pr-agent -- uv --directory /absolute/path/to/starter run server.py
    

Module 2: GitHub Actions Integration

  1. Set up webhook server (webhook_server.py) on port 8080
  2. Configure GitHub webhook to send Actions events
  3. Use Cloudflare Tunnel for local development
  4. Implement CI/CD monitoring tools

Module 3: Slack Notifications

  1. Configure Slack webhook URL
  2. Implement send_slack_notification tool
  3. Create notification prompts for success/failure events
  4. Test end-to-end workflow automation

Real-World Benefits

Transform manual workflows:

  • Before: Manually create PRs, wait for CI/CD, check results, notify team
  • After: Claude intelligently suggests templates, monitors pipelines, and alerts team automatically

Key Interaction Patterns

🔄 Tool Composition Pattern

Claude Code intelligently combines multiple MCP tools to accomplish complex tasks:

  • analyze_file_changes → suggest_template for PR workflow
  • get_recent_actions_events → get_workflow_status → send_slack_notification for CI monitoring

🎯 Prompt-Guided Intelligence

MCP Prompts provide structured workflows that guide Claude through multi-step processes:

  • Templates for consistent Slack formatting
  • Step-by-step troubleshooting guidance
  • Automated decision-making patterns

⚡ Event-Driven Architecture

  • GitHub webhooks provide real-time CI/CD event data
  • Webhook server runs independently on port 8080
  • Events stored locally for rapid access by MCP tools

🔧 Modular Design

  • Module 1: Git analysis and PR template management
  • Module 2: CI/CD monitoring and workflow analysis
  • Module 3: Slack integration and team notifications
  • Shared: Configuration and utilities for consistency

📊 Data Flow Summary

  1. Input: Developer requests via Claude Code
  2. Processing: MCP tools gather data from Git, GitHub events, templates
  3. Intelligence: Claude analyzes data using provided prompts
  4. Output: Formatted responses, Slack notifications, actionable insights
  5. Feedback: Team receives notifications, workflow improves

This architecture demonstrates a sophisticated integration that transforms manual development workflows into intelligent, automated processes while maintaining human
oversight and control.

✅ How it works (Sequence Diagram)

sequenceDiagram
      participant User as 👤 Developer
      participant Claude as 🤖 Claude Code
      participant MCP as 📡 MCP Server
      participant PR as 🔧 PR Tools
      participant Git as 📚 Git Repository
      participant Templates as 📄 PR Templates
      participant GHA as ⚙️ GitHub Actions
      participant Webhook as 🎣 Webhook Server
      participant GitHub as 🐙 GitHub
      participant Events as 📊 Events Storage
      participant Slack as 💬 Slack Integration
      participant SlackAPI as 📢 Slack API
      participant Team as 👥 Team Channel

      Note over User, Team: PR Agent Workflow - Complete Interaction Flow

      %% Scenario 1: PR Analysis and Template Suggestion
      rect rgb(240, 248, 255)
          Note over User, Claude: Scenario 1: PR Creation Workflow
          User->>Claude: "Analyze my changes and suggest a PR template"
          Claude->>MCP: Call analyze_file_changes tool
          MCP->>PR: analyze_file_changes(base_branch="main")
          PR->>Git: git diff --name-status main...HEAD
          Git-->>PR: Changed files list
          PR->>Git: git diff main...HEAD
          Git-->>PR: Full diff content
          PR-->>MCP: JSON response with changes
          MCP-->>Claude: File changes data

          Claude->>MCP: Call suggest_template tool
          MCP->>PR: suggest_template(changes_summary, change_type)
          PR->>Templates: Read template files
          Templates-->>PR: Template content
          PR-->>MCP: Template suggestion with content
          MCP-->>Claude: Template recommendation

          Claude-->>User: "Based on your changes, I suggest using the 'feature' template..."
      end

      %% Scenario 2: CI/CD Monitoring
      rect rgb(255, 248, 240)
          Note over GitHub, Team: Scenario 2: CI/CD Monitoring Workflow
          GitHub->>Webhook: POST /webhook/github (workflow_run event)
          Webhook->>Events: Store event in github_events.json

          User->>Claude: "Check the CI/CD status"
          Claude->>MCP: Call get_recent_actions_events tool
          MCP->>GHA: get_recent_actions_events(limit=10)
          GHA->>Events: Read github_events.json
          Events-->>GHA: Recent workflow events
          GHA-->>MCP: Events data
          MCP-->>Claude: CI/CD events

          Claude->>MCP: Call get_workflow_status tool
          MCP->>GHA: get_workflow_status()
          GHA->>Events: Filter workflow_run events
          Events-->>GHA: Workflow status data
          GHA-->>MCP: Current workflow states
          MCP-->>Claude: Workflow status summary

          Claude-->>User: "Your CI pipeline is failing on test-auth-service..."
      end

      %% Scenario 3: Automated Slack Notification
      rect rgb(248, 255, 248)
          Note over Claude, Team: Scenario 3: Slack Notification Workflow
          Claude->>MCP: Use notify_ci_status_to_slack prompt
          MCP->>GHA: Check recent events for failures
          GHA-->>MCP: Failed workflow detected

          Claude->>MCP: Use format_ci_failure_alert prompt
          MCP-->>Claude: Slack markdown template

          Claude->>MCP: Call send_slack_notification tool
          MCP->>Slack: send_slack_notification(formatted_message)
          Slack->>SlackAPI: POST to webhook URL
          SlackAPI->>Team: Deliver formatted alert

          Note over Team: ❌ CI Failed - Repository Name<br/>Workflow: test-pipeline<br/>Branch: feature-branch<br/>🔗 View Action Logs

          Slack-->>MCP: Success response
          MCP-->>Claude: Notification sent confirmation
          Claude-->>User: "Slack notification sent to team channel"
      end

      %% Scenario 4: Daily Summary Automation
      rect rgb(255, 240, 255)
          Note over User, Team: Scenario 4: Daily CI Summary
          User->>Claude: "Generate daily CI summary for the team"
          Claude->>MCP: Use daily_ci_summary_to_slack prompt
          MCP->>GHA: get_recent_actions_events(limit=50)
          GHA-->>MCP: Today's CI activity

          Claude->>MCP: Analyze patterns and create summary
          MCP->>Slack: send_slack_notification(daily_summary)
          Slack->>SlackAPI: POST formatted daily report
          SlackAPI->>Team: Deliver summary

          Note over Team: 📊 Daily CI/CD Report<br/>Total runs: 25<br/>Success rate: 80%<br/>Failed workflows: 3<br/>Action items: Fix test-auth

          Claude-->>User: "Daily summary sent to team"
      end

      %% Configuration and Error Handling
      rect rgb(248, 248, 248)
          Note over MCP, Slack: Configuration & Error Handling
          Note over PR: Uses config.py for:<br/>- Template paths<br/>- Default values<br/>- Git settings
          Note over GHA: Uses config.py for:<br/>- Events file path<br/>- Limits & timeouts
          Note over Slack: Uses config.py for:<br/>- Webhook URL<br/>- Message formatting<br/>- Timeout settings
          Note over MCP: Uses utils.py for:<br/>- JSON formatting<br/>- File operations<br/>- Input validation<br/>- Error handling
      end