gh_mcp_server
MCP wrapper for the `gh` command
Documentation
GitHub MCP Server
A Spring Boot-based Model Context Protocol (MCP) server that provides GitHub integration tools for AI assistants like Claude Desktop.
Overview
This server implements the Model Context Protocol to expose GitHub operations as tools that can be used by MCP clients. It leverages the GitHub CLI (`gh`) to perform various GitHub operations including repository management, issue tracking, pull request management, and more. This provides a lightweight alternative to the official GitHub MCP server that doesn't require Docker.
Quick Start for Claude Desktop
To use this server with Claude Desktop, add the following to your Claude configuration file:
macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
Windows: `%APPDATA%\Claude\claude_desktop_config.json`
{
"mcpServers": {
"github": {
"command": "java",
"args": ["-jar", "/path/to/gh_mcp_server/build/libs/gh_mcp_server.jar"],
"env": {}
}
}
}Replace `/path/to/gh_mcp_server` with the actual path to your project directory.
Features
Repository Operations
- List repositories for authenticated user
- Search repositories on GitHub
- Get detailed repository information
- List branches in a repository
- Create new branches
- Get file contents from repositories
- Get commit history
Issue Management
- List issues (open, closed, or all)
- Get detailed issue information
- Create new issues
- Close issues
- Add comments to issues
- Edit issue title and body
Pull Request Management
- List pull requests
- Get detailed pull request information
- Create new pull requests
- Merge pull requests (merge, squash, or rebase)
- Close pull requests
- Add comments to pull requests
Workflow and Actions
- List workflows in a repository
- List workflow runs with optional filtering
- View detailed workflow run information
Release Management
- List releases
- View release details
- Create new releases (with draft/prerelease options)
User Operations
- Get authenticated user details
Prerequisites
- Java 21 or higher - Uses modern Java features (virtual threads, records, pattern matching)
- GitHub CLI (`gh`) - Must be installed and authenticated
- Gradle - Wrapper included in project
Why Use This MCP Server?
- π Lightweight: No Docker required, pure Java implementation
- π§ Comprehensive: 26 GitHub operations covering complete workflows
- β‘ Fast: Direct GitHub CLI integration with optimized JSON responses
- π§ͺ Well-Tested: 75+ test cases ensuring reliability
- π‘οΈ Secure: Leverages existing GitHub CLI authentication
Setup
1. Install GitHub CLI
# macOS
brew install gh
# or download from https://cli.github.com/2. Authenticate with GitHub
gh auth login3. Clone and build the project
git clone
cd gh_mcp_server
./gradlew build> Note: The build automatically creates a version-independent symlink `gh_mcp_server.jar` β `gh_mcp_server-1.0.0.jar`
4. Configure Claude Desktop
After building, configure Claude to use this MCP server. You have two options:
Option A: Using the JAR file (Recommended)
{
"mcpServers": {
"github": {
"command": "java",
"args": ["-jar", "/path/to/gh_mcp_server/build/libs/gh_mcp_server.jar"],
"env": {}
}
}
}> Note: A symlink `gh_mcp_server.jar` points to the current version (`gh_mcp_server-1.0.0.jar`). This provides version-independent deployment. For version-specific deployment, use the full versioned filename instead.
Option B: Using Gradle
{
"mcpServers": {
"github": {
"command": "./gradlew",
"args": ["bootRun"],
"cwd": "/path/to/gh_mcp_server",
"env": {}
}
}
}5. Restart Claude Desktop to load the new server configuration
Usage Examples
After configuring Claude Desktop, you can use natural language to interact with GitHub:
Repository Management
- *"List my repositories"* β Shows your repositories with details
- *"List my private repositories"* β Filter by visibility (public/private/internal)
- *"Search for Spring Boot repositories with over 1000 stars"*
- *"Show me details about the microsoft/vscode repository"*
- *"Get the last 5 commits from my project repository"*
- *"What branches exist in my project repository?"*
Issue Tracking
- *"List open issues in my project"* β Lists current open issues
- *"Show me issue #123 details"* β Gets specific issue information
- *"Create a new issue titled 'Bug: Login fails' with description..."*
- *"Close issue #123 and add a comment 'Fixed in latest release'"*
Pull Request Management
- *"List all pull requests in the kubernetes/kubernetes repository"*
- *"Show me details for PR #456"*
- *"Create a pull request from my feature-branch to main"*
- *"Merge PR #789 using squash strategy"*
CI/CD and Releases
- *"Show me all workflows in this repository"* β Lists GitHub Actions
- *"What's the status of recent workflow runs?"*
- *"List releases for the golang/go repository"*
- *"Create a new release v2.1.0 as a draft"*
File Operations
- *"Get the contents of package.json from my project"*
- *"Show me the README file from the main branch"*
Verification
If the server fails to start, check that:
- Java 21+ is installed and in your PATH
- GitHub CLI is installed and authenticated (`gh auth status`)
- The JAR file path in the configuration is correct
- Claude Desktop has been restarted
Testing the Server
To test the server independently (without Claude):
./gradlew bootRunThe server will start in STDIO mode and wait for MCP protocol messages. However, for normal usage, the server should be configured to run automatically by Claude Desktop as shown above.
Development Commands
# Build the project and run all tests
./gradlew build
# Run tests (command syntax validation only)
./gradlew test
# Run tests including GitHub CLI integration tests
./gradlew test -Dtest.gh.integration=true
# Format code with Spotless (Google Java Format)
./gradlew spotlessApply
# Check code formatting without applying changes
./gradlew spotlessCheck
# Clean build artifacts
./gradlew clean
# Run the server locally for testing
./gradlew bootRunTest Coverage
The project includes comprehensive test coverage:
- 75+ test cases validating all 26 GitHub operations
- Command syntax tests - Verify exact `gh` command construction
- Edge case tests - Handle special characters, Unicode, null values
- Integration tests - Optional real GitHub CLI execution
- Error handling tests - Validate graceful failure modes
See `src/test/java/com/kousenit/gh_mcp_server/TEST_README.md` for detailed testing documentation.
Configuration
The server uses Spring Boot's default configuration. You can customize settings in `src/main/resources/application.properties`.
Key Configuration Options
- `github.defaultBranch` - Default branch name for operations (default: `main`)
- `spring.threads.virtual.enabled` - Enable virtual threads for better performance (default: `true`)
- MCP server runs in STDIO mode for CLI integration
Available Operations (26 Total)
Repository Operations
- `listRepositories` - List user's repositories with optional visibility filter (public/private/internal)
- `searchRepositories` - Search GitHub repositories
- `getRepository` - Get detailed repository information
- `getCommitHistory` - Get repository commit history with configurable limit
- `listBranches` - List repository branches
- `createBranch` - Create a new branch
Issue Management
- `listIssues` - List issues in repository
- `getIssue` - Get specific issue details
- `createIssue` - Create new issue
- `closeIssue` - Close an issue
- `commentOnIssue` - Add comment to issue
- `editIssue` - Edit issue title/body
Pull Request Management
- `listPullRequests` - List pull requests
- `getPullRequest` - Get PR details
- `createPullRequest` - Create new pull request
- `mergePullRequest` - Merge PR (merge/squash/rebase)
- `closePullRequest` - Close pull request
- `commentOnPullRequest` - Add PR comment
Workflow & CI/CD
- `listWorkflows` - List repository workflows
- `listWorkflowRuns` - List workflow runs with filtering
- `getWorkflowRun` - Get workflow run details
Release Management
- `listReleases` - List repository releases
- `getRelease` - Get release details
- `createRelease` - Create new release (draft/prerelease options)
File & User Operations
- `getFileContents` - Get file contents from repository
- `getMe` - Get authenticated user details
All operations return optimized JSON responses and support comprehensive error handling.
Troubleshooting
Common Issues
"gh: command not found"
- Install GitHub CLI from https://cli.github.com/
- Ensure `gh` is in your system PATH
- Test with `gh --version`
Authentication errors
- Run `gh auth login` to authenticate
- Check status with `gh auth status`
- Ensure you have access to the repositories you're trying to access
Server startup failures
- Verify Java 21+ is installed: `java --version`
- Check the JAR file path in Claude configuration
- Look for error messages in Claude Desktop logs
- Ensure the server isn't already running on another instance
Command timeouts
- Large repositories or slow networks may cause timeouts
- Default timeout is 30 seconds per operation
- Check your internet connection and GitHub API status
Permission denied errors
- Ensure GitHub CLI has proper permissions for the repository
- For organization repositories, check if you have appropriate access
- Some operations require write permissions (create, edit, merge, close)
Performance Tips
- Use specific repository and owner names for faster responses
- Limit search results with appropriate limit parameters
- The server uses virtual threads for optimal concurrent performance
- GitHub CLI handles rate limiting automatically
Getting Help
- Check GitHub CLI documentation: `gh help`
- Review MCP protocol: https://modelcontextprotocol.io/
- For server issues, enable debug logging in application.properties
Deployment Considerations
JAR Versioning
The build process generates JAR files with version numbers in the filename (e.g., `gh_mcp_server-1.0.0.jar`). When deploying or updating:
1. Initial Deployment: Use the current version in your Claude Desktop configuration:
"args": ["-jar", "/path/to/gh_mcp_server/build/libs/gh_mcp_server-1.0.0.jar"]2. Version Updates: When updating to a new version, you must:
3. Version-Independent Deployment: For easier deployment, you can:
Automatic Symlink Management: The build process automatically creates and maintains the symlink:
Configuration Management
- Keep your Claude Desktop configuration in version control
- Document the specific JAR version being used in production
- Consider using environment variables for paths in deployment scripts
Technology Stack
- Spring Boot 3.5.0 - Application framework
- Spring AI 1.0.0 - AI integration and MCP server capabilities
- Java 21 - Programming language with virtual threads support
- GitHub CLI - GitHub API integration
- Gradle - Build tool
- Spotless - Code formatting with Google Java Format
Key Implementation Features
- Virtual Threads (Java 21) - Efficient concurrent I/O operations
- ProcessBuilder - Secure command execution with timeout support
- Records (Java 17) - Immutable data structures for command results
- Pattern Matching - Modern Java syntax for type checking
- String Templates - Using `String.formatted()` for cleaner string construction
License
This project is licensed under the MIT License - see the LICENSE file for details.
Frequently asked questions
What is gh_mcp_server?
gh_mcp_server is MCP wrapper for the `gh` command
How do I install gh_mcp_server?
Open the GitHub repository and follow its README. Most MCP servers are added to your client's MCP config, then called by your agent.
Is gh_mcp_server open source?
Yes β it is hosted on GitHub at https://github.com/kousen/gh_mcp_server and has 4 stars.
Related MCP tools
MCP Server for Ghidra Java-based implementation. Trusted by 6400+ developers. Trusted by 6400+ developers. Trusted by 6400+ developers.
The official Java SDK for Model Context Protocol servers and clients. Maintained in collaboration with Spring AI Trusted by 2800+ developers.
A library for communication with a Minecraft client/server. Built for the Model Context Protocol to enhance AI capabilities. Java-based implementation.
Plugin for JADX to integrate MCP server Java-based implementation. Trusted by 600+ developers. Trusted by 600+ developers.
π€ The Semantic Engine for Model Context Protocol(MCP) Clients and AIΒ Agents π₯ Java-based implementation.
Playwright MCP server TypeScript-based implementation. Trusted by 22000+ developers. Trusted by 22000+ developers. Trusted by 22000+ developers.
Run your own MCP server? See who uses it and what to fix.
Measure it with TrackMCP