|
| 1 | +# Install GitHub MCP Server in Claude Applications |
| 2 | + |
| 3 | +This guide covers installation for both Claude Code CLI and Claude Desktop applications. |
| 4 | + |
| 5 | +## Claude Code CLI |
| 6 | + |
| 7 | +Claude Code CLI provides command-line access to Claude with MCP server integration. |
| 8 | + |
| 9 | +### Prerequisites |
| 10 | + |
| 11 | +1. Claude Code CLI installed |
| 12 | +2. [GitHub Personal Access Token](https://github.com/settings/personal-access-tokens/new) |
| 13 | + |
| 14 | +### Installation |
| 15 | + |
| 16 | +Run the following command in the Claude Code CLI, referencing your GitHub PAT: |
| 17 | + |
| 18 | +```bash |
| 19 | +claude mcp add-json github '{"command": "github-mcp-server", "args": ["stdio"], "env": {"GITHUB_PERSONAL_ACCESS_TOKEN": "your_github_pat"}}' |
| 20 | +``` |
| 21 | + |
| 22 | +### Configuration Steps |
| 23 | + |
| 24 | +1. Replace `your_github_pat` with your actual GitHub Personal Access Token |
| 25 | +2. Ensure you have the necessary permissions on your GitHub PAT for the operations you want to perform |
| 26 | +3. The command will add the GitHub MCP Server to your Claude Code configuration |
| 27 | + |
| 28 | +### Troubleshooting Claude Code |
| 29 | + |
| 30 | +- Verify the Claude Code CLI is properly installed and accessible |
| 31 | +- Check that your GitHub PAT is valid and has the required permissions |
| 32 | +- Ensure the command syntax is correct (note the single quotes around the JSON) |
| 33 | +- Review Claude Code documentation for any specific MCP server requirements |
| 34 | + |
| 35 | +--- |
| 36 | + |
| 37 | +## Claude Desktop |
| 38 | + |
| 39 | +Claude Desktop provides a user-friendly interface for interacting with the GitHub MCP Server. |
| 40 | + |
| 41 | +### Prerequisites |
| 42 | + |
| 43 | +1. Claude Desktop installed |
| 44 | +2. [GitHub Personal Access Token](https://github.com/settings/personal-access-tokens/new) |
| 45 | +3. [Docker](https://www.docker.com/) installed and running |
| 46 | + |
| 47 | +### Installation Steps |
| 48 | + |
| 49 | +1. Follow the Claude Desktop [MCP install guide](https://modelcontextprotocol.io/quickstart/user) |
| 50 | +2. Add the following configuration to your Claude Desktop configuration file |
| 51 | + |
| 52 | +### Configuration |
| 53 | + |
| 54 | +Add the following JSON to your Claude Desktop configuration file, replacing `your_github_pat` with your actual GitHub Personal Access Token: |
| 55 | + |
| 56 | +```json |
| 57 | +{ |
| 58 | + "mcpServers": { |
| 59 | + "github": { |
| 60 | + "command": "docker", |
| 61 | + "args": [ |
| 62 | + "run", |
| 63 | + "-i", |
| 64 | + "--rm", |
| 65 | + "-e", |
| 66 | + "GITHUB_PERSONAL_ACCESS_TOKEN", |
| 67 | + "ghcr.io/github/github-mcp-server" |
| 68 | + ], |
| 69 | + "env": { |
| 70 | + "GITHUB_PERSONAL_ACCESS_TOKEN": "your_github_pat" |
| 71 | + } |
| 72 | + } |
| 73 | + } |
| 74 | +} |
| 75 | +``` |
| 76 | + |
| 77 | +### Using Environment Variables |
| 78 | + |
| 79 | +You can also use environment variables for better security. Replace `your_github_pat` with a variable reference like `$GITHUB_PAT`: |
| 80 | + |
| 81 | +```json |
| 82 | +{ |
| 83 | + "mcpServers": { |
| 84 | + "github": { |
| 85 | + "command": "docker", |
| 86 | + "args": [ |
| 87 | + "run", |
| 88 | + "-i", |
| 89 | + "--rm", |
| 90 | + "-e", |
| 91 | + "GITHUB_PERSONAL_ACCESS_TOKEN", |
| 92 | + "ghcr.io/github/github-mcp-server" |
| 93 | + ], |
| 94 | + "env": { |
| 95 | + "GITHUB_PERSONAL_ACCESS_TOKEN": "$GITHUB_PAT" |
| 96 | + } |
| 97 | + } |
| 98 | + } |
| 99 | +} |
| 100 | +``` |
| 101 | + |
| 102 | +### Configuration File Location |
| 103 | + |
| 104 | +The Claude Desktop configuration file is typically located at: |
| 105 | +- **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json` |
| 106 | +- **Windows**: `%APPDATA%/Claude/claude_desktop_config.json` |
| 107 | +- **Linux**: `~/.config/claude/claude_desktop_config.json` |
| 108 | + |
| 109 | +### Troubleshooting Claude Desktop |
| 110 | + |
| 111 | +- Verify Docker is running and accessible |
| 112 | +- Check that your GitHub PAT is valid and has the required permissions |
| 113 | +- Ensure the configuration file is valid JSON |
| 114 | +- Restart Claude Desktop after making configuration changes |
| 115 | +- Check Claude Desktop logs for any error messages |
| 116 | + |
| 117 | +### Prerequisites |
| 118 | + |
| 119 | +1. Claude Code CLI installed |
| 120 | +2. [GitHub Personal Access Token](https://github.com/settings/personal-access-tokens/new) |
| 121 | + |
| 122 | +### Installation |
| 123 | + |
| 124 | +Run the following command in the Claude Code CLI, referencing your GitHub PAT: |
| 125 | + |
| 126 | +```bash |
| 127 | +claude mcp add-json github '{"command": "github-mcp-server", "args": ["stdio"], "env": {"GITHUB_PERSONAL_ACCESS_TOKEN": "your_github_pat"}}' |
| 128 | +``` |
| 129 | + |
| 130 | +### Configuration Steps |
| 131 | + |
| 132 | +1. Replace `your_github_pat` with your actual GitHub Personal Access Token |
| 133 | +2. Ensure you have the necessary permissions on your GitHub PAT for the operations you want to perform |
| 134 | +3. The command will add the GitHub MCP Server to your Claude Code configuration |
| 135 | + |
| 136 | +### Troubleshooting Claude Code |
| 137 | + |
| 138 | +- Verify the Claude Code CLI is properly installed and accessible |
| 139 | +- Check that your GitHub PAT is valid and has the required permissions |
| 140 | +- Ensure the command syntax is correct (note the single quotes around the JSON) |
| 141 | +- Review Claude Code documentation for any specific MCP server requirements |
| 142 | + |
| 143 | +--- |
| 144 | + |
| 145 | +## Security Best Practices |
| 146 | + |
| 147 | +Regardless of which Claude application you're using, follow these security guidelines: |
| 148 | + |
| 149 | +- **Keep your GitHub PAT secure** and never commit it to version control |
| 150 | +- **Limit the scope** of your GitHub PAT to only the permissions you need |
| 151 | +- **Consider using environment variables** for token storage when supported by your setup |
| 152 | +- **Regularly rotate** your GitHub Personal Access Tokens |
| 153 | +- **Ensure Docker environment is secure** (for Claude Desktop installations) |
| 154 | + |
| 155 | +## Installation Methods |
| 156 | + |
| 157 | +The GitHub MCP Server supports multiple installation approaches: |
| 158 | + |
| 159 | +### Docker (Recommended for Claude Desktop) |
| 160 | +- **Pros**: No local build required, consistent environment, easy updates |
| 161 | +- **Cons**: Requires Docker installed and running |
| 162 | +- **Used by**: Claude Desktop configuration above |
| 163 | + |
| 164 | +### Direct Binary (Used by Claude Code) |
| 165 | +- **Pros**: No Docker required, direct execution via stdio |
| 166 | +- **Cons**: Requires the `github-mcp-server` binary to be available in PATH |
| 167 | +- **Used by**: Claude Code CLI configuration above |
| 168 | + |
| 169 | +### Build from Source (Alternative) |
| 170 | +- **Pros**: Latest features, customizable, no Docker dependency |
| 171 | +- **Cons**: Requires Go development environment |
| 172 | +- **Prerequisites**: [Go 1.24+](https://go.dev/doc/install) |
| 173 | +- **Build command**: `go build -o github-mcp-server cmd/github-mcp-server/main.go` |
| 174 | + |
| 175 | +Choose the method that best fits your environment and requirements. |
0 commit comments