mcp-server
This project is a Model Context Protocol (MCP) server implemented with FastAPI to facilitate AI interaction with GitHub. Key features include GitHub user and repository management, issue handling, and secure communication using OAuth tokens. Future plans involve supporting pull request management and real-time notifications.
š GitHub MCP Server - FastAPI Implementation
š Overview
This project implements a Model Context Protocol (MCP) server using FastAPI, enabling AI assistants like Claude to interact with GitHub. The server provides API endpoints to fetch user details, manage repositories, create issues, and automate GitHub workflows.
⨠Features
- ā Fetch GitHub user details and repositories
- ā Create and manage issues in repositories
- ā List all issues in a repository
- ā Star a repository
- ā AI-powered GitHub Issue Summarization (Optional)
- ā Secure API with GitHub OAuth Token
- ā Asynchronous FastAPI implementation
š ļø Setup & Installation
1ļøā£ Clone the Repository
git clone https://github.com/snehaapratap/mcp-server.git
cd mcp-server
2ļøā£ Create & Activate a Virtual Environment
python3 -m venv venv
source venv/bin/activate
3ļøā£ Install Dependencies
pip install -r requirements.txt
4ļøā£ Set Up Environment Variables
Create a .env
file in the root directory and add your GitHub Personal Access Token (PAT):
GITHUB_TOKEN=your_personal_access_token
5ļøā£ Run the FastAPI Server
uvicorn server:app --reload
The server will start on http://127.0.0.1:8000.
š„ API Endpoints
Method | Endpoint | Description |
---|---|---|
GET | / | Health check for MCP server |
GET | /github/user | Fetch GitHub user details |
GET | /github/repos | Get all repositories of the authenticated user |
POST | /github/create-issue | Create an issue in a repository |
GET | /github/list-issues | List all issues in a repository |
PUT | /github/star-repo | Star a repository |
POST | /github/summarize-issues | AI-powered issue summarization (Optional) |
ā” Usage Examples (cURL)
š¹ Get User Details
curl -X GET "http://127.0.0.1:8000/github/user"
š¹ Fetch Repositories
curl -X GET "http://127.0.0.1:8000/github/repos"
š¹ Create an Issue
curl -X POST "http://127.0.0.1:8000/github/create-issue?owner=your-username&repo=your-repo&title=New%20Issue&body=This%20is%20a%20test%20issue"
š¹ Star a Repository
curl -X PUT "http://127.0.0.1:8000/github/star-repo?owner=your-username&repo=your-repo"
š„ Slides
š View the Slides
š”ļø Error Handling
The API handles errors gracefully and returns meaningful messages:
{
"error": "Invalid GitHub Token",
"hint": "Ensure your token has the 'repo' scope."
}
šÆ Future Enhancements
- š¹ Support for pull requests management
- š¹ Implement WebSockets for real-time GitHub notifications
- š¹ Deploy on AWS/GCP with CI/CD pipeline
š” Contributing
Want to improve this project? Feel free to open a pull request or file an issue!
šØāš» Author
š¹ Sneha P Pratap
š¹ GitHub: @snehaapratap
š¹ LinkedIn: Sneha Prem Pratap