This guide provides step-by-step instructions for setting up the GitHub MCP (Model Context Protocol) server with Claude Desktop, enabling seamless integration between Claude and your GitHub repositories.
The Model Context Protocol (MCP) is an open protocol that enables AI assistants to securely connect to local and remote resources. The GitHub MCP server allows Claude Desktop to interact with GitHub repositories, enabling features like reading files, creating repositories, managing issues, and more.
Before starting, ensure you have:
- Claude Desktop installed on your computer
- Node.js (version 16 or higher) installed
- A GitHub account
- Git installed on your system
-
Open your terminal or command prompt
-
Install the GitHub MCP server globally using npm:
npm install -g @modelcontextprotocol/server-github
-
Verify the installation:
mcp-server-github --version
- Go to GitHub and sign in to your account
- Click on your profile picture in the top right corner
- Select "Settings" from the dropdown menu
- In the left sidebar, click on "Developer settings"
- Click on "Personal access tokens" → "Tokens (classic)"
- Click "Generate new token" → "Generate new token (classic)"
- Give your token a descriptive name (e.g., "Claude Desktop MCP")
- Select the following scopes:
repo(Full control of private repositories)user:email(Access to user email addresses)read:user(Read access to user profile info)workflow(Update GitHub Action workflows)
- Click "Generate token"
- Important: Copy the token immediately and save it securely. You won't be able to see it again.
- Open Finder and navigate to
~/Library/Application Support/Claude/ - Create or edit the
claude_desktop_config.jsonfile - Add the following configuration:
{
"mcpServers": {
"github": {
"command": "mcp-server-github",
"args": [],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "your_github_token_here"
}
}
}
}- Navigate to
%APPDATA%\Claude\ - Create or edit the
claude_desktop_config.jsonfile - Add the same configuration as above
- Navigate to
~/.config/Claude/ - Create or edit the
claude_desktop_config.jsonfile - Add the same configuration as above
In the configuration file, replace your_github_token_here with the actual token you generated in Step 2.
Example:
{
"mcpServers": {
"github": {
"command": "mcp-server-github",
"args": [],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
}
}
}- Completely quit Claude Desktop
- Restart the application
- The GitHub MCP server should now be connected
Try asking Claude to perform GitHub-related tasks:
- "List my repositories"
- "Create a new repository called 'test-repo'"
- "Show me the contents of my README file in [repository-name]"
- "Create an issue in [repository-name]"
Once configured, Claude can help you with:
- Repository Management: Create, list, and manage repositories
- File Operations: Read, create, and update files in repositories
- Issue Management: Create, list, and update issues
- Pull Request Management: Create, review, and merge pull requests
- Branch Management: Create and manage branches
- Search Operations: Search repositories, code, issues, and users
- Collaboration: Fork repositories, create reviews, and manage collaborators
-
"MCP server not found"
- Ensure you installed the server globally:
npm install -g @modelcontextprotocol/server-github - Verify the installation path matches your system's global npm path
- Ensure you installed the server globally:
-
"Authentication failed"
- Double-check your GitHub personal access token
- Ensure the token has the correct scopes
- Make sure the token hasn't expired
-
"Configuration not loaded"
- Verify the config file is in the correct location
- Check that the JSON syntax is valid
- Ensure Claude Desktop has been restarted after configuration
-
"Permission denied"
- Check that your GitHub token has the necessary permissions
- Verify you have access to the repositories you're trying to interact with
- Check the Claude Desktop logs for error messages
- Verify your configuration file syntax using a JSON validator
- Test your GitHub token using the GitHub API directly
- Ensure Node.js and npm are properly installed
- Store your GitHub personal access token securely
- Use tokens with minimal required permissions
- Regularly rotate your access tokens
- Consider using environment variables instead of hardcoding tokens
- Review and audit repository access regularly
For enhanced security, you can set the token as an environment variable:
-
Set the environment variable:
export GITHUB_PERSONAL_ACCESS_TOKEN=your_token_here -
Update your configuration:
{ "mcpServers": { "github": { "command": "mcp-server-github", "args": [], "env": { "GITHUB_PERSONAL_ACCESS_TOKEN": "${GITHUB_PERSONAL_ACCESS_TOKEN}" } } } }
If you encounter issues:
- Check the official MCP documentation
- Review the GitHub MCP server repository for updates
- Verify your GitHub API limits and usage
- Consult the Claude Desktop support resources
If you find issues with this guide or have suggestions for improvement, please create an issue or submit a pull request to this repository.
This is generated by Claude for testing purposes.