MCP server enabling AI assistants to interact with GitHub
GitHub MCP Server
An open-source Model Context Protocol (MCP) server that enables AI assistants to interact with GitHub through natural language. Automate repository management, issue tracking, pull requests, branch operations, and file management.
🌟 Features
15 Powerful Tools
Repository Management (3 tools):
list_repositories- List all repositoriesget_repository- Get detailed repository infocreate_repository- Create new repository
Issue Management (4 tools):
list_issues- List issues in repositoryget_issue- Get issue detailscreate_issue- Create new issueclose_issue- Close issue with optional comment
Pull Request Management (4 tools):
list_pull_requests- List pull requestsget_pull_request- Get PR detailscreate_pull_request- Create new PRmerge_pull_request- Merge a PR
Branch Management (2 tools):
list_branches- List all branchescreate_branch- Create new branch
File Operations (2 tools):
get_file_contents- Read file from repositorycreate_or_update_file- Create or update file
🚀 Quick Start
Installation
git clone https://github.com/afrah123456/github-mcp-server.git
cd github-mcp-server
pip install -r requirements.txt
Configuration
-
Get a GitHub Personal Access Token:
- Go to https://github.com/settings/tokens
- Generate new token (classic)
- Select scopes:
repo,user,delete_repo
-
Create
.envfile:
cp .env.example .env
- Add your token to
.env:
GITHUB_TOKEN=your_github_token_here
GITHUB_USERNAME=your_username
Run the Server
python run_server.py
The server will start and wait for MCP protocol messages from AI assistants.
💡 Usage Examples
With AI Assistants (Claude, ChatGPT, etc.):
User: "List all my GitHub repositories"
AI → GitHub MCP Server → Returns list
User: "Create issue: Fix login bug"
AI → GitHub MCP Server → Creates issue
User: "Show me all open PRs in my repo"
AI → GitHub MCP Server → Lists PRs
User: "Create branch 'feature-dark-mode' from main"
AI → GitHub MCP Server → Creates branch
🧪 Testing
# Run all tests
pytest tests/ -v
# Test connection
python test_connection.py
# Test all features
python test_mvp.py
Test Results:
- ✅ 6/6 tests passing
- ✅ 100% success rate
- ✅ All 15 tools functional
📁 Project Structure
github-mcp-server/
├── src/github_mcp/
│ ├── server.py # Main MCP server
│ ├── github_client.py # GitHub API client
│ └── config.py # Configuration
├── tests/
│ └── test_github_client.py
├── examples/
│ └── basic_usage.md
├── run_server.py
├── requirements.txt
└── README.md
🛠️ Tech Stack
- Python 3.11+
- PyGithub - GitHub API client
- MCP SDK - Model Context Protocol
- OAuth - Secure authentication
- pytest - Testing framework
🤝 Contributing
Contributions welcome! Feel free to:
- Report bugs
- Suggest features
- Submit pull requests
- Improve documentation
👤 Author
Afrah Fathima S
- GitHub: @afrah123456
- LinkedIn: [https://www.linkedin.com/in/afrah-fathima-b98090241/]
🙏 Acknowledgments
Built using the Model Context Protocol specification and PyGithub library.
📊 Stats
- Tools: 15
- Test Coverage: 100%
- Language: Python
- Status: ✅ Production Ready
Star this repo if you find it useful! ⭐