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-github2. 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
- Go to GitHub Settings → Developer settings → Personal access tokens
- Generate new token (classic)
- Select scopes:
repo- Full control of private repositoriesissues- Manage issuespull_requests- Manage pull requests
- 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/1232. 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 merge3. 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 dependencies5. 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, #46MCP Tools Available
Repository Tools
list_repositories- List accessible repositoriesget_repository- Get repository detailsupdate_repository- Update repository settings
Issue Tools
list_issues- List issues in repositorycreate_issue- Create new issueget_issue- Get issue detailsupdate_issue- Update issueclose_issue- Close issue
Pull Request Tools
list_pull_requests- List pull requestscreate_pull_request- Create PRget_pull_request- Get PR detailsreview_pull_request- Review PRmerge_pull_request- Merge PR
Commit Tools
list_commits- List commitsget_commit- Get commit detailscreate_commit- Create commit
Content Tools
get_file- Get file contentscreate_file- Create fileupdate_file- Update filedelete_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 PRWorkflow 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 PRWorkflow 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 fixesBest 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 dependencies2. 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 cases3. Use Labels
bug - Bug reports
enhancement - Feature requests
documentation - Documentation
good first issue - Good for newcomers
help wanted - Help requested
high-priority - High priority4. Link Issues
In commit messages:
Closes #123
Fixes #456
Refs #789
In PRs:
Closes #123, #124Troubleshooting
Authentication Failed
Problem: Token authentication failed
Solutions:
- Verify token is correct
- Check token has necessary scopes
- Regenerate token
- Check token hasn't expired
Rate Limiting
Problem: Rate limit exceeded
Solutions:
- Wait for rate limit reset
- Use authentication (increases limit)
- Cache responses
- Reduce request frequency
Repository Not Found
Problem: Repository not found
Solutions:
- Verify repository name is correct
- Check you have access to repository
- Use full owner/repo format
- 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..."
}
}
}
}