GitHub MCP Server
Model Context Protocol (MCP) server for GitHub integration. Built for PETA Desk integration with STDIO transport.
GitHub MCP Server
Model Context Protocol (MCP) server for GitHub integration. Built for PETA Desk integration with STDIO transport.
Features
-
39 tools across 10 categories covering all GitHub development workflows:
Repository Management (6 tools):
githubListRepositories- List repositories for a user or authenticated usergithubGetRepository- Get detailed repository informationgithubCreateRepository- Create a new repositorygithubForkRepository- Fork an existing repositorygithubSearchRepositories- Search repositories across GitHubgithubGetFileContents- Get file or directory contents from a repository
Issue Management (5 tools):
githubListIssues- List issues in a repository with filtersgithubGetIssue- Get detailed issue informationgithubCreateIssue- Create a new issuegithubUpdateIssue- Update an existing issuegithubAddIssueComment- Add a comment to an issue
Pull Request Management (5 tools):
githubListPullRequests- List pull requests in a repositorygithubGetPullRequest- Get detailed pull request informationgithubCreatePullRequest- Create a new pull requestgithubMergePullRequest- Merge a pull requestgithubGetPullRequestDiff- Get the diff of a pull request
User Operations (3 tools):
githubGetAuthenticatedUser- Get information about the authenticated usergithubGetUser- Get information about a specific usergithubSearchUsers- Search for users across GitHub
Organizations & Teams (5 tools) - Includes GitHub official "context" toolset:
githubListOrganizations- List organizations for a usergithubGetOrganization- Get organization detailsgithubListTeams- List teams (context toolset)githubGetTeam- Get team detailsgithubListTeamMembers- List team members (context toolset)
Commits (3 tools):
githubListCommits- List commits with filtering optionsgithubGetCommit- Get detailed commit informationgithubCompareCommits- Compare two commits
Branches (4 tools):
githubListBranches- List all branchesgithubGetBranch- Get branch detailsgithubCreateBranch- Create a new branchgithubDeleteBranch- Delete a branch
Pull Request Reviews (4 tools):
githubListPullRequestReviews- List all reviews for a PRgithubCreateReview- Create a review (approve/request changes/comment)githubListPullRequestFiles- List files changed in a PRgithubListPullRequestComments- List all review comments
File Operations (2 tools):
githubCreateOrUpdateFile- Create or update a file in a repositorygithubDeleteFile- Delete a file from a repository
Code Search (2 tools):
githubSearchCode- Search code across GitHub repositoriesgithubSearchIssues- Search issues and pull requests
-
STDIO Transport: Direct process communication via stdin/stdout
-
Dynamic Token Updates: Supports runtime token refresh without server restart
-
MCP Apps Views: Repository, issue, pull request, and PR detail views for compatible clients
-
GitHub API v3: Uses the latest stable GitHub REST API (2022-11-28)
-
Comprehensive Validation: Input validation, branch name rules, file path security
-
Enhanced Error Handling: Clear error messages with GitHub API error mapping
Quick Start
Option 1: Docker (Recommended)
# Pull from GitHub Container Registry (GHCR)
docker pull ghcr.io/dunialabs/mcp-servers/github:latest
# Run with your GitHub OAuth access token
export accessToken='ghp_xxxxxxxxxxxx'
docker run -i --rm -e accessToken ghcr.io/dunialabs/mcp-servers/github:latest
# Or build locally
npm run build
docker build -t ghcr.io/dunialabs/mcp-servers/github:latest .
Option 2: Direct Node.js
# Install and build
npm install
npm run build
# Run
export accessToken='ghp_xxxxxxxxxxxx'
node dist/stdio.js
For PETA Core Integration
PETA Core will automatically:
- Start this MCP server with STDIO transport (Docker or Node.js)
- Provide GitHub OAuth access token via
accessTokenenvironment variable - Manage token refresh and server lifecycle
No manual configuration needed!
Docker launchConfig:
{
"command": "docker",
"args": ["run", "--pull=always", "-i", "--rm", "-e", "accessToken", "ghcr.io/dunialabs/mcp-servers/github:latest"],
"env": {
"accessToken": "ghp_xxxxxxxxxxxx"
}
}
Node.js launchConfig:
{
"command": "node",
"args": ["/path/to/mcp-github/dist/stdio.js"],
"env": {
"accessToken": "ghp_xxxxxxxxxxxx"
}
}
Authentication
The server reads the GitHub OAuth access token from the accessToken environment variable.
Token Formats:
- Personal Access Token (classic):
ghp_prefix (40 characters) - Fine-grained PAT:
github_pat_prefix - OAuth access token:
gho_prefix - GitHub App token:
ghs_prefix
Note: Token refresh is handled by PETA Core. This server only needs the access token.
MCP Apps
Compatible MCP Apps clients can render richer views for:
githubListRepositoriesgithubListIssuesgithubSearchIssuesgithubListPullRequestsgithubGetPullRequest
These tools keep their original text fallback for non-Apps clients and add structuredContent plus App resources for compatible hosts.
Build Notes
npm run build now runs both:
- server TypeScript compilation
npm run build:appfor the GitHub MCP Apps HTML resources
If you change files under ui/, rebuild before testing:
npm run build
Required GitHub OAuth Scopes
Core Scopes (Recommended):
repo- Full control of private repositories- Includes:
repo:status,repo_deployment,public_repo,repo:invite,security_events
- Includes:
read:user- Read user profile datauser:email- Access user email addresses (optional)
Additional Scopes (Optional):
write:repo_hook- Write repository hooks (for webhook management)read:org- Read organization membership and teams (for organization operations)
Environment Variables
Required
accessToken- GitHub OAuth access token or Personal Access Token (provided by peta-core or set manually)
Optional - API Configuration
GITHUB_API_URL- GitHub API base URL (default:https://api.github.com)GITHUB_API_TIMEOUT- API request timeout in milliseconds (default:30000)
Optional - Proxy Configuration
HTTP_PROXY/http_proxy- HTTP proxy URLHTTPS_PROXY/https_proxy- HTTPS proxy URLNO_PROXY/no_proxy- Hosts to bypass proxy
Note: Proxy is disabled by default in Docker images to prevent connection issues.
Tool Examples
Repository Management
List Repositories
{
"name": "githubListRepositories",
"arguments": {
"username": "octocat",
"type": "owner",
"sort": "updated",
"per_page": 10
}
}
Get Repository
{
"name": "githubGetRepository",
"arguments": {
"repo": "octocat/Hello-World"
}
}
Create Repository
{
"name": "githubCreateRepository",
"arguments": {
"name": "my-new-repo",
"description": "A new repository created via MCP",
"private": false,
"auto_init": true
}
}
Fork Repository
{
"name": "githubForkRepository",
"arguments": {
"repo": "octocat/Hello-World"
}
}
Search Repositories
{
"name": "githubSearchRepositories",
"arguments": {
"query": "machine learning language:python stars:>1000",
"sort": "stars",
"order": "desc",
"per_page": 20
}
}
Get File Contents
{
"name": "githubGetFileContents",
"arguments": {
"repo": "octocat/Hello-World",
"path": "README.md",
"ref": "main"
}
}
Issue Management
List Issues
{
"name": "githubListIssues",
"arguments": {
"repo": "octocat/Hello-World",
"state": "open",
"labels": ["bug", "high-priority"],
"sort": "updated"
}
}
Get Issue
{
"name": "githubGetIssue",
"arguments": {
"repo": "octocat/Hello-World",
"issue_number": 42
}
}
Create Issue
{
"name": "githubCreateIssue",
"arguments": {
"repo": "octocat/Hello-World",
"title": "Bug: Application crashes on startup",
"body": "## Description\nThe application crashes when...",
"labels": ["bug"],
"assignees": ["octocat"]
}
}
Update Issue
{
"name": "githubUpdateIssue",
"arguments": {
"repo": "octocat/Hello-World",
"issue_number": 42,
"state": "closed",
"body": "Fixed in #43"
}
}
Add Issue Comment
{
"name": "githubAddIssueComment",
"arguments": {
"repo": "octocat/Hello-World",
"issue_number": 42,
"body": "Thanks for reporting! I'll look into this."
}
}
Pull Request Management
List Pull Requests
{
"name": "githubListPullRequests",
"arguments": {
"repo": "octocat/Hello-World",
"state": "open",
"sort": "updated",
"direction": "desc"
}
}
Get Pull Request
{
"name": "githubGetPullRequest",
"arguments": {
"repo": "octocat/Hello-World",
"pull_number": 123
}
}
Create Pull Request
{
"name": "githubCreatePullRequest",
"arguments": {
"repo": "octocat/Hello-World",
"title": "Add new feature",
"head": "feature-branch",
"base": "main",
"body": "## Changes\n- Added feature X\n- Fixed bug Y",
"draft": false
}
}
Merge Pull Request
{
"name": "githubMergePullRequest",
"arguments": {
"repo": "octocat/Hello-World",
"pull_number": 123,
"commit_title": "Merge pull request #123",
"merge_method": "squash"
}
}
Get Pull Request Diff
{
"name": "githubGetPullRequestDiff",
"arguments": {
"repo": "octocat/Hello-World",
"pull_number": 123
}
}
User Operations
Get Authenticated User
{
"name": "githubGetAuthenticatedUser",
"arguments": {}
}
Get User
{
"name": "githubGetUser",
"arguments": {
"username": "octocat"
}
}
Search Users
{
"name": "githubSearchUsers",
"arguments": {
"query": "location:San Francisco followers:>100",
"sort": "followers",
"order": "desc"
}
}
Usage Scenarios
Scenario 1: Repository Analysis
- Use
githubGetAuthenticatedUserto verify authentication - Use
githubListRepositoriesto list user's repositories - Use
githubGetRepositoryto get detailed information - Use
githubGetFileContentsto read specific files
Scenario 2: Issue Management Workflow
- Use
githubListIssuesto view open issues - Use
githubGetIssueto read issue details - Use
githubAddIssueCommentto participate in discussions - Use
githubUpdateIssueto update status or labels - Use
githubCreateIssueto report new issues
Scenario 3: Pull Request Review
- Use
githubListPullRequeststo find PRs needing review - Use
githubGetPullRequestto get PR details - Use
githubGetPullRequestDiffto review changes - Use
githubAddIssueCommentto provide feedback (PRs are issues) - Use
githubMergePullRequestto merge approved PRs
Scenario 4: Code Search and Discovery
- Use
githubSearchRepositoriesto find relevant projects - Use
githubGetRepositoryto check repository details - Use
githubForkRepositoryto create your own copy - Use
githubGetFileContentsto explore code structure
API Rate Limits
GitHub API has rate limits that vary by authentication method:
Authenticated Requests:
- OAuth tokens: 5,000 requests per hour
- Personal Access Tokens: 5,000 requests per hour
- GitHub Apps: 5,000 requests per hour (per installation)
Unauthenticated Requests:
- 60 requests per hour (not applicable for this server)
Best Practices:
- Use pagination to limit result sets (
per_page,pageparameters) - Cache results when appropriate
- Monitor rate limit headers in responses
- Implement exponential backoff on rate limit errors
The server automatically logs rate limit information when responses are received.
Development
# Install dependencies
npm install
# Build TypeScript
npm run build
# Development mode with auto-reload
npm run dev
# Run tests
npm test
# Lint code
npm run lint
Docker Build
# Local build (current platform)
./build-docker.sh
# Multi-platform build (amd64, arm64)
./build-docker.sh multi
# Build and push to GHCR
./build-docker.sh push
# Clean up builders
./build-docker.sh clean
Security Features
- ✅ Input validation with Zod schemas
- ✅ Token format validation
- ✅ Repository name format validation (
owner/repo) - ✅ Username validation
- ✅ Secure logging with sensitive data redaction
- ✅ Error handling with MCP standard error codes
- ✅ Rate limit monitoring and logging
- ✅ Request timeout protection (30s default)
Troubleshooting
Authentication Errors
Error: Authentication failed: Invalid or expired access token
Solutions:
- Verify
accessTokenenvironment variable is set correctly - Check token format matches one of the supported formats (ghp_, gho_, github_pat_, ghs_)
- Ensure token has required scopes (repo, read:user)
- Regenerate token if expired: https://github.com/settings/tokens
Rate Limit Errors
Error: GitHub API rate limit exceeded
Solutions:
- Wait for rate limit reset (check
X-RateLimit-Resetheader) - Use pagination to reduce request count
- Implement caching in your application
- Consider using GitHub Apps for higher rate limits
Repository Not Found
Error: Repository not found: owner/repo
Solutions:
- Verify repository name format is correct (
owner/repo) - Check if repository is private and token has
reposcope - Verify repository exists on GitHub
- Check if you have access to the repository
Network Errors
Error: Request timeout or connection errors
Solutions:
- Check internet connectivity
- Verify GitHub API is accessible (https://www.githubstatus.com/)
- Configure proxy settings if behind corporate firewall
- Increase timeout with
GITHUB_API_TIMEOUTenvironment variable
License
MIT
Related Documents
Datalevin MCP Server
`dtlv mcp` runs a Datalevin MCP server over `stdio`.
WAVS MCP Server
`wavs-mcp` is a [Model Context Protocol](https://modelcontextprotocol.io) server that exposes WAVS platform operations to AI clients over stdio. It lets Claude Desktop, Cursor, VS Code, and other MCP-compatible clients query a live WAVS node, scaffold and build WASM components, upload binaries, deploy services, and simulate triggers — all from natural language.
一次性多版本
注意 wails 应该和 ChYing 目录在一级,也就是 ls
Heti AI Ökoszisztéma Figyelő
title: "Heti AI Ökoszisztéma Figyelő"