Use GitHub for Code Access
This guide shows how to use the GitHub MCP server to interact with GitHub repositories, issues, pull requests, and more.
Prerequisites
- MCP enabled in your mini-me configuration
- GitHub MCP server configured
- GitHub Personal Access Token with appropriate scopes
Configuration Example
Add this to your agent.yaml or custom config file:
mcp:
enabled: true
servers:
- name: github
transport: http
url: https://api.githubcopilot.com/mcp/
timeout: 60s
auth:
type: bearer
tokenEnv: GITHUB_PERSONAL_ACCESS_TOKEN
headers:
Accept: "application/json, text/event-stream"
# Optional: Filter which tools to expose
tools:
- get_me
- list_repositories
- list_issues
- list_pull_requests
- get_file_contents
- search_code
- search_repositories
- create_pull_request
- add_issue_comment
Authentication Setup
-
Get a GitHub PAT:
- Go to https://github.com/settings/tokens
- Click "Generate new token"
- Select "Classic" token type
-
Required Scopes:
- For repository access:
repo(full control of private repositories) - For reading user profile:
user(read:user) - For reading organizations:
read:org - For issues and pull requests:
repoorpublic_repo - For code search:
repo
- For repository access:
-
Set the environment variable:
export GITHUB_PERSONAL_ACCESS_TOKEN=ghp_your_token_here
Available Tools
The GitHub MCP server provides many tools organized by category:
Repository Information
github_get_me- Get authenticated user profilegithub_list_repositories- List user repositoriesgithub_get_repository- Get repository details
Code Access
github_get_file_contents- Get file content from a repositorygithub_list_branches- List repository branchesgithub_list_commits- List repository commitsgithub_get_commit- Get commit details
Issues and Pull Requests
github_list_issues- List repository issuesgithub_get_issue_details- Get issue details (usingissue_readmethod)github_list_pull_requests- List repository pull requestsgithub_get_pull_request- Get pull request details (usingpull_request_readmethod)github_create_pull_request- Create a new pull requestgithub_add_issue_comment- Add a comment to an issuegithub_update_issue_comment- Update an existing comment
Search
github_search_code- Search code across repositoriesgithub_search_issues- Search issues using semantic matchinggithub_search_pull_requests- Search pull requestsgithub_search_repositories- Search for repositoriesgithub_search_commits- Search for commitsgithub_search_users- Search for users
Repository Management
github_create_repository- Create a new repositorygithub_create_branch- Create a new branchgithub_fork_repository- Fork a repositorygithub_merge_pull_request- Merge a pull requestgithub_delete_file- Delete a file from a repository
Advanced
github_run_secret_scanning- Scan content for secretsgithub_assign_copilot_to_issue- Assign GitHub Copilot to an issuegithub_get_copilot_job_status- Get Copilot job statusgithub_create_pull_request_with_copilot- Create PR with Copilot agentgithub_request_copilot_review- Request Copilot code review
Usage Examples
Get Your Profile
Use the github_get_me tool to get my GitHub user information
List Your Repositories
Use the github_list_repositories tool to list all my repositories
Search for Code
Use the github_search_code tool to find references to "context" in the golang/go repository
Get File Contents
Use the github_get_file_contents tool to get the README.md file from owner/repo on the main branch
Create a Pull Request
Use the github_create_pull_request tool to create a PR in owner/repo with title "Fix bug", head "feature-branch", base "main"
Add Comment to Issue
Use the github_add_issue_comment tool to add a comment "Thanks for reporting!" to issue #123 in owner/repo
Tool Parameters
Most GitHub tools require these common parameters:
owner- Repository owner (username or organization)repo- Repository name- Often both are marked with
x-mcp-headerto indicate they should be passed as headers
For example:
{
"owner": "octocat",
"repo": "Hello-World"
}
Tips
- Be specific with owner/repo: Always verify the owner and repository name before proceeding
- Use filters: When searching, use GitHub's search qualifiers like
language:go,org:,user: - Handle large responses: Some tools return large amounts of data; consider filtering or limiting results
- Check scopes: If a tool fails with authentication error, your PAT may lack the required scope
Common Issues
Missing Required Parameters
Many GitHub tools require specific parameters. Check the tool description for required fields.
Authentication Errors
If you see "missing bearer token" or "401 Unauthorized":
- Verify
GITHUB_PERSONAL_ACCESS_TOKENenvironment variable is set - Check your token has the required scopes
- Ensure the token hasn't expired
Rate Limiting
GitHub has rate limits. If you hit them:
- Wait before making more requests
- Consider using a fine-grained PAT with specific repository access
- Check your rate limit status at https://api.github.com/rate_limit
Troubleshooting
If GitHub tools are not appearing:
- Verify MCP is enabled in your configuration
- Check that
GITHUB_PERSONAL_ACCESS_TOKENis exported in your environment - Look for warnings about GitHub server at startup
- Test your token:
curl -H "Authorization: Bearer $GITHUB_PERSONAL_ACCESS_TOKEN" https://api.github.com/user - Test the MCP endpoint:
curl -X POST https://api.githubcopilot.com/mcp/ -H "Authorization: Bearer $GITHUB_PERSONAL_ACCESS_TOKEN" -H "Accept: application/json, text/event-stream" -d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}'
See Also
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
|