The Model Context Protocol (MCP) server, a powerful tool introduced by Anthropic, bridges the gap between your AI assistant and your GitHub repository. By setting up an MCP server, you can directly query your code, read/write files, generate insights, and step-up your development workflow.
In this guide, we'll walk you through the steps of setting up a GitHub MCP server on both Windows and macOS for use with the Claude Desktop app.
Prerequisites
Before you begin, ensure you have the following installed on your system:
Node.js
andnpm
(Node Package Manager)- The latest version of
Claude Desktop
- A GitHub account with appropriate permissions
Step 1: Generate a GitHub Personal Access Token
To allow the MCP server to interact with your GitHub repositories, you'll need a Personal Access Token (PAT) with the necessary permissions.
- Log in to your GitHub account and navigate to Personal access tokens in your account settings.
- Click on Generate new token.
- Provide a descriptive name for your token, such as Claude MCP Server Access.
- Select the required scopes for your token:
- For full access to private repositories, select
repo
. - For access to public repositories only, select
public_repo
. - Scroll down and click on Generate token.
- Copy the generated token and save it securely. You'll need it in later steps.
Step 2: Install the GitHub MCP Server
With your token ready, you can now install the GitHub MCP server using npm
.
Open your terminal or command prompt, and install the GitHub MCP server globally by running:
npm install -g @modelcontextprotocol/server-github
Step 3: Configure the MCP Server
Next, you'll configure the MCP server to use your GitHub Personal Access Token.
Set the environment variable for your token. In your terminal, run:
export GITHUB_PERSONAL_ACCESS_TOKEN="your_token_here"
Replace your_token_here
with the token you saved earlier.
Step 4: Update the Claude Desktop Coniguration
Now, you'll update Claude Desktop's configuration to include the GitHub MCP server.
- Locate the
config.json
file (on Windows) orclaude_desktop_config.json
file on your macOS. This file is typically found in the Claude Desktop settings directory.
- Windows:
%APPDATA%/Claude/config.json
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json
- Edit the configuration file to add the following settings:
{
"mcpServers": {
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "your_token_here"
}
}
}
}
Ensure you replace your_token_here
with your actual GitHub Personal Access Token.
Step 5: Restart Claude Desktop
For the changes to take effect, you'll need to restart Claude Desktop.
- Completely close Claude Desktop, making sure it's not running in the background.
- Reopen Claude Desktop.
Step 6: Verify the Integration
Finally, confirm that the GitHub MCP server is properly integrated with Claude Desktop.
- In Claude Desktop, start a new conversation.
- Ask Claude to perform a simple GitHub operation, such as listing your repositories or creating a new issue.
- If everything is set up correctly, Claude should be able to interact with your GitHub repositories seamlessly.
With your GitHub MCP server configured and connected to Claude Desktop, you can now manage your repositories and perform file operations directly from your desktop environment.
Member discussion