A GitHub CLI extension that seamlessly runs the github-mcp-server in a Docker container using your existing gh
authentication.
gh-mcp
eliminates the manual setup of GitHub Personal Access Tokens for MCP (Model Context Protocol) servers. It automatically retrieves your GitHub credentials from the gh
CLI and launches the MCP server in a Docker container with proper authentication.
- GitHub CLI (
gh
) installed and authenticated (gh auth login
) - Docker installed and running
gh extension install shuymn/gh-mcp
To update the extension to the latest version:
gh extension upgrade mcp
Add this to your MCP client configuration:
{
"github": {
"command": "gh",
"args": ["mcp"]
}
}
With environment variables:
{
"github": {
"command": "gh",
"args": ["mcp"],
"env": {
"GITHUB_TOOLSETS": "repos,issues,pull_requests",
"GITHUB_READ_ONLY": "1"
}
}
}
To add this as an MCP server to Claude Code:
claude mcp add-json github '{"command":"gh","args":["mcp"]}'
With environment variables:
claude mcp add-json github '{"command":"gh","args":["mcp"],"env":{"GITHUB_TOOLSETS":"repos,issues","GITHUB_READ_ONLY":"1"}}'
You can also run the server directly:
gh mcp
This will:
- ๐ Retrieve your GitHub credentials from
gh
CLI - ๐ณ Connect to Docker
- ๐ฆ Pull the MCP server image (if not already present)
- ๐ Start the MCP server with your credentials
- Stream I/O between your terminal and the container
Press Ctrl+C
to gracefully shut down the server.
The extension passes through several environment variables to configure the MCP server:
Control which GitHub API toolsets are available:
# Enable specific toolsets
GITHUB_TOOLSETS="repos,issues,pull_requests" gh mcp
# Enable all toolsets
GITHUB_TOOLSETS="all" gh mcp
Enable dynamic toolset discovery (beta feature):
GITHUB_DYNAMIC_TOOLSETS=1 gh mcp
Run the server in read-only mode to prevent modifications:
GITHUB_READ_ONLY=1 gh mcp
You can combine multiple options:
GITHUB_READ_ONLY=1 GITHUB_TOOLSETS="repos,issues" gh mcp
- The extension retrieves your GitHub credentials from your existing
gh
CLI authentication - It pulls and runs the official
github-mcp-server
Docker image - Your credentials are securely passed to the container
- The container is automatically cleaned up when you exit
Run gh auth login
to authenticate with GitHub first.
Make sure Docker Desktop (or Docker service) is running on your system.
- Check your internet connection
- Verify you have access to
ghcr.io
(GitHub Container Registry) - The first pull may take a few minutes depending on your connection
Check the container logs or ensure the MCP server image is working correctly.
- Your GitHub token is never stored by this extension
- Credentials are passed to the container via environment variables
- The container runs with
--rm
to ensure cleanup - No data persists after the session ends
Contributions are welcome! Please feel free to submit a Pull Request.
For development information, see CONTRIBUTING.md.
This project is licensed under the MIT License - see the LICENSE file for details.
- github-mcp-server - The MCP server this extension runs
- GitHub CLI - The official GitHub command line tool
- go-gh - The Go library for GitHub CLI extensions