Skip to content

GitHub MCP Integration

Integrate MyDeskBot with GitHub using the Model Context Protocol (MCP).

Overview

The GitHub MCP integration allows MyDeskBot to interact with GitHub repositories, enabling actions like:

  • Creating issues and pull requests
  • Reviewing code changes
  • Managing repository settings
  • Analyzing commit history
  • Generating commit messages

Setup

1. Install GitHub MCP Server

bash
npm install -g @modelcontextprotocol/server-github

2. Configure MyDeskBot

In your MyDeskBot settings:

Desktop:

json
{
  "mcp": {
    "github": {
      "enabled": true,
      "token": "ghp_...",
      "defaultRepo": "owner/repo"
    }
  }
}

VS Code:

json
{
  "mydeskbot.mcp.github": {
    "enabled": true,
    "token": "ghp_...",
    "defaultRepo": "owner/repo"
  }
}

Neovim:

lua
require('mydeskbot').setup({
  mcp = {
    github = {
      enabled = true,
      token = 'ghp_...',
      defaultRepo = 'owner/repo'
    }
  }
})

3. Create GitHub Personal Access Token

  1. Go to GitHub Settings → Developer settings → Personal access tokens
  2. Generate new token (classic)
  3. Select scopes:
    • repo - Full control of private repositories
    • issues - Manage issues
    • pull_requests - Manage pull requests
  4. Copy the token

Usage Examples

1. Create Issue

User: Create an issue for the login bug

MyDeskBot: Creating issue...

Title: Bug: Login fails for users with special characters in email

Description:
- Users with special characters (+, %) in email cannot login
- Error: "Invalid email format"
- Impact: ~5% of users affected

Labels: bug, high-priority
Assignee: @username

Issue created: https://github.com/owner/repo/issues/123

2. Review Pull Request

User: Review the latest PR in the main branch

MyDeskBot: Reviewing PR #45: Add user authentication

Changes:
+ Added AuthService with JWT authentication
+ Added AuthMiddleware for protected routes
+ Added login/register endpoints
+ Added tests

Issues found:
1. Password should be hashed with bcrypt
2. JWT secret should be in environment variables
3. Missing rate limiting on login endpoint

Suggested changes:
- Use bcrypt for password hashing
- Move JWT_SECRET to .env
- Add rate limiting middleware

Overall: Good structure, fix security issues before merge

3. Generate Commit Message

User: Generate a commit message for these changes

[Changes shown]

MyDeskBot: Here are commit message options:

Option 1 (Conventional):
feat: add user authentication with JWT

Implement JWT-based authentication system:
- Add AuthService for token generation
- Add AuthMiddleware for route protection
- Add login and register endpoints
- Add unit tests

Closes #42

Option 2 (Descriptive):
Add user authentication feature using JWT tokens

This commit adds a complete authentication system with:
- User registration and login
- JWT token generation and validation
- Protected routes with middleware
- Comprehensive test coverage

Breaking changes: None

Which would you prefer?

4. Analyze Repository

User: Analyze this repository for common issues

MyDeskBot: Analyzing repository...

Repository Analysis:
====================

Code Quality:
✓ Good: Consistent code style
✓ Good: Comprehensive tests
⚠ Warning: Missing documentation in utils/helpers.js
✗ Issue: Unused dependencies in package.json

Security:
✓ Good: No exposed secrets
✓ Good: Proper authentication
⚠ Warning: Outdated dependencies (3 packages)

Best Practices:
✓ Good: Follows semantic versioning
✓ Good: Has CONTRIBUTING.md
⚠ Warning: No CODE_OF_CONDUCT.md

Recommendations:
1. Update outdated dependencies
2. Add documentation for helper functions
3. Add Code of Conduct
4. Remove unused dependencies

5. Create Pull Request

User: Create a PR for the user-api branch

MyDeskBot: Creating pull request...

Title: feat: Add user CRUD API

Description:
Implements a complete CRUD API for user management:

- GET /api/users - List all users
- GET /api/users/:id - Get single user
- POST /api/users - Create new user
- PUT /api/users/:id - Update user
- DELETE /api/users/:id - Delete user

Features:
- Input validation
- Error handling
- Pagination support
- Comprehensive tests

Closes #45, #46

MCP Tools Available

Repository Tools

  • list_repositories - List accessible repositories
  • get_repository - Get repository details
  • update_repository - Update repository settings

Issue Tools

  • list_issues - List issues in repository
  • create_issue - Create new issue
  • get_issue - Get issue details
  • update_issue - Update issue
  • close_issue - Close issue

Pull Request Tools

  • list_pull_requests - List pull requests
  • create_pull_request - Create PR
  • get_pull_request - Get PR details
  • review_pull_request - Review PR
  • merge_pull_request - Merge PR

Commit Tools

  • list_commits - List commits
  • get_commit - Get commit details
  • create_commit - Create commit

Content Tools

  • get_file - Get file contents
  • create_file - Create file
  • update_file - Update file
  • delete_file - Delete file

Configuration Options

json
{
  "mcp": {
    "github": {
      "enabled": true,
      "token": "ghp_...",
      "defaultRepo": "owner/repo",
      "apiEndpoint": "https://api.github.com",
      "maxResults": 100,
      "cacheEnabled": true,
      "cacheDuration": 300
    }
  }
}

Workflows

Workflow 1: Feature Development

1. Create feature branch
   User: Create branch feature/user-auth

2. Implement feature
   [Coding with MyDeskBot assistance]

3. Commit changes
   User: Generate commit message

4. Push to remote
   User: Push to feature/user-auth

5. Create PR
   User: Create PR from feature/user-auth

6. Review with AI
   User: Review the PR

7. Merge
   User: Merge the PR

Workflow 2: Bug Fixing

1. Create issue
   User: Create issue for login bug

2. Create fix branch
   User: Create branch fix/login-bug

3. Implement fix
   [AI helps debug and fix]

4. Test
   User: Run tests

5. Create PR
   User: Create PR fix/login-bug

6. Reference issue
   MyDeskBot adds "Closes #123" to commit message

7. Merge
   User: Merge PR

Workflow 3: Code Review

1. Monitor PRs
   User: List open PRs

2. Review specific PR
   User: Review PR #45

3. Add comments
   MyDeskBot adds review comments

4. Request changes
   User: Request changes on PR

5. Re-review
   User: Re-review after fixes

Best Practices

1. Use Semantic Commit Messages

feat: add user authentication
fix: resolve login issue
docs: update README
style: format code
refactor: simplify AuthController
test: add unit tests for AuthService
chore: update dependencies

2. Write Good Descriptions

Bad:
Fix login bug

Good:
Fix login issue for users with special characters

The login endpoint was rejecting emails with + and % characters.
Fixed by updating the email validation regex.

Impact: Fixes login for ~5% of users
Tests: Added 3 new test cases

3. Use Labels

bug - Bug reports
enhancement - Feature requests
documentation - Documentation
good first issue - Good for newcomers
help wanted - Help requested
high-priority - High priority
In commit messages:
Closes #123
Fixes #456
Refs #789

In PRs:
Closes #123, #124

Troubleshooting

Authentication Failed

Problem: Token authentication failed

Solutions:

  1. Verify token is correct
  2. Check token has necessary scopes
  3. Regenerate token
  4. Check token hasn't expired

Rate Limiting

Problem: Rate limit exceeded

Solutions:

  1. Wait for rate limit reset
  2. Use authentication (increases limit)
  3. Cache responses
  4. Reduce request frequency

Repository Not Found

Problem: Repository not found

Solutions:

  1. Verify repository name is correct
  2. Check you have access to repository
  3. Use full owner/repo format
  4. Check defaultRepo setting

Advanced Features

1. Multi-Repository Support

json
{
  "mcp": {
    "github": {
      "repositories": {
        "main": "owner/main-repo",
        "frontend": "owner/frontend",
        "backend": "owner/backend"
      }
    }
  }
}

2. Webhook Integration

Set up webhooks for real-time updates:

json
{
  "mcp": {
    "github": {
      "webhooks": {
        "enabled": true,
        "events": ["push", "pull_request", "issues"]
      }
    }
  }
}

3. Custom Templates

Define custom templates for issues and PRs:

json
{
  "mcp": {
    "github": {
      "templates": {
        "bug": "Bug Report Template\n\n## Description\n...",
        "feature": "Feature Request Template\n\n## Description\n..."
      }
    }
  }
}

See Also