Skip to content

Commit cff52bc

Browse files
saidsefCopilot
andauthored
feat: Implement containerization, SSE server and improve infrastructure (#1)
* chore: add ci workflow to create container * chore: ping python version * feat: add mcp sse server via docker * docs: update architecture and deplyment method * feat: add python setup file * feat: add ip integration class * chore: add tag and release to workflows * chore: typo fix Co-authored-by: Copilot <[email protected]> * chore: run build piepline * fix: docker build script * chore: update python dep libs * docs: update intro section * fix: typo Co-authored-by: Copilot <[email protected]> * docs: update description for get_pr_diff Co-authored-by: Copilot <[email protected]> * Update github_integration.py Co-authored-by: Copilot <[email protected]> * Update pyproject.toml Co-authored-by: Copilot <[email protected]> * Update Dockerfile Co-authored-by: Copilot <[email protected]> * chore: add open containers labels --------- Co-authored-by: Copilot <[email protected]>
1 parent a8a833a commit cff52bc

File tree

11 files changed

+622
-81
lines changed

11 files changed

+622
-81
lines changed

.github/workflows/ci.yml

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
name: CI
2+
on:
3+
push:
4+
branches:
5+
- main
6+
paths:
7+
- "*.py"
8+
- ".github/workflows/ci.yml"
9+
pull_request:
10+
branches:
11+
- main
12+
paths:
13+
- "*.py"
14+
- ".github/workflows/ci.yml"
15+
workflow_dispatch:
16+
17+
env:
18+
REGISTRY: ghcr.io
19+
OWNER: ${{ github.repository_owner }}
20+
REPO_NAME: ${{ github.event.repository.name }}
21+
22+
jobs:
23+
analyze:
24+
name: analyze
25+
runs-on: ubuntu-latest
26+
strategy:
27+
fail-fast: false
28+
matrix:
29+
language: ['python']
30+
steps:
31+
- name: Checkout repository
32+
uses: actions/checkout@v4
33+
- name: Initialize CodeQL
34+
uses: github/codeql-action/init@v3
35+
with:
36+
languages: ${{ matrix.language }}
37+
- name: Autobuild
38+
uses: github/codeql-action/autobuild@v3
39+
- name: Perform CodeQL Analysis
40+
uses: github/codeql-action/analyze@v3
41+
42+
review:
43+
uses: saidsef/saidsef/.github/workflows/dependency-review.yaml@main
44+
if: ${{ github.event_name == 'pull_request' }}
45+
needs: [analyze]
46+
47+
build:
48+
runs-on: ubuntu-latest
49+
needs: [analyze]
50+
steps:
51+
- name: Checkout source code
52+
uses: actions/checkout@v4
53+
with:
54+
lfs: 'true'
55+
- name: Set Tag Name
56+
run: |
57+
echo "TAG=$(echo ${{ github.head_ref || github.ref_name }})" >> $GITHUB_ENV
58+
echo "DATE=v$(echo `date +'%Y.%m'`)" >> $GITHUB_ENV
59+
60+
- name: Run Trivy config vulnerability scanner
61+
uses: aquasecurity/trivy-action@master
62+
continue-on-error: true
63+
with:
64+
scan-type: "config"
65+
scan-ref: "."
66+
67+
- name: Login to DockerHub
68+
uses: docker/login-action@v3
69+
with:
70+
registry: ${{ env.REGISTRY }}
71+
username: ${{ env.OWNER }}
72+
password: ${{ github.token }}
73+
- name: Set up QEMU
74+
uses: docker/setup-qemu-action@v3
75+
with:
76+
platforms: all
77+
- name: Set up Docker Buildx
78+
id: buildx
79+
uses: docker/setup-buildx-action@v3
80+
env:
81+
DOCKER_BUILDKIT: 1
82+
- name: Build and push Docker image
83+
uses: docker/build-push-action@v5
84+
env:
85+
DOCKER_BUILD_SUMMARY: true
86+
DOCKER_BUILD_CHECKS_ANNOTATIONS: true
87+
DOCKER_BUILD_RECORD_RETENTION_DAYS: 10
88+
with:
89+
context: .
90+
file: ./Dockerfile
91+
platforms: linux/amd64,linux/arm64
92+
build-args: |
93+
BUILD_ID=${{ env.DATE }}
94+
pull: true
95+
push: true
96+
sbom: true
97+
provenance: true
98+
cache-from: type=gha
99+
cache-to: type=gha,mode=max
100+
tags: ${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.REPO_NAME }}:${{ env.TAG != 'main' && env.TAG || env.DATE }}
101+
102+
auto-approve:
103+
runs-on: ubuntu-latest
104+
needs: [build]
105+
if: ${{ github.event_name == 'pull_request' }}
106+
steps:
107+
- name: Auto Approve PR
108+
uses: actions/github-script@v7
109+
with:
110+
script: |
111+
github.rest.pulls.createReview({
112+
owner: context.repo.owner,
113+
repo: context.repo.repo,
114+
pull_number: context.issue.number,
115+
event: "APPROVE"
116+
})

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.12

Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM docker.io/python:3.12-alpine
2+
3+
LABEL org.opencontainers.image.description="MCP for GitHub PR, Issues, Tags and Releases"
4+
LABEL org.opencontainers.image.authors="Said Sef"
5+
LABEL org.opencontainers.image.documentation="https://github.com/saidsef/mcp-github-pr-issue-analyser/blob/main/README.md"
6+
LABEL org.opencontainers.image.source="https://github.com/saidsef/mcp-github-pr-issue-analyser.git"
7+
LABEL org.opencontainers.image.licenses="Apache License, Version 2.0"
8+
9+
ENV MCP_ENABLE_REMOTE="true"
10+
11+
WORKDIR /app
12+
13+
COPY requirements.txt github_integration.py ip_integration.py issues_pr_analyser.py /app
14+
15+
RUN pip install --no-cache-dir -r requirements.txt
16+
17+
EXPOSE 8080
18+
19+
CMD ["python3", "issues_pr_analyser.py"]

README.md

Lines changed: 54 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
1-
# MCP GitHub Issues Create/Update and PR Analyse
1+
# MCP for GitHub PR, Issues, Tags and Releases
22

3-
The [Model Context Protocol](https://www.anthropic.com/news/model-context-protocol) (MCP) is an open standard that can be implemented in any AI system, including Custom LLM setups. However, the degree of integration and optimisation varies based on the model's architecture and capabilities.
3+
The [Model Context Protocol](https://www.anthropic.com/news/model-context-protocol) (MCP) is an open standard that enables seamless integration between Large Language Models (LLMs) and external tools. Whilst it can be implemented in any AI system, including custom LLM setups, the degree of integration and optimisation varies based on the model's architecture and capabilities.
44

5-
This MCP application analyses GitHub pull requests and managing issues. It provides a set of tools to fetch PR details, create issues, and update issues directly from your desktop LLM as part of an automated workflow. The application is designed for integration with other systems and supports extensibility via the MCP tool interface.
5+
This MCP application serves as a bridge between LLMs and GitHub's repository management features, offering automated analysis of pull requests and comprehensive issue management. It provides a robust set of tools to fetch PR details, create issues, and update issues directly from your desktop LLM. The application is designed with modularity in mind, supporting extensibility via the MCP tool interface and seamless integration with existing workflows.
6+
7+
The toolset enables automated PR analysis, issue tracking, tagging and release management through a standardised MCP interface, making it ideal for teams seeking to streamline their GitHub workflow automation.
68

79
## Features
810

9-
| Feature | Function Name | Description |
10-
|-----------------------------|---------------------------|-----------------------------------------------------------------------------------------------|
11-
| Fetch Pull Request Details | `fetch_pr` | Retrieve metadata and content for any GitHub pull request. |
12-
| Update PR Description | `update_pr_description` | Update the description of a GitHub pull request, including file changes and context. |
13-
| Create GitHub Issues | `create_github_issue` | Easily create new issues from a PR with custom titles and bodies, including label support. |
14-
| Update GitHub Issues | `update_github_issue` | Update existing issues with new titles and descriptions. |
11+
| Feature | Function Name | Description |
12+
|----------------------------|--------------------------------|-----------------------------------------------------------------------------------------------|
13+
| PR Content Retrieval | `get_github_pr_content` | Fetch PR metadata including title, description, author, and state. |
14+
| PR Diff Analysis | `get_github_pr_diff` | Retrieve the diff/patch content showing file changes in the PR. |
15+
| PR Description Updates | `update_github_pr_description` | Update PR titles and descriptions with What/Why/How sections and file changes. |
16+
| Issue Creation | `create_github_issue` | Create new issues with conventional commit prefixes (feat/fix/chore) and MCP label. |
17+
| Issue Updates | `update_github_issue` | Modify existing issues with new title, body, and state (open/closed). |
18+
| Tag Management | `create_github_tag` | Create new git tags with associated messages for versioning. |
19+
| Release Management | `create_github_release` | Generate GitHub releases with automatic release notes and tag references. |
20+
| Network Information | `get_ipv4_ipv6_info` | Fetch IPv4 and IPv6 network information for the system. |
1521
| MCP Tool Registration | `_register_tools` | Tools are registered and exposed via the MCP server for easy integration. |
1622

1723
## Requirements
@@ -22,38 +28,48 @@ This MCP application analyses GitHub pull requests and managing issues. It provi
2228
## Architecture Diagram
2329

2430
```ascii
25-
+-------------------+ +--------------------------+
26-
| | | |
27-
| LLM 🤖 | <-----> | MCP Server (FastMCP) |
28-
| | | (issues_pr_analyser.py) |
29-
+-------------------+ +--------------------------+
30-
|
31-
| (calls tools)
32-
v
33-
+-------------------------------+
34-
| GitHub Integration (GI) |
35-
| (github_integration.py) |
36-
+-------------------------------+
37-
|
38-
| (REST API calls)
39-
v
40-
+------------------------+
41-
| GitHub API |
42-
+------------------------+
31+
+------------------------+
32+
| |
33+
| MCP Client/User |
34+
| |
35+
+------------------------+
36+
|
37+
| (stdio/SSE)
38+
v
39+
+--------------------+ +------------------------+
40+
| | | PRIssueAnalyser |
41+
| IP Integration | <------------| (FastMCP Server) |
42+
| (ipinfo.io) | | |
43+
+--------------------+ +------------------------+
44+
|
45+
| (API calls)
46+
v
47+
+------------------------+
48+
| GitHub Integration |
49+
+------------------------+
50+
|
51+
| (REST API)
52+
+-------------------------+-------------------------+
53+
| | |
54+
+-------------+ +--------------+ +-------------+
55+
| GitHub PRs | |GitHub Issues | |GitHub Tags/ |
56+
| & Releases | | | | Releases |
57+
+-------------+ +--------------+ +-------------+
4358
```
4459

45-
### Legend:
60+
### Features:
4661

47-
- LLM interacts with the MCP server (e.g., via stdio or other transport).
48-
- MCP Server (FastMCP) hosts tools for PR analysis and issue management.
49-
- GitHub Integration (GI) handles actual API requests to GitHub.
50-
- GitHub API is the external service for PR and issue data.
62+
1. PR Management: Fetch, analyze, and update
63+
2. Issue Tracking: Create and update
64+
3. Release Management: Tags and releases
65+
4. Network Info: IPv4/IPv6 details
5166

5267
### Main Flows:
5368

54-
- LLM requests (e.g., fetch PR, create/update issue) go to MCP Server.
55-
- MCP Server delegates to GI for GitHub operations.
56-
- GutHubIntegration class communicates with GitHub API and returns results up the stack.
69+
- PRIssueAnalyser: Main MCP server handling tool registration and requests
70+
- GitHub Integration: Manages all GitHub API interactions
71+
- IP Integration: Handles IPv4/IPv6 information retrieval
72+
- MCP Client: Interacts via stdio or Server-Sent Events (SSE)
5773

5874
## Local Installation
5975

@@ -71,23 +87,18 @@ uv pip install -r requirements.txt
7187
```
7288
## Local Integration with Desktop LLMs
7389

74-
To add an MCP server to your desktop LLM such as Claude, LM Studio etc.., you need to add this section to the configuration file. The basic structure involves defining a server name and providing the command and any necessary arguments to run the server.
90+
To add an MCP server to your desktop LLM such as Claude etc.., you need to add this section to the configuration file. The basic structure involves defining a server name and providing the command and any necessary arguments to run the server.
7591

7692
```json
7793
{
7894
"mcpServers": {
7995
"github_pr_issues": {
80-
"command": "uv",
96+
"command": "uvx",
8197
"env": {
8298
"GITHUB_TOKEN": "<your-github-token>"
8399
},
84100
"args": [
85-
"run",
86-
"--with",
87-
"mcp[cli]",
88-
"--with",
89-
"requests",
90-
"/path/to/mcp-github-pr-issue-analyser/issues_pr_analyser.py"
101+
"https://github.com/saidsef/mcp-github-pr-issue-analyser.git"
91102
]
92103
}
93104
}

0 commit comments

Comments
 (0)