Spaces:
Running
Running
Upload folder using huggingface_hub
Browse files- Dockerfile +19 -0
- README.md +28 -10
- pyproject.toml +201 -0
- src/mcp-github/Dockerfile +19 -0
- src/mcp-github/README.md +28 -0
- src/mcp-github/server.py +173 -0
Dockerfile
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
FROM python:3.12-slim
|
| 3 |
+
|
| 4 |
+
WORKDIR /app
|
| 5 |
+
|
| 6 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 7 |
+
git \
|
| 8 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 9 |
+
|
| 10 |
+
COPY pyproject.toml .
|
| 11 |
+
RUN pip install --no-cache-dir .
|
| 12 |
+
|
| 13 |
+
COPY src/mcp-github ./src/mcp-github
|
| 14 |
+
|
| 15 |
+
ENV PYTHONPATH=/app/src
|
| 16 |
+
|
| 17 |
+
EXPOSE 7860
|
| 18 |
+
|
| 19 |
+
CMD ["python", "src/mcp-github/server.py", "--transport", "sse", "--port", "7860", "--host", "0.0.0.0"]
|
README.md
CHANGED
|
@@ -1,10 +1,28 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
---
|
| 3 |
+
title: MCP GitHub
|
| 4 |
+
emoji: 🐙
|
| 5 |
+
colorFrom: gray
|
| 6 |
+
colorTo: yellow
|
| 7 |
+
sdk: docker
|
| 8 |
+
pinned: false
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
# MCP GitHub Server
|
| 12 |
+
|
| 13 |
+
This is a Model Context Protocol (MCP) server for GitHub repository management and automation.
|
| 14 |
+
|
| 15 |
+
## Tools
|
| 16 |
+
- `list_issues`: List repository issues.
|
| 17 |
+
- `create_issue`: Create a new issue.
|
| 18 |
+
- `get_issue`: Get detailed issue info.
|
| 19 |
+
- `create_pull_request`: Create a new PR.
|
| 20 |
+
- `list_security_alerts`: Check for security alerts.
|
| 21 |
+
|
| 22 |
+
## Configuration
|
| 23 |
+
Requires `GITHUB_TOKEN` secret in Hugging Face Space settings.
|
| 24 |
+
|
| 25 |
+
## Running Locally
|
| 26 |
+
```bash
|
| 27 |
+
python src/mcp-github/server.py
|
| 28 |
+
```
|
pyproject.toml
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[project]
|
| 2 |
+
name = "agenticai"
|
| 3 |
+
version = "0.1.0"
|
| 4 |
+
description = "Agentic AI project"
|
| 5 |
+
readme = "README.md"
|
| 6 |
+
requires-python = "==3.12.*"
|
| 7 |
+
|
| 8 |
+
dependencies = [
|
| 9 |
+
# =======================
|
| 10 |
+
# LLM PROVIDERS / SDKs
|
| 11 |
+
# =======================
|
| 12 |
+
"openai>=2.8.1",
|
| 13 |
+
"openai-agents>=0.5.1",
|
| 14 |
+
"anthropic>=0.49.0",
|
| 15 |
+
"langchain-openai>=1.0.3",
|
| 16 |
+
"langchain-anthropic>=1.1.0",
|
| 17 |
+
"langchain_huggingface>=1.1.0",
|
| 18 |
+
"langchain_ollama>=1.0.0",
|
| 19 |
+
"langchain_google_genai>=3.0.3",
|
| 20 |
+
"langchain_groq>=1.0.1",
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
# =======================
|
| 24 |
+
# LANGCHAIN / LANGGRAPH
|
| 25 |
+
# =======================
|
| 26 |
+
"langchain>=1.0.7",
|
| 27 |
+
"langchain-community>=0.4.1",
|
| 28 |
+
"langgraph>=1.0.3",
|
| 29 |
+
"langgraph-checkpoint-sqlite>=3.0.0",
|
| 30 |
+
"langsmith>=0.4.43",
|
| 31 |
+
"langchain-text-splitters>=1.0.0",
|
| 32 |
+
"langchain-chroma>=1.0.0",
|
| 33 |
+
"html2text>=2025.4.15",
|
| 34 |
+
"traceloop-sdk>=0.33.0",
|
| 35 |
+
|
| 36 |
+
# =======================
|
| 37 |
+
# MICROSOFT AGENT FRAMEWORK
|
| 38 |
+
# =======================
|
| 39 |
+
#"agent-framework==1.0.0b251204",
|
| 40 |
+
#"agent-framework-azure-ai==1.0.0b251204",
|
| 41 |
+
#"azure-ai-projects",
|
| 42 |
+
#"azure-ai-agents",
|
| 43 |
+
#"azure-ai-agents>=1.2.0b5",
|
| 44 |
+
#"agent-framework-azure-ai",
|
| 45 |
+
|
| 46 |
+
# =======================
|
| 47 |
+
# VECTOR DB / INDEXING
|
| 48 |
+
# =======================
|
| 49 |
+
"faiss-cpu>=1.13.0",
|
| 50 |
+
"chromadb>=0.4.0",
|
| 51 |
+
"sentence-transformers>=5.1.2",
|
| 52 |
+
"pymupdf",
|
| 53 |
+
"pypdf>=6.3.0",
|
| 54 |
+
"pypdf2>=3.0.1",
|
| 55 |
+
"arxiv>=2.3.1",
|
| 56 |
+
"wikipedia>=1.4.0",
|
| 57 |
+
|
| 58 |
+
# =======================
|
| 59 |
+
# AUTOGEN
|
| 60 |
+
# =======================
|
| 61 |
+
"autogen-agentchat==0.4.7",
|
| 62 |
+
"autogen-ext[grpc,mcp,ollama,openai]==0.4.7",
|
| 63 |
+
"asyncio",
|
| 64 |
+
"phidata>=2.0.0",
|
| 65 |
+
|
| 66 |
+
# =======================
|
| 67 |
+
# MCP
|
| 68 |
+
# =======================
|
| 69 |
+
"mcp-server-fetch>=2025.1.17",
|
| 70 |
+
"mcp[cli]>=1.21.2",
|
| 71 |
+
|
| 72 |
+
# =======================
|
| 73 |
+
# NETWORKING / UTILITIES
|
| 74 |
+
# =======================
|
| 75 |
+
"psutil>=7.0.0",
|
| 76 |
+
"python-dotenv>=1.0.1",
|
| 77 |
+
"requests>=2.32.3",
|
| 78 |
+
"aiohttp>=3.8.5",
|
| 79 |
+
"httpx>=0.28.1",
|
| 80 |
+
"speedtest-cli>=2.1.3",
|
| 81 |
+
"logfire",
|
| 82 |
+
"google-search-results",
|
| 83 |
+
"smithery>=0.4.4",
|
| 84 |
+
"sendgrid",
|
| 85 |
+
|
| 86 |
+
# =======================
|
| 87 |
+
# WEB SCRAPING
|
| 88 |
+
# =======================
|
| 89 |
+
"playwright>=1.51.0",
|
| 90 |
+
"beautifulsoup4>=4.12.3",
|
| 91 |
+
"lxml>=5.3.1",
|
| 92 |
+
|
| 93 |
+
# =======================
|
| 94 |
+
# FINANCE / NLP
|
| 95 |
+
# =======================
|
| 96 |
+
"yfinance>=0.2.66",
|
| 97 |
+
"textblob>=0.17.1",
|
| 98 |
+
"polygon-api-client>=1.16.3",
|
| 99 |
+
|
| 100 |
+
# =======================
|
| 101 |
+
# VISUAL / UI / PDF
|
| 102 |
+
# =======================
|
| 103 |
+
"plotly>=6.5.0",
|
| 104 |
+
"streamlit>=1.51.0",
|
| 105 |
+
"reportlab>=4.4.5",
|
| 106 |
+
"fastapi",
|
| 107 |
+
"Pillow",
|
| 108 |
+
"python-docx",
|
| 109 |
+
"matplotlib",
|
| 110 |
+
"fpdf",
|
| 111 |
+
"extra-streamlit-components",
|
| 112 |
+
"nest_asyncio",
|
| 113 |
+
|
| 114 |
+
# =======================
|
| 115 |
+
# AUDIO / VIDEO
|
| 116 |
+
# =======================
|
| 117 |
+
"yt_dlp>=2025.11.12",
|
| 118 |
+
"openai-whisper==20240930",
|
| 119 |
+
"numba==0.59.0",
|
| 120 |
+
"llvmlite==0.42.0",
|
| 121 |
+
|
| 122 |
+
# =======================
|
| 123 |
+
# MACHINE LEARNING
|
| 124 |
+
# =======================
|
| 125 |
+
"scikit-learn>=1.7.2",
|
| 126 |
+
"huggingface_hub<=1.3.2",
|
| 127 |
+
"datasets>=4.4.1",
|
| 128 |
+
|
| 129 |
+
# =======================
|
| 130 |
+
# IPYNB SUPPORT
|
| 131 |
+
# =======================
|
| 132 |
+
"ipykernel>=7.1.0",
|
| 133 |
+
|
| 134 |
+
# =======================
|
| 135 |
+
# TOOLS
|
| 136 |
+
# =======================
|
| 137 |
+
"ddgs>=9.9.2",
|
| 138 |
+
"duckduckgo_search",
|
| 139 |
+
"azure-identity>=1.25.1",
|
| 140 |
+
"azure-mgmt-resource>=23.0.1",
|
| 141 |
+
"azure-mgmt-compute>=30.3.0",
|
| 142 |
+
"azure-mgmt-monitor>=6.0.2",
|
| 143 |
+
"azure-monitor-query>=1.2.0",
|
| 144 |
+
"PyGithub>=2.1.1",
|
| 145 |
+
|
| 146 |
+
# =======================
|
| 147 |
+
# OBSERVABILITY
|
| 148 |
+
# =======================
|
| 149 |
+
"openinference-instrumentation-autogen>=0.1.0",
|
| 150 |
+
"openinference-instrumentation-openai>=0.1.15",
|
| 151 |
+
"opentelemetry-sdk>=1.20.0",
|
| 152 |
+
"opentelemetry-exporter-otlp>=1.20.0",
|
| 153 |
+
"opentelemetry-api>=1.20.0",
|
| 154 |
+
|
| 155 |
+
# =======================
|
| 156 |
+
# Google Authentication
|
| 157 |
+
# =======================
|
| 158 |
+
"google-auth>=2.22.0",
|
| 159 |
+
"google-auth-oauthlib>=0.4.6",
|
| 160 |
+
"google-auth-httplib2>=0.1.0",
|
| 161 |
+
"autoflake>=1.5.0",
|
| 162 |
+
|
| 163 |
+
]
|
| 164 |
+
|
| 165 |
+
[dependency-groups]
|
| 166 |
+
dev = [
|
| 167 |
+
"pytest>=8.3.3",
|
| 168 |
+
"ipykernel>=7.1.0",
|
| 169 |
+
"pytest-asyncio",
|
| 170 |
+
]
|
| 171 |
+
|
| 172 |
+
# ============================================================
|
| 173 |
+
# BUILD SYSTEM
|
| 174 |
+
# ============================================================
|
| 175 |
+
# Defines how to build the project.
|
| 176 |
+
# We use setuptools as the build backend, ensuring consistent packaging.
|
| 177 |
+
[build-system]
|
| 178 |
+
requires = ["setuptools>=80.9.0"]
|
| 179 |
+
build-backend = "setuptools.build_meta"
|
| 180 |
+
|
| 181 |
+
# ============================================================
|
| 182 |
+
# PACKAGING & DISCOVERY
|
| 183 |
+
# ============================================================
|
| 184 |
+
# Tells setuptools where to find the source code.
|
| 185 |
+
# This makes 'common' and 'src' importable when installed (pip install -e .).
|
| 186 |
+
[tool.setuptools.packages.find]
|
| 187 |
+
where = ["."] # Look in the project root
|
| 188 |
+
include = ["common*", "src*"] # Treat 'common' and 'src' folders as packages
|
| 189 |
+
|
| 190 |
+
|
| 191 |
+
# ============================================================
|
| 192 |
+
# PYTEST SETTINGS
|
| 193 |
+
# ============================================================
|
| 194 |
+
# Configures the test runner to automatically find code.
|
| 195 |
+
[tool.pytest.ini_options]
|
| 196 |
+
# Adds 'src' and 'common' to the python path during tests.
|
| 197 |
+
# This allows tests to import modules (e.g., 'import travel_agent')
|
| 198 |
+
# just like the apps do locally, preventing ModuleNotFoundError.
|
| 199 |
+
pythonpath = ["src", "common"]
|
| 200 |
+
testpaths = ["tests"] # Only look for tests in the 'tests' directory
|
| 201 |
+
addopts = "-q" # Run in quiet mode (less verbose output)
|
src/mcp-github/Dockerfile
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
FROM python:3.12-slim
|
| 3 |
+
|
| 4 |
+
WORKDIR /app
|
| 5 |
+
|
| 6 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 7 |
+
git \
|
| 8 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 9 |
+
|
| 10 |
+
COPY pyproject.toml .
|
| 11 |
+
RUN pip install --no-cache-dir .
|
| 12 |
+
|
| 13 |
+
COPY src/mcp-github ./src/mcp-github
|
| 14 |
+
|
| 15 |
+
ENV PYTHONPATH=/app/src
|
| 16 |
+
|
| 17 |
+
EXPOSE 7860
|
| 18 |
+
|
| 19 |
+
CMD ["python", "src/mcp-github/server.py", "--transport", "sse", "--port", "7860", "--host", "0.0.0.0"]
|
src/mcp-github/README.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
---
|
| 3 |
+
title: MCP GitHub
|
| 4 |
+
emoji: 🐙
|
| 5 |
+
colorFrom: gray
|
| 6 |
+
colorTo: yellow
|
| 7 |
+
sdk: docker
|
| 8 |
+
pinned: false
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
# MCP GitHub Server
|
| 12 |
+
|
| 13 |
+
This is a Model Context Protocol (MCP) server for GitHub repository management and automation.
|
| 14 |
+
|
| 15 |
+
## Tools
|
| 16 |
+
- `list_issues`: List repository issues.
|
| 17 |
+
- `create_issue`: Create a new issue.
|
| 18 |
+
- `get_issue`: Get detailed issue info.
|
| 19 |
+
- `create_pull_request`: Create a new PR.
|
| 20 |
+
- `list_security_alerts`: Check for security alerts.
|
| 21 |
+
|
| 22 |
+
## Configuration
|
| 23 |
+
Requires `GITHUB_TOKEN` secret in Hugging Face Space settings.
|
| 24 |
+
|
| 25 |
+
## Running Locally
|
| 26 |
+
```bash
|
| 27 |
+
python src/mcp-github/server.py
|
| 28 |
+
```
|
src/mcp-github/server.py
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
"""
|
| 3 |
+
GitHub MCP Server
|
| 4 |
+
"""
|
| 5 |
+
import sys
|
| 6 |
+
import os
|
| 7 |
+
from mcp.server.fastmcp import FastMCP
|
| 8 |
+
from typing import List, Dict, Any, Optional
|
| 9 |
+
|
| 10 |
+
# Add src to pythonpath
|
| 11 |
+
current_dir = os.path.dirname(os.path.abspath(__file__))
|
| 12 |
+
src_dir = os.path.dirname(os.path.dirname(current_dir))
|
| 13 |
+
if src_dir not in sys.path:
|
| 14 |
+
sys.path.append(src_dir)
|
| 15 |
+
|
| 16 |
+
try:
|
| 17 |
+
from github import Github, Auth
|
| 18 |
+
from github.GithubException import GithubException
|
| 19 |
+
except ImportError:
|
| 20 |
+
Github = None
|
| 21 |
+
Auth = None
|
| 22 |
+
GithubException = Exception
|
| 23 |
+
|
| 24 |
+
# Initialize FastMCP Server
|
| 25 |
+
mcp = FastMCP("GitHub Operations")
|
| 26 |
+
|
| 27 |
+
def get_client():
|
| 28 |
+
token = os.environ.get("GITHUB_TOKEN")
|
| 29 |
+
if not token:
|
| 30 |
+
raise ValueError("GITHUB_TOKEN environment variable not set.")
|
| 31 |
+
if not Github:
|
| 32 |
+
raise ImportError("PyGithub not installed.")
|
| 33 |
+
auth = Auth.Token(token)
|
| 34 |
+
return Github(auth=auth)
|
| 35 |
+
|
| 36 |
+
@mcp.tool()
|
| 37 |
+
def list_issues(owner: str, repo_name: str, state: str = "open") -> List[Dict[str, Any]]:
|
| 38 |
+
"""
|
| 39 |
+
List issues for a repository.
|
| 40 |
+
"""
|
| 41 |
+
try:
|
| 42 |
+
g = get_client()
|
| 43 |
+
repo = g.get_repo(f"{owner}/{repo_name}")
|
| 44 |
+
issues = repo.get_issues(state=state)
|
| 45 |
+
|
| 46 |
+
results = []
|
| 47 |
+
for issue in issues[:10]: # Limit to 10 recent
|
| 48 |
+
results.append({
|
| 49 |
+
"number": issue.number,
|
| 50 |
+
"title": issue.title,
|
| 51 |
+
"state": issue.state,
|
| 52 |
+
"created_at": str(issue.created_at),
|
| 53 |
+
"user": issue.user.login
|
| 54 |
+
})
|
| 55 |
+
return results
|
| 56 |
+
except Exception as e:
|
| 57 |
+
return [{"error": str(e)}]
|
| 58 |
+
|
| 59 |
+
@mcp.tool()
|
| 60 |
+
def create_issue(owner: str, repo_name: str, title: str, body: str) -> Dict[str, Any]:
|
| 61 |
+
"""
|
| 62 |
+
Create a new issue.
|
| 63 |
+
"""
|
| 64 |
+
try:
|
| 65 |
+
g = get_client()
|
| 66 |
+
repo = g.get_repo(f"{owner}/{repo_name}")
|
| 67 |
+
issue = repo.create_issue(title=title, body=body)
|
| 68 |
+
return {
|
| 69 |
+
"number": issue.number,
|
| 70 |
+
"title": issue.title,
|
| 71 |
+
"url": issue.html_url
|
| 72 |
+
}
|
| 73 |
+
except Exception as e:
|
| 74 |
+
return {"error": str(e)}
|
| 75 |
+
|
| 76 |
+
@mcp.tool()
|
| 77 |
+
def get_issue(owner: str, repo_name: str, issue_number: int) -> Dict[str, Any]:
|
| 78 |
+
"""
|
| 79 |
+
Get detailed issue info including comments.
|
| 80 |
+
"""
|
| 81 |
+
try:
|
| 82 |
+
g = get_client()
|
| 83 |
+
repo = g.get_repo(f"{owner}/{repo_name}")
|
| 84 |
+
issue = repo.get_issue(issue_number)
|
| 85 |
+
|
| 86 |
+
comments = []
|
| 87 |
+
for c in issue.get_comments():
|
| 88 |
+
comments.append({
|
| 89 |
+
"user": c.user.login,
|
| 90 |
+
"body": c.body,
|
| 91 |
+
"created_at": str(c.created_at)
|
| 92 |
+
})
|
| 93 |
+
|
| 94 |
+
return {
|
| 95 |
+
"number": issue.number,
|
| 96 |
+
"title": issue.title,
|
| 97 |
+
"body": issue.body,
|
| 98 |
+
"state": issue.state,
|
| 99 |
+
"comments": comments
|
| 100 |
+
}
|
| 101 |
+
except Exception as e:
|
| 102 |
+
return {"error": str(e)}
|
| 103 |
+
|
| 104 |
+
@mcp.tool()
|
| 105 |
+
def list_security_alerts(owner: str, repo_name: str) -> List[Dict[str, Any]]:
|
| 106 |
+
"""
|
| 107 |
+
List dependabot alerts (if enabled and accessible).
|
| 108 |
+
"""
|
| 109 |
+
try:
|
| 110 |
+
g = get_client()
|
| 111 |
+
repo = g.get_repo(f"{owner}/{repo_name}")
|
| 112 |
+
|
| 113 |
+
# PyGithub support for alerts varies, using common method if available
|
| 114 |
+
# or manual requests otherwise. Assuming PyGithub >= 2.0 has some support.
|
| 115 |
+
# Often requires specific permissions.
|
| 116 |
+
try:
|
| 117 |
+
alerts = repo.get_dependabot_alerts()
|
| 118 |
+
results = []
|
| 119 |
+
for alert in alerts:
|
| 120 |
+
results.append({
|
| 121 |
+
"number": alert.number,
|
| 122 |
+
"package": alert.dependency.package.name,
|
| 123 |
+
"severity": alert.security_advisory.severity,
|
| 124 |
+
"state": alert.state,
|
| 125 |
+
"created_at": str(alert.created_at)
|
| 126 |
+
})
|
| 127 |
+
return results
|
| 128 |
+
except AttributeError:
|
| 129 |
+
return [{"error": "get_dependabot_alerts not supported by this PyGithub version"}]
|
| 130 |
+
|
| 131 |
+
except Exception as e:
|
| 132 |
+
return [{"error": str(e)}]
|
| 133 |
+
|
| 134 |
+
@mcp.tool()
|
| 135 |
+
def create_pull_request(owner: str, repo_name: str, title: str, body: str, head: str, base: str = "main") -> Dict[str, Any]:
|
| 136 |
+
"""
|
| 137 |
+
Create a new Pull Request.
|
| 138 |
+
"""
|
| 139 |
+
try:
|
| 140 |
+
g = get_client()
|
| 141 |
+
repo = g.get_repo(f"{owner}/{repo_name}")
|
| 142 |
+
pr = repo.create_pull(title=title, body=body, head=head, base=base)
|
| 143 |
+
return {
|
| 144 |
+
"number": pr.number,
|
| 145 |
+
"title": pr.title,
|
| 146 |
+
"url": pr.html_url,
|
| 147 |
+
"state": pr.state
|
| 148 |
+
}
|
| 149 |
+
except Exception as e:
|
| 150 |
+
return {"error": str(e)}
|
| 151 |
+
|
| 152 |
+
@mcp.tool()
|
| 153 |
+
def get_pull_request(owner: str, repo_name: str, pr_number: int) -> Dict[str, Any]:
|
| 154 |
+
"""
|
| 155 |
+
Get Pull Request details.
|
| 156 |
+
"""
|
| 157 |
+
try:
|
| 158 |
+
g = get_client()
|
| 159 |
+
repo = g.get_repo(f"{owner}/{repo_name}")
|
| 160 |
+
pr = repo.get_pull(pr_number)
|
| 161 |
+
return {
|
| 162 |
+
"number": pr.number,
|
| 163 |
+
"title": pr.title,
|
| 164 |
+
"body": pr.body,
|
| 165 |
+
"state": pr.state,
|
| 166 |
+
"merged": pr.merged,
|
| 167 |
+
"url": pr.html_url
|
| 168 |
+
}
|
| 169 |
+
except Exception as e:
|
| 170 |
+
return {"error": str(e)}
|
| 171 |
+
|
| 172 |
+
if __name__ == "__main__":
|
| 173 |
+
mcp.run()
|