MCP GitHub Automation Server
README.md
# ๐ค MCP GitHub Automation Server
<p align="center">
<img src="https://capsule-render.vercel.app/api?type=venom&height=260&text=MCP%20GitHub%20Automation&fontSize=42&fontColor=ffffff&color=0:0f172a,50:1e3a8a,100:4f46e5&stroke=6366f1&strokeWidth=2&animation=twinkling&fontAlignY=45" width="100%"/>
</p>
<p align="center">
<strong>AI-Powered GitHub Automation using Model Context Protocol</strong>
</p>
<p align="center">
<a href="#">
<img src="https://img.shields.io/badge/Model%20Context%20Protocol-MCP-6366F1?style=for-the-badge&logo=probot&logoColor=white"/>
</a>
<a href="#">
<img src="https://img.shields.io/badge/Python-3.12-3776AB?style=for-the-badge&logo=python&logoColor=white"/>
</a>
<a href="#">
<img src="https://img.shields.io/badge/Docker-Containerized-2496ED?style=for-the-badge&logo=docker&logoColor=white"/>
</a>
<a href="#">
<img src="https://img.shields.io/badge/AWS-EC2-FF9900?style=for-the-badge&logo=amazonaws&logoColor=white"/>
</a>
</p>
<p align="center">
<a href="#">
<img src="https://img.shields.io/badge/GitHub-Automation-181717?style=for-the-badge&logo=github&logoColor=white"/>
</a>
<a href="#">
<img src="https://img.shields.io/badge/GitHub%20Actions-CI%2FCD-2088FF?style=for-the-badge&logo=githubactions&logoColor=white"/>
</a>
<a href="#">
<img src="https://img.shields.io/badge/GHCR-Container%20Registry-181717?style=for-the-badge&logo=github&logoColor=white"/>
</a>
<a href="#">
<img src="https://img.shields.io/badge/Linux-Ubuntu-E95420?style=for-the-badge&logo=ubuntu&logoColor=white"/>
</a>
</p>
---
## ๐ Project Overview
This project demonstrates how to build, containerize, deploy, and automatically update a **Model Context Protocol (MCP) server** for GitHub automation.
The MCP server is developed using **Python** and exposes GitHub-related tools that can be discovered and invoked by an MCP-compatible AI application.
The complete application is:
```text
Python MCP Server
โ
GitHub REST API
โ
Docker Container
โ
GitHub Container Registry
โ
AWS EC2
โ
GitHub Actions CI/CD
````
---
## ๐ฏ Project Objectives
* ๐ง Understand Model Context Protocol
* ๐ Build a custom MCP server
* ๐ ๏ธ Implement MCP tools
* ๐ Integrate GitHub REST API
* ๐ณ Containerize the MCP server
* โ๏ธ Deploy the server on AWS EC2
* ๐ฆ Publish Docker images to GHCR
* โ๏ธ Implement GitHub Actions CI/CD
* ๐ Secure API credentials
* ๐ Automate application deployment
---
# ๐ง What is MCP?
**Model Context Protocol (MCP)** is a standardized protocol that allows AI applications to interact with external tools, resources, and services.
Instead of creating a separate integration for every AI application and external system, MCP provides a common interface.
```text
โโโโโโโโโโโโโโโโโโโโโโโ
โ AI Application โ
โโโโโโโโโโโโฌโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโ
โ MCP Client โ
โโโโโโโโโโโโฌโโโโโโโโโโโ
โ
MCP Protocol
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโ
โ MCP Server โ
โโโโโโโโโโโโฌโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโ
โ โ โ
โผ โผ โผ
๐ Tools ๐ Resources ๐ฌ Prompts
โ โ โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโ
โ
โผ
External Systems
```
---
# ๐ MCP Architecture
```text
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ AI APPLICATION โ
โ โ
โ ChatGPT / Claude / Other MCP-Compatible AI Application โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโ
โ MCP Client โ
โโโโโโโโโโฌโโโโโโโโโ
โ
โ MCP
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ AWS EC2 โ
โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Docker Container โ โ
โ โ โ โ
โ โ Python MCP Server โ โ
โ โ โ โ
โ โ โโโโโโโโโโโโโโ โโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โ โ
โ โ โ Repository โ โ Issues โ โ Workflows โ โ โ
โ โ โ Tool โ โ Tool โ โ Tool โ โ โ
โ โ โโโโโโโโฌโโโโโโ โโโโโโโฌโโโโโโโ โโโโโโโโฌโโโโโโโโ โ โ
โ โโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโผโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโ
โ โ โ
โโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโ
โผ
โโโโโโโโโโโโโโโโโโโโ
โ GitHub REST API โ
โโโโโโโโโโฌโโโโโโโโโโ
โ
โผ
๐ GitHub
```
---
# ๐ GitHub Automation Use Case
GitHub was selected as the practical MCP use case.
The MCP server provides controlled access to GitHub information through reusable tools.
### Problem
AI applications need a standardized and secure way to interact with GitHub repositories, issues, and workflows.
### MCP Solution
The MCP server acts as a controlled gateway between the AI application and GitHub.
```text
AI
โ
โผ
MCP Client
โ
โผ
MCP Server
โ
โโโ Repository Information
โโโ Issue Management
โโโ Workflow Monitoring
โ
โผ
GitHub API
```
---
# ๐ ๏ธ MCP Tools
| Tool | Purpose |
| ----------------------- | ------------------------------------ |
| `get_repository_info()` | Retrieve repository information |
| `list_issues()` | Retrieve open GitHub issues |
| `get_workflow_status()` | Check GitHub Actions workflow status |
---
## ๐ฆ Repository Information
```text
get_repository_info()
```
Returns:
```text
Repository Name
Description
Visibility
Default Branch
Stars
Forks
```
---
## ๐ Issue Management
```text
list_issues()
```
Returns open GitHub issues.
Example:
```text
Issue #12
Title: Docker deployment issue
State: OPEN
```
---
## โ๏ธ Workflow Monitoring
```text
get_workflow_status()
```
Returns GitHub Actions workflow information.
Example:
```text
Workflow: MCP Server CI/CD
Status: completed
Conclusion: success
Branch: main
```
---
# ๐งฐ Technology Stack
<p align="center">
<img src="https://skillicons.dev/icons?i=python,docker,aws,ubuntu,github,git,githubactions&perline=7" />
</p>
| Category | Technology |
| ------------ | ------------------------- |
| ๐ค Protocol | Model Context Protocol |
| ๐ Language | Python 3.12 |
| ๐ SDK | MCP Python SDK |
| ๐ API | GitHub REST API |
| ๐ HTTP | HTTPX |
| ๐ณ Container | Docker |
| ๐ฆ Registry | GitHub Container Registry |
| โ๏ธ Cloud | AWS |
| ๐ป Compute | EC2 |
| ๐ง OS | Ubuntu |
| โ๏ธ CI/CD | GitHub Actions |
| ๐ฌ Testing | MCP Inspector |
| ๐ Transport | Streamable HTTP |
---
# ๐ Project Structure
```text
github-mcp-server/
โ
โโโ ๐ server.py
โโโ ๐ requirements.txt
โโโ ๐ณ Dockerfile
โโโ ๐ .dockerignore
โโโ ๐ .gitignore
โโโ ๐ README.md
โ
โโโ .github/
โโโ workflows/
โโโ ๐ deploy.yml
```
---
# โ๏ธ Environment Configuration
Create a `.env` file:
```env
GITHUB_TOKEN=your_github_token
GITHUB_OWNER=your_github_username
GITHUB_REPO=your_repository_name
```
### ๐ Never commit `.env`
Add the following to `.gitignore`:
```gitignore
.env
venv/
__pycache__/
*.pyc
```
---
# ๐ป Local Development
## Clone Repository
```bash
git clone https://github.com/YOUR_USERNAME/YOUR_REPOSITORY.git
```
```bash
cd github-mcp-server
```
## Create Virtual Environment
```bash
python -m venv venv
```
Linux:
```bash
source venv/bin/activate
```
Windows:
```powershell
venv\Scripts\activate
```
## Install Dependencies
```bash
pip install -r requirements.txt
```
## Start Server
```bash
python server.py
```
---
# ๐ MCP Endpoint
The MCP server uses **Streamable HTTP**.
Local:
```text
http://localhost:8000/mcp
```
AWS EC2:
```text
http://EC2_PUBLIC_IP:8000/mcp
```
For production:
```text
https://mcp.example.com/mcp
```
---
# ๐ณ Docker
## Build Image
```bash
docker build -t github-mcp-server .
```
## Run Container
```bash
docker run -d \
--name mcp-server \
--env-file .env \
-p 8000:8000 \
github-mcp-server
```
## Verify
```bash
docker ps
```
## View Logs
```bash
docker logs mcp-server
```
---
# ๐ณ Dockerfile
```dockerfile
FROM python:3.12-slim
WORKDIR /app
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY server.py .
EXPOSE 8000
CMD ["python", "server.py"]
```
---
# โ๏ธ AWS EC2 Deployment
The MCP server is deployed on an Ubuntu EC2 instance using Docker.
## Install Docker
```bash
sudo apt update
sudo apt install -y docker.io
```
Enable Docker:
```bash
sudo systemctl enable docker
sudo systemctl start docker
```
Verify:
```bash
docker --version
```
---
## Clone Project
```bash
git clone https://github.com/YOUR_USERNAME/YOUR_REPOSITORY.git
```
```bash
cd github-mcp-server
```
---
## Configure Environment
```bash
nano .env
```
Add:
```env
GITHUB_TOKEN=your_github_token
GITHUB_OWNER=your_github_username
GITHUB_REPO=your_repository_name
```
Secure the file:
```bash
chmod 600 .env
```
---
## Run MCP Server
```bash
docker build -t github-mcp-server .
```
```bash
docker run -d \
--name mcp-server \
--restart unless-stopped \
--env-file .env \
-p 8000:8000 \
github-mcp-server
```
Verify:
```bash
docker ps
```
---
# ๐ CI/CD Pipeline
<p align="center">
<img src="https://capsule-render.vercel.app/api?type=rect&color=0:111827,100:2563EB&height=100§ion=header&text=Automated%20CI%2FCD%20Pipeline&fontSize=30&fontColor=FFFFFF" width="100%"/>
</p>
```text
๐จโ๐ป Developer
โ
โ git push
โผ
๐ GitHub Repository
โ
โผ
โ๏ธ GitHub Actions
โ
โโโโโโโโโโโดโโโโโโโโโโ
โ โ
โผ โผ
๐งช Test ๐ณ Build
โ โ
โโโโโโโโโโโฌโโโโโโโโโโ
โ
โผ
๐ฆ Docker Image
โ
โผ
๐ฆ GHCR
โ
โผ
๐ SSH Deploy
โ
โผ
โ๏ธ AWS EC2
โ
โผ
๐ณ Docker
โ
โผ
๐ค MCP Server
```
---
# โ๏ธ GitHub Actions
The pipeline automatically executes when code is pushed to the `main` branch.
### Pipeline Stages
```text
Checkout
โ
Setup Python
โ
Install Dependencies
โ
Run Tests
โ
Build Docker Image
โ
Login to GHCR
โ
Push Docker Image
โ
Connect to EC2
โ
Pull Latest Image
โ
Stop Old Container
โ
Start New Container
```
---
# ๐ GitHub Secrets
Configure secrets under:
```text
Repository
โ
Settings
โ
Secrets and variables
โ
Actions
```
Required:
```text
EC2_HOST
EC2_USERNAME
EC2_SSH_KEY
GHCR_USERNAME
GHCR_TOKEN
```
Secrets must never be committed to GitHub.
---
# ๐ฆ GitHub Container Registry
Images are stored in GHCR.
Example:
```text
ghcr.io/YOUR_USERNAME/github-mcp-server:latest
```
Commit-based image:
```text
ghcr.io/YOUR_USERNAME/github-mcp-server:<commit-sha>
```
This provides versioned and reproducible container deployments.
---
# ๐งช Testing
## Python Syntax Test
```bash
python -m py_compile server.py
```
## Docker Build Test
```bash
docker build -t github-mcp-server .
```
## Container Test
```bash
docker ps
```
## Log Verification
```bash
docker logs mcp-server
```
---
# ๐ MCP Tool Verification
Connect an MCP-compatible client or MCP Inspector to:
```text
http://localhost:8000/mcp
```
Verify tool discovery:
```text
โ get_repository_info
โ list_issues
โ get_workflow_status
```
---
# ๐ Security
Security is critical because MCP servers can provide AI applications with access to external systems.
### ๐ Secret Management
Never hard-code:
```text
GitHub Tokens
AWS Credentials
SSH Keys
API Keys
Passwords
```
Use:
```text
GitHub Secrets
Environment Variables
AWS Secrets Manager
```
---
### ๐ก๏ธ Least Privilege
GitHub tokens should only receive the permissions required by the MCP tools.
Prefer read-only permissions when write operations are not required.
---
### ๐ซ Avoid Dangerous Tools
Avoid unrestricted operations such as:
```text
delete_repository()
delete_branch()
merge_pull_request()
create_deployment()
```
unless proper authorization and confirmation are implemented.
---
### ๐ Network Security
Restrict EC2 access.
Recommended:
```text
SSH
Port 22
Source: Your IP/32
```
For production MCP access:
```text
HTTPS
Port 443
Source: Authorized Clients
```
---
### ๐ง Prompt Injection Protection
GitHub issues, comments, pull requests, and repository content may contain untrusted instructions.
External content should be treated as **data**, not automatically as trusted instructions.
---
# ๐ Deployment Verification
After making changes:
```bash
git add .
```
```bash
git commit -m "Update MCP server"
```
```bash
git push origin main
```
GitHub Actions:
```text
๐งช Test โ โ
Passed
๐ณ Docker Build โ โ
Passed
๐ฆ GHCR Push โ โ
Passed
โ๏ธ EC2 Deploy โ โ
Passed
```
EC2:
```bash
docker ps
```
Logs:
```bash
docker logs mcp-server
```
---
# ๐ End-to-End Workflow
```text
โโโโโโโโโโโโโโโโโโโ
โ Developer โ
โโโโโโโโโโฌโโโโโโโโโ
โ
git push
โ
โผ
โโโโโโโโโโโโโโโโโโโ
โ GitHub โ
โโโโโโโโโโฌโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโ
โ GitHub Actions โ
โโโโโโโโโโฌโโโโโโโโโ
โ
โโโโโโโโโโโดโโโโโโโโโโ
โ โ
โผ โผ
๐งช Test ๐ณ Build
โ โ
โโโโโโโโโโโฌโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโ
โ GHCR โ
โโโโโโโโโโฌโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโ
โ AWS EC2 โ
โโโโโโโโโโฌโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโ
โ Docker Containerโ
โโโโโโโโโโฌโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโ
โ MCP Server โ
โโโโโโโโโโฌโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโ
โ GitHub API โ
โโโโโโโโโโโโโโโโโโโ
```
---
# ๐ MCP Concepts Covered
| Concept | Description |
| --------------- | --------------------------------------- |
| MCP Client | Connects AI applications to MCP servers |
| MCP Server | Exposes capabilities to MCP clients |
| Tools | Executable functions |
| Resources | Data/context exposed to clients |
| Prompts | Reusable interaction templates |
| Transport | Communication mechanism |
| Tool Discovery | Client discovers available tools |
| Tool Invocation | Client calls a selected tool |
---
# ๐ Key DevOps Practices
```text
SOURCE CONTROL
โ
โผ
GIT
โ
โผ
CI/CD PIPELINE
โ
โผ
AUTOMATED TEST
โ
โผ
DOCKER BUILD
โ
โผ
CONTAINER REGISTRY
โ
โผ
CLOUD DEPLOYMENT
โ
โผ
RUNTIME SECRETS
โ
โผ
SECURITY
```
---
# โจ Project Highlights
* ๐ค Custom MCP server built with Python
* ๐ GitHub REST API integration
* ๐ ๏ธ Three reusable MCP tools
* ๐ Streamable HTTP transport
* ๐ณ Docker containerization
* ๐ฆ GitHub Container Registry
* โ๏ธ AWS EC2 deployment
* โ๏ธ GitHub Actions CI/CD
* ๐ Secure secret management
* ๐ก๏ธ Least-privilege access
* ๐ Automated deployment
* ๐งช Automated validation
* ๐ GitHub workflow monitoring
---
# ๐ฎ Future Enhancements
```text
HTTPS
โ
Custom Domain
โ
AWS ALB
โ
AWS Secrets Manager
โ
Amazon ECR
โ
Amazon ECS
โ
Kubernetes
โ
Terraform
โ
Prometheus
โ
Grafana
```
Potential MCP improvements:
* ๐ Repository search
* ๐ Pull request management
* ๐ Create GitHub issues
* ๐ฌ Pull request comments
* ๐ท๏ธ GitHub label management
* ๐ Authentication and authorization
* ๐ฆ Rate limiting
* ๐ Monitoring and observability
* ๐ก๏ธ Container vulnerability scanning
---
# ๐ Skills Demonstrated
<p align="center">
<img src="https://skillicons.dev/icons?i=python,docker,aws,linux,github,git,githubactions,terraform,kubernetes&perline=9" />
</p>
```text
Model Context Protocol
Python
GitHub REST API
Docker
AWS EC2
GitHub Actions
GHCR
Linux
Git
CI/CD
REST APIs
Cloud Security
Containerization
Automation
```
---
# ๐ Learning Outcomes
By completing this project, the following concepts were implemented and understood:
* Model Context Protocol
* MCP Client and Server architecture
* MCP Tools
* MCP Resources
* MCP Prompts
* Tool discovery
* Tool invocation
* GitHub API integration
* Python MCP development
* Streamable HTTP
* Docker containerization
* GHCR
* AWS EC2
* GitHub Actions
* CI/CD automation
* Secret management
* Cloud security
* Automated deployment
---
# ๐ผ Resume Project Description
> **MCP GitHub Automation Server | Python, MCP, Docker, AWS EC2, GitHub Actions**
>
> Developed and deployed a Python-based Model Context Protocol server for GitHub automation, exposing tools for repository information, issue retrieval, and GitHub Actions workflow monitoring. Containerized the application using Docker, published images to GitHub Container Registry, deployed on AWS EC2, and implemented GitHub Actions CI/CD for automated testing, image publishing, and remote deployment. Applied secure credential management, least-privilege access, and cloud network security practices.
---
# ๐จโ๐ป Author
## Venu Gopala Reddy Eppala
**Cloud & DevOps Engineer**
<p align="left">
<img src="https://img.shields.io/badge/AWS-Cloud-FF9900?style=flat-square&logo=amazonaws&logoColor=white"/>
<img src="https://img.shields.io/badge/Docker-Containers-2496ED?style=flat-square&logo=docker&logoColor=white"/>
<img src="https://img.shields.io/badge/Kubernetes-Orchestration-326CE5?style=flat-square&logo=kubernetes&logoColor=white"/>
<img src="https://img.shields.io/badge/Terraform-IaC-7B42BC?style=flat-square&logo=terraform&logoColor=white"/>
<img src="https://img.shields.io/badge/CI%2FCD-Automation-2088FF?style=flat-square&logo=githubactions&logoColor=white"/>
</p>
---
<p align="center">
<img src="https://capsule-render.vercel.app/api?type=waving&color=0:4F46E5,50:1E3A8A,100:0F172A&height=120§ion=footer" width="100%"/>
</p>
<p align="center">
<strong>Built with MCP โข Docker โข AWS โข GitHub Actions</strong>
</p>
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo issues