A Python-based Model Context Protocol (MCP) server that lets AI agents interact with GitHub through structured tools. It connects the GitHub API with MCP clients such as GitHub Copilot Agent, enabling natural-language access to repositories, pull requests, and commits.
This project demonstrates how MCP can connect an AI agent to GitHub without putting GitHub API logic directly inside the agent.
flowchart LR
A[User] --> B[GitHub Copilot<br/>Agent]
B -->|MCP| C[Python<br/>GitHub MCP Server]
C -->|GitHub API| D[GitHub]
D --> E[Repositories]
D --> F[Pull Requests]
D --> G[Commits]
- GitHub API integration through MCP
- Repository, pull request, and commit tools
- GitHub Copilot Agent integration
- MCP Inspector support
- Environment-based authentication
| Tool | Description |
|---|---|
list_repositories |
List available repositories |
list_pull_requests |
List repository pull requests |
list_commits |
List repository commits |
get_issues |
Get open repository issues |
With the server connected to Copilot Agent:
List my GitHub repositories.
Show me the open pull requests in alibro005/CardioPredict.
Show me the latest 5 commits in alibro005/CardioPredict.
Copilot selects the appropriate MCP tool, retrieves the data through the server, and returns the result in natural language.
- Python
- Model Context Protocol (MCP)
- GitHub REST API
- GitHub Copilot
- MCP Inspector
- VS Code
github-mcp-server/
│
├── .vscode/
│ └── mcp.json
│
├── assets/
│ └── demo.gif
│
├── tools/
│ ├── repos.py
│ ├── pulls.py
│ ├── commits.py
│ └── issues.py
│
├── server.py
├── requirements.txt
├── .env
├── .gitignore
└── README.md
git clone https://github.com/alibro005/github-mcp-server.git
cd github-mcp-serverpython -m venv .venvWindows:
.venv\Scripts\activateLinux/macOS:
source .venv/bin/activatepip install -r requirements.txtCreate a .env file:
GITHUB_TOKEN=your_github_tokenKeep your token private and add .env to .gitignore:
.env
.venv/
__pycache__/Test the server independently with:
npx @modelcontextprotocol/inspector python server.pyThis verifies tool discovery, execution, and GitHub API responses.
The server was also tested with GitHub Copilot Agent in VS Code to verify the complete workflow:
User → Copilot Agent → MCP Server → GitHub API → Response
- GitHub issue management
- Pull request creation and updates
- Automated PR reviews
- Commit and diff analysis
- Repository search
- AI-generated PR summaries
- GitHub Actions integration
A working MCP integration that allows an AI agent to interact with GitHub using reusable, structured tools instead of directly handling GitHub API operations.
This project is licensed under the MIT License.
