A Python implementation of the GitHub Message Control Protocol (MCP) server for facilitating communication between Windsurf and GitHub.
This server provides an interface for communicating with GitHub services via either:
- Standard I/O (stdio) streams using JSON-RPC messages
- HTTP API endpoints
It supports various GitHub operations and is designed to run in both standalone mode and containerized environments.
- Modern Python implementation with async support
- Standard I/O communication using JSON-RPC
- REST API interface for HTTP communication
- Configurable GitHub toolsets
- Comprehensive capability advertising
- Advanced GitHub integrations:
- Repository management
- Issue tracking with labels and comments
- Project management (see note on GitHub Projects below)
- Pull request operations
- Content management
- Comprehensive logging
- Docker support with configurable ports
- Read-only mode option for restricted operations
GitHub has deprecated the classic Projects API in favor of their new Projects experience. This MCP server now uses GitHub's GraphQL API to interact with Projects v2, providing full support for the new Projects experience. This means:
- Project operations use GraphQL instead of REST API
- Instead of moving cards between columns, you now update a status field value
- Item IDs are GraphQL node IDs rather than numeric IDs
The API methods maintain backwards compatibility with existing code while using the modern Projects v2 implementation behind the scenes.
- Python 3.10+
- Pip
- Clone the repository:
git clone https://github.com/yourusername/github-mcp-py.git
cd github-mcp-py- Install dependencies:
pip install -r requirements.txtThe MCP server requires a GitHub Personal Access Token to authenticate with the GitHub API. Follow these steps to create one:
-
Go to your GitHub account settings: https://github.com/settings/tokens
-
Click on "Generate new token" (classic)
-
Give your token a descriptive name, e.g., "GitHub MCP Server"
-
Set an expiration date (or choose "No expiration" for testing purposes)
-
Select the following permissions:
- repo: Full control of private repositories
- repo:status: Access commit status
- repo_deployment: Access deployment status
- public_repo: Access public repositories
- repo:invite: Access repository invitations
- user: Read all user profile data
- read:org: Read org and team data
- workflow: Update GitHub Action workflows
- repo: Full control of private repositories
-
Click "Generate token"
-
Copy the generated token (it will only be shown once)
-
Set the token as an environment variable:
export GITHUB_PERSONAL_ACCESS_TOKEN="your_token_here"IMPORTANT: Keep your token secure. Anyone with your token can access your GitHub account with the permissions you specified. Never commit your token to version control or share it publicly.
Create a .env file or set the following environment variables:
GITHUB_PERSONAL_ACCESS_TOKEN=your_github_token
GITHUB_HOST=github.com # Optional: For GitHub Enterprise
GITHUB_READ_ONLY=false # Optional: Set to true for read-only operations
GITHUB_LOG_FILE=path/to/logfile.log # Optional: Log file path
GITHUB_ENABLE_COMMAND_LOGGING=false # Optional: Log all commands
GITHUB_TOOLSETS=all # Optional: Comma-separated list of toolsets to enable
GITHUB_DYNAMIC_TOOLSETS=false # Optional: Enable dynamic toolsets
The GitHub MCP Server supports the following API methods:
repository.get- Get repository detailsrepository.list- List repositories for a user or organizationrepository.list_branches- List branches in a repositoryrepository.get_branch- Get details of a specific branch
issue.get- Get issue detailsissue.list- List issues in a repositoryissue.create- Create a new issueissue.update- Update an existing issueissue.add_labels- Add labels to an issueissue.remove_label- Remove a label from an issueissue.comment- Add a comment to an issue
pullrequest.get- Get pull request detailspullrequest.list- List pull requests in a repositorypullrequest.create- Create a new pull requestpullrequest.update- Update an existing pull requestpullrequest.merge- Merge a pull request
projects.list- List projects in a repositoryprojects.get_columns- Get columns in a projectprojects.get_cards- Get cards in a project columnprojects.move_card- Move a card to a different column or position
content.get- Get file contentscontent.create- Create a filecontent.update- Update file contents
user.get- Get user detailsuser.list_followers- List a user's followersuser.list_following- List users a user is following
Run the server with stdio communication:
python -m github_mcp_server stdioRun the server with HTTP API:
python -m github_mcp_server http --port 8080docker build -t github-mcp-server .docker run -p 8080:8080 \
-e GITHUB_PERSONAL_ACCESS_TOKEN=your_token \
github-mcp-server http --port 8080For stdio mode (for integration with Windsurf):
docker run -i \
-e GITHUB_PERSONAL_ACCESS_TOKEN=your_token \
github-mcp-server stdioTo integrate this MCP server with Windsurf in a containerized environment:
- Run the GitHub MCP server in a container:
docker run -d --name github-mcp \
-e GITHUB_PERSONAL_ACCESS_TOKEN=your_token \
github-mcp-server stdio- Configure Windsurf to connect to the MCP server container:
In your Windsurf container setup, add:
services:
windsurf:
# ... windsurf configuration ...
environment:
- MCP_GITHUB_SERVER=github-mcp
depends_on:
- github-mcp- In your Windsurf configuration, specify the MCP server endpoint:
MCP_GITHUB_SERVER_MODE=container
MCP_GITHUB_SERVER_CONTAINER=github-mcp
If using HTTP mode instead of stdio:
- Run the GitHub MCP server with HTTP:
docker run -d --name github-mcp -p 8080:8080 \
-e GITHUB_PERSONAL_ACCESS_TOKEN=your_token \
github-mcp-server http --port 8080- Configure Windsurf to connect via HTTP:
MCP_GITHUB_SERVER_MODE=http
MCP_GITHUB_SERVER_URL=http://github-mcp:8080
The HTTP server exposes a REST API and JSON-RPC endpoints. Documentation available at /docs or /redoc when running the HTTP server.
pytest[Add your license here]