Skip to content

GitHub MCP ByteBuddy Cookbook

This cookbook provides practical recipes for integrating ByteBuddy with GitHub using the Model Context Protocol (MCP). Learn how to automate issue creation, pull request reviews, documentation updates, and more.

What is MCP?

The Model Context Protocol (MCP) is a standard protocol that allows AI models to securely interact with external tools and services. With MCP, ByteBuddy can:

  • Access GitHub Data: Read repositories, issues, pull requests, and discussions
  • Perform Actions: Create issues, comment on PRs, and update documentation
  • Maintain Security: All interactions are secure and authorized
  • Enable Automation: Automate complex workflows across GitHub

Prerequisites

GitHub Account Setup

Ensure you have:

  1. GitHub Account with appropriate permissions
  2. Personal Access Token for authentication
  3. Repository Access for target repositories
  4. GitHub App (recommended for organization-wide access)

MCP Configuration

Configure MCP in ByteBuddy:

yaml
# .bytebuddy/config.yaml
mcp:
  enabled: true
  servers:
    - name: "github-mcp"
      uri: "mcp://github-plugin"
      autoConnect: true

tools:
  - name: "github-integration"
    tool: "mcp/github-mcp"
    args:
      baseUrl: "https://api.github.com"
      token: "${GITHUB_TOKEN}"
      owner: "your-organization"

Recipe 1: Automated Issue Creation

Problem

Manually creating GitHub issues for bugs, features, and tasks is time-consuming.

Solution

Automatically create GitHub issues based on code analysis or user requests:

yaml
tools:
  - name: "create-github-issue"
    tool: "mcp/github-mcp"
    args:
      action: "createIssue"
      repo: "{{repository}}"
      title: "{{issue_title}}"
      body: |
        ## Issue Description
        {{issue_description}}

        ## Technical Details
        **File**: {{file_path}}
        **Line**: {{line_number}}
        **Function**: {{function_name}}

        ## Suggested Solution
        {{suggested_solution}}

        ## Additional Context
        {{additional_context}}

        _Automatically generated by ByteBuddy_
      labels:
        - "automated"
        - "bytebuddy"
        - "{{issue_type}}"
      assignees:
        - "{{assignee}}"

Usage Example

yaml
continuousAI:
  enabled: true
  workflows:
    - name: "issue-automation"
      trigger:
        eventType: "codeAnalysis"
        severity: "high"
      actions:
        - action: "createToolCall"
          tool: "create-github-issue"
          parameters:
            repository: "{{target_repo}}"
            issue_title: "Security vulnerability in {{file_name}}"
            issue_description: "{{vulnerability_details}}"
            file_path: "{{vulnerable_file}}"
            line_number: "{{vulnerable_line}}"
            suggested_solution: "{{fix_recommendation}}"
            issue_type: "security"
            assignee: "{{maintainer}}"

Advanced Issue Templates

Create detailed issue templates for different scenarios:

yaml
tools:
  - name: "create-bug-report"
    tool: "mcp/github-mcp"
    args:
      action: "createIssue"
      repo: "{{repository}}"
      title: "🐛 Bug: {{bug_summary}}"
      body: |
        ## Bug Report

        **Description**: {{bug_description}}

        **Steps to Reproduce**:
        1. {{step_1}}
        2. {{step_2}}
        3. {{step_3}}

        **Expected Behavior**: {{expected_behavior}}

        **Actual Behavior**: {{actual_behavior}}

        **Environment**:
        - OS: {{operating_system}}
        - Browser: {{browser}}
        - Version: {{version}}

        **Additional Context**:
        {{additional_context}}

        **Screenshots**:
        ![Screenshot]({{screenshot_url}})

        **Stack Trace**:
        ```
        {{stack_trace}}
        ```
      labels:
        - "bug"
        - "triage"
        - "{{component}}"
      milestone: "{{milestone}}"

Recipe 2: Intelligent Pull Request Reviews

Problem

Manual code reviews are inconsistent and may miss important issues.

Solution

Enhance GitHub pull request reviews with AI-powered insights:

yaml
tools:
  - name: "github-pr-review"
    tool: "mcp/github-mcp"
    args:
      action: "reviewPullRequest"
      repo: "{{repository}}"
      pullNumber: "{{pr_number}}"
      comments:
        - path: "{{file_path}}"
          position: "{{line_number}}"
          body: |
            🔍 **Code Review Comment**

            **Issue**: {{issue_description}}

            **Severity**: {{severity_level}}

            **Suggestion**: {{improvement_suggestion}}

            **Best Practice**: {{related_best_practice}}

            _Reviewed by ByteBuddy AI_
      event: "COMMENT" # or "APPROVE" or "REQUEST_CHANGES"
      body: |
        ## Pull Request Review Summary

        **Overall Assessment**: {{overall_rating}}/10

        **Key Findings**:
        {{#each findings}}
        - {{finding_description}} ({{severity}})
        {{/each}}

        **Recommendations**:
        {{#each recommendations}}
        - {{recommendation}}
        {{/each}}

Usage Example

yaml
integrations:
  github:
    prReviewBot:
      enabled: true
      workflows:
        - name: "ai-code-review"
          trigger:
            eventType: "pullRequest"
            actions: ["opened", "synchronize"]
          actions:
            - action: "analyzeCodeChanges"
            - action: "createToolCall"
              tool: "github-pr-review"
              parameters:
                repository: "{{repo_name}}"
                pr_number: "{{pr_id}}"
                file_path: "{{changed_file}}"
                line_number: "{{changed_line}}"
                issue_description: "{{detected_issue}}"
                severity_level: "{{issue_severity}}"
                improvement_suggestion: "{{suggestion}}"

Detailed Review Configuration

Configure comprehensive review settings:

yaml
tools:
  - name: "comprehensive-pr-review"
    tool: "mcp/github-mcp"
    args:
      action: "reviewPullRequest"
      repo: "{{repository}}"
      pullNumber: "{{pr_number}}"
      reviewSettings:
        categories:
          - "security"
          - "performance"
          - "maintainability"
          - "best-practices"
          - "accessibility"
        depth: "thorough"
        confidenceThreshold: 0.8
        maxComments: 25
        format: "detailed"
      labelsToAdd:
        - "ai-reviewed"
        - "needs-human-review"

Recipe 3: Documentation Automation

Problem

Keeping documentation in sync with code changes is challenging.

Solution

Automatically update documentation when code changes:

yaml
tools:
  - name: "update-readme"
    tool: "mcp/github-mcp"
    args:
      action: "updateFile"
      repo: "{{repository}}"
      path: "README.md"
      message: "docs: update documentation for {{feature_name}}"
      content: |
        # {{project_name}}

        {{project_description}}

        ## Features
        {{#each features}}
        - {{feature}}
        {{/each}}

        ## Installation
        ```bash
        {{installation_instructions}}
        ```

        ## Usage
        {{#each usage_examples}}
        ### {{example_title}}
        {{example_description}}
        ```{{language}}
        {{code_example}}
        ```
        {{/each}}

        ## API Reference
        {{api_reference}}

        ## Contributing
        {{contributing_guide}}

        ## License
        {{license_info}}

        _Documentation automatically generated by ByteBuddy_
      sha: "{{current_file_sha}}" # Required for updates

Usage Example

yaml
continuousAI:
  enabled: true
  workflows:
    - name: "documentation-sync"
      trigger:
        eventType: "releasePublished"
      actions:
        - action: "extractDocumentation"
        - action: "generateApiDocs"
        - action: "createToolCall"
          tool: "update-readme"
          parameters:
            repository: "{{repo_name}}"
            project_name: "{{project_display_name}}"
            project_description: "{{project_summary}}"
            features: "{{project_features}}"
            installation_instructions: "{{install_steps}}"
            usage_examples: "{{code_examples}}"
            api_reference: "{{api_docs}}"
            contributing_guide: "{{contributing_info}}"
            license_info: "{{license_details}}"
            current_file_sha: "{{readme_sha}}"

Recipe 4: Release Management

Problem

Managing releases involves multiple manual steps and coordination.

Solution

Automate release management workflows:

yaml
tools:
  - name: "create-release"
    tool: "mcp/github-mcp"
    args:
      action: "createRelease"
      repo: "{{repository}}"
      tagName: "v{{version}}"
      name: "Release {{version}}"
      body: |
        ## 🎉 Version {{version}} Released!

        {{release_highlights}}

        ### 🚀 New Features
        {{#each new_features}}
        - {{feature_description}}
        {{/each}}

        ### 🐛 Bug Fixes
        {{#each bug_fixes}}
        - {{fix_description}}
        {{/each}}

        ### 📈 Performance Improvements
        {{#each perf_improvements}}
        - {{improvement_description}}
        {{/each}}

        ### 📚 Documentation Updates
        {{#each doc_updates}}
        - {{update_description}}
        {{/each}}

        ### 🔧 Breaking Changes
        {{#each breaking_changes}}
        - {{change_description}}
        {{/each}}

        ### 📦 Assets
        {{#each assets}}
        - [{{asset_name}}]({{asset_url}}) - {{asset_size}}
        {{/each}}

        ### 🙏 Thanks
        Thanks to all our contributors for making this release possible!

        _Released on {{release_date}}_
      draft: false
      prerelease: "{{is_prerelease}}"
      targetCommitish: "{{target_branch}}"

Advanced Release Workflow

Create comprehensive release management:

yaml
continuousAI:
  enabled: true
  workflows:
    - name: "release-management"
      trigger:
        eventType: "versionBump"
      actions:
        # 1. Generate changelog
        - action: "generateChangelog"
          parameters:
            fromTag: "{{previous_version}}"
            toTag: "{{new_version}}"

        # 2. Update version files
        - action: "updateVersionFiles"
          parameters:
            version: "{{new_version}}"

        # 3. Create release
        - action: "createToolCall"
          tool: "create-release"
          parameters:
            repository: "{{repo_name}}"
            version: "{{new_version}}"
            release_highlights: "{{highlights}}"
            new_features: "{{features}}"
            bug_fixes: "{{fixes}}"
            perf_improvements: "{{perf_gains}}"
            doc_updates: "{{doc_changes}}"
            breaking_changes: "{{breaking}}"
            assets: "{{release_assets}}"
            is_prerelease: "{{prerelease}}"
            target_branch: "{{target}}"
            release_date: "{{today}}"

Recipe 5: Issue Triage Automation

Problem

Triaging incoming issues is time-consuming and inconsistent.

Solution

Automatically triage and categorize GitHub issues:

yaml
tools:
  - name: "triage-issue"
    tool: "mcp/github-mcp"
    args:
      action: "updateIssue"
      repo: "{{repository}}"
      issueNumber: "{{issue_number}}"
      labels:
        add:
          - "{{detected_category}}"
          - "{{priority_level}}"
          - "{{complexity_estimate}}"
        remove:
          - "needs-triage"
      assignees:
        add:
          - "{{suggested_assignee}}"
      milestone: "{{suggested_milestone}}"
      state: "{{issue_state}}" # open or closed

Usage Example

yaml
integrations:
  github:
    issueBot:
      enabled: true
      workflows:
        - name: "issue-triage"
          trigger:
            eventType: "issues"
            actions: ["opened"]
          actions:
            - action: "analyzeIssue"
            - action: "classifyIssue"
            - action: "estimateComplexity"
            - action: "suggestAssignee"
            - action: "createToolCall"
              tool: "triage-issue"
              parameters:
                repository: "{{repo_name}}"
                issue_number: "{{issue_id}}"
                detected_category: "{{category}}"
                priority_level: "{{priority}}"
                complexity_estimate: "{{complexity}}"
                suggested_assignee: "{{assignee}}"
                suggested_milestone: "{{milestone}}"
                issue_state: "open"

Recipe 6: Cross-Repository Workflow

Problem

Coordinating work across multiple repositories is complex.

Solution

Create workflows that span multiple GitHub repositories:

yaml
continuousAI:
  enabled: true
  workflows:
    - name: "cross-repo-dependency-update"
      trigger:
        eventType: "dependencyUpdated"
      actions:
        # 1. Update dependent repositories
        - action: "forEach"
          items: "{{dependent_repos}}"
          actions:
            - action: "createToolCall"
              tool: "mcp/github-mcp"
              parameters:
                action: "createPullRequest"
                repo: "{{item}}"
                title: "chore: update {{library_name}} to v{{new_version}}"
                body: |
                  ## Dependency Update

                  Updates {{library_name}} from v{{old_version}} to v{{new_version}}.

                  ## Release Notes
                  {{release_notes}}

                  ## Testing
                  Please ensure all tests pass with this update.
                head: "deps/update-{{library_name}}-{{new_version}}"
                base: "main"

        # 2. Create tracking issue
        - action: "createToolCall"
          tool: "mcp/github-mcp"
          parameters:
            action: "createIssue"
            repo: "{{tracking_repo}}"
            title: "Dependency update: {{library_name}} v{{new_version}}"
            body: |
              Tracking issue for {{library_name}} v{{new_version}} update across repositories.

              ## Updated Repositories
              {{#each updated_repos}}
              - [{{repo_name}}]({{pr_url}})
              {{/each}}

              ## Status
              - [ ] All PRs created
              - [ ] All PRs merged
              - [ ] Release published
            labels:
              - "dependencies"
              - "tracking"

Security Best Practices

Secure Authentication

Protect your GitHub credentials:

yaml
# Use environment variables for sensitive data
tools:
  - name: "secure-github"
    tool: "mcp/github-mcp"
    args:
      baseUrl: "https://api.github.com"
      token: "${GITHUB_TOKEN}" # Store in secure vault
      appId: "${GITHUB_APP_ID}"
      privateKey: "${GITHUB_PRIVATE_KEY}"

Permission Management

Limit tool permissions:

yaml
# Configure granular permissions
tools:
  - name: "limited-github"
    tool: "mcp/github-mcp"
    args:
      permissions:
        issues:
          read: true
          write: true
        pullRequests:
          read: true
          write: true
        contents:
          read: true
          write: false # Read-only access to code
        discussions:
          read: true
          write: true

Troubleshooting

Common Issues

Authentication Failures

bash
# Check token validity
curl -H "Authorization: token $GITHUB_TOKEN" https://api.github.com/user

# Verify token scopes
curl -H "Authorization: token $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3+json" https://api.github.com/rate_limit

Permission Errors

yaml
# Check repository permissions
# Ensure token has necessary scopes:
# - repo (for private repos)
# - public_repo (for public repos)
# - write:discussion (for discussions)

Rate Limiting

yaml
tools:
  - name: "rate-limited-github"
    tool: "mcp/github-mcp"
    args:
      rateLimiting:
        enabled: true
        requestsPerHour: 1000
        retryAttempts: 3
        retryDelay: 2000 # ms

Debugging Commands

bash
# Test GitHub connection
bytebuddy mcp test github-mcp

# View available actions
bytebuddy mcp actions github-mcp

# Debug tool calls
bytebuddy debug tool-call --tool=github-integration

Best Practices

Workflow Design

  1. Start Simple: Begin with basic integrations
  2. Test Thoroughly: Verify each step works independently
  3. Handle Errors: Implement proper error handling
  4. Monitor Usage: Track tool usage and effectiveness

Security

  1. Least Privilege: Grant minimum necessary permissions
  2. Secure Storage: Store credentials in secure vaults
  3. Regular Rotation: Rotate tokens regularly
  4. Audit Logs: Monitor all tool activities

Performance

  1. Rate Limiting: Respect API rate limits
  2. Caching: Cache frequently accessed data
  3. Batching: Batch operations when possible
  4. Asynchronous: Use async operations for better UX

Next Steps

After implementing these recipes, explore these related guides: