GitHub MCP Server - Quick Usage Guide
Lists 16 GitHub API tools with usage examples, setup steps, and error handling for MCP server integration.
What this file does
Lists 16 GitHub API tools with usage examples, setup steps, and error handling for MCP server integration.
When to use it
- Setting up a GitHub MCP server for the first time
- Needing quick reference for GitHub API tool names and parameters
- Debugging common GitHub API errors like 401 or 403
- Learning search qualifiers for repositories, issues, and code
Assumes this stack
GitHub MCP Server - Quick Usage Guide
๐ฏ Available Tools (16 Total)
Repositories (3 tools)
github_search_repositories- Search for repositoriesgithub_list_repositories- List user/org repositoriesgithub_get_repository- Get repository details
Issues (4 tools)
github_list_issues- List repository issuesgithub_get_issue- Get issue detailsgithub_create_issue- Create a new issuegithub_update_issue- Update an existing issue
Pull Requests (4 tools)
github_list_pull_requests- List repository PRsgithub_get_pull_request- Get PR detailsgithub_create_pull_request- Create a new PRgithub_merge_pull_request- Merge a PR
Search (2 tools)
github_search_code- Search code across all repositoriesgithub_search_issues- Search issues across all repositories
Users (1 tool)
github_get_user- Get user profile
Commits (2 tools)
github_list_commits- List repository commitsgithub_get_commit- Get commit details
๐ Usage Examples
Example 1: Search Popular React Repositories
Tool: github_search_repositories
Params: {
query: "stars:>10000 language:react",
per_page: 10,
response_format: "markdown"
}
Example 2: List Issues in a Repository
Tool: github_list_issues
Params: {
owner: "facebook",
repo: "react",
state: "open",
per_page: 20,
response_format: "markdown"
}
Example 3: Create a New Issue
Tool: github_create_issue
Params: {
owner: "owner",
repo: "repo",
title: "Fix authentication bug",
body: "Users cannot login after timeout...",
labels: ["bug", "high-priority"],
assignees: ["developer"]
}
Example 4: List Pull Requests
Tool: github_list_pull_requests
Params: {
owner: "microsoft",
repo: "vscode",
state: "open",
base: "main",
per_page: 10,
response_format: "markdown"
}
Example 5: Search Code
Tool: github_search_code
Params: {
query: "language:typescript useEffect",
per_page: 20,
response_format: "markdown"
}
Example 6: Get User Profile
Tool: github_get_user
Params: {
username: "torvalds",
response_format: "markdown"
}
Example 7: List Commits
Tool: github_list_commits
Params: {
owner: "facebook",
repo: "react",
sha: "main",
per_page: 20,
response_format: "markdown"
}
๐ง Setup Instructions
1. Install Dependencies
cd github-mcp-server
npm install
2. Build Project
npm run build
3. Configure GitHub Token
Create a .env file:
GITHUB_TOKEN=ghp_xxxxxxxxxxxxxxxxxxxx
Get your token from: https://github.com/settings/tokens
4. Start Server
# stdio mode (for MCP clients)
npm start
# HTTP mode (for web access)
TRANSPORT=http PORT=3000 npm start
5. Test with Inspector
npx @modelcontextprotocol/inspector node dist/index.js
๐จ Response Format Options
All tools support two output formats:
Markdown (default)
- Human-readable formatted text
- Headers, lists, and formatting
- Good for reading by humans
- Example:
response_format: "markdown"
JSON
- Machine-readable structured data
- Complete data objects
- Good for programmatic processing
- Example:
response_format: "json"
โ ๏ธ Common Errors and Solutions
401 - Invalid Token
Error: "Error: Invalid GitHub token"
Solution: Check GITHUB_TOKEN in .env file, ensure it's valid and not expired.
403 - Permission Denied
Error: "Error: Permission denied"
Solution: Your token lacks required permissions. Ensure token has repo scope.
404 - Not Found
Error: "Error: Resource not found" Solution: Check owner, repository name, or issue/PR number for typos.
422 - Validation Error
Error: "Error: Validation failed" Solution: Check input parameters - field lengths, enum values, etc.
429 - Rate Limit
Error: "Error: Rate limit exceeded" Solution: Wait for the reset time shown in the error message. Authenticated requests get 5000/hour.
๐ Rate Limits
| Authentication Type | Limit |
|---|---|
| Authenticated | 5,000 requests/hour |
| Unauthenticated | 60 requests/hour |
| Search API | 30 requests/minute |
๐ Best Practices
- Use Authentication: Always use a GitHub token for higher rate limits
- Filter Results: Use
per_pageparameter to limit response size - Use Qualifiers: In search queries, use qualifiers like
language:,stars:, etc. - Handle Pagination: Check
has_morefield to determine if more results available - Cache Responses: Cache read-only responses to reduce API calls
- Use JSON Format: For programmatic processing, use
response_format: "json"
๐ GitHub Search Qualifiers
Repository Search
stars:>1000- Repos with 1000+ starslanguage:typescript- TypeScript repositoriesuser:facebook- Repos by Facebookfork:true- Only forked reposis:public- Only public repos
Issue Search
is:open- Only open issuesis:pr- Only pull requestslabel:bug- Issues with bug labelauthor:username- Issues by specific authorcreated:>2024-01-01- Issues created after date
Code Search
language:python- Python code onlyfilename:package.json- Only package.json filesrepo:facebook/react- Search in specific repoorg:microsoft- Search in Microsoft org repos
Ready to use! Start the server and connect with your MCP client.
What's inside
16 tools across 6 categories, 7 usage examples, setup instructions, error solutions, rate limits, best practices, and search qualifiers
Change this for your project
- Replace
GITHUB_TOKEN=ghp_xxxxxxxxxxxxxxxxxxxxwith your actual GitHub token - Replace
owner: "facebook"andrepo: "react"with your own repository details - Replace
username: "torvalds"with the target GitHub username
Where it goes
Use as the system prompt for your model call, or as the base instructions in your agent framework.
Worth borrowing
- Organizing tools by GitHub resource type (repositories, issues, PRs) for easy lookup
- Providing both Markdown and JSON response format options for human vs programmatic use
- Including a search qualifier cheat sheet for power users
Related Documents
Character Persona
Defines a Fallout 2 roleplay persona for an LLM agent: charming rogue with social-first combat and moral code.
How to implement tool use
Explains how to define, configure, and control tool use with the Anthropic API, including model selection, tool definitions, output control, and parallel calls.
Gemini by Example
Collects 20+ Gemini API code examples covering text, images, audio, video, PDFs, agents, and token counting.
Claude Tool Use (Function Calling) Documentation
Teaches how to define and use Claude tool use (function calling) with Python, including schema rules, execution patterns, and best practices.