Commit Β·
f54375b
1
Parent(s): a9142dd
refactor: simplify Gradio interface creation for GitHub MCP Server
Browse files
app.py
CHANGED
|
@@ -1,8 +1,3 @@
|
|
| 1 |
-
"""
|
| 2 |
-
GitHub MCP Server with Gradio Interface
|
| 3 |
-
Provides GitHub repository scanning and file content access via MCP
|
| 4 |
-
"""
|
| 5 |
-
|
| 6 |
import json
|
| 7 |
import os
|
| 8 |
import base64
|
|
@@ -144,68 +139,52 @@ class GitHubMCPServer:
|
|
| 144 |
# Initialize the GitHub MCP server
|
| 145 |
github_server = GitHubMCPServer()
|
| 146 |
|
| 147 |
-
# Create Gradio
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
value=".py,.js,.ts,.php,.java",
|
| 194 |
-
placeholder=".py,.js,.ts,.php,.java"
|
| 195 |
-
)
|
| 196 |
-
|
| 197 |
-
scan_btn = gr.Button("Scan Repository", variant="primary")
|
| 198 |
-
scan_output = gr.Textbox(label="Scan Results", lines=20)
|
| 199 |
-
|
| 200 |
-
scan_btn.click(
|
| 201 |
-
fn=github_server.scan_repository,
|
| 202 |
-
inputs=[scan_owner, scan_repo, scan_extensions],
|
| 203 |
-
outputs=scan_output
|
| 204 |
-
)
|
| 205 |
-
|
| 206 |
-
gr.Markdown("---")
|
| 207 |
-
gr.Markdown("π‘ **Setup**: Add your `GITHUB_TOKEN` to environment variables or `.env` file")
|
| 208 |
-
gr.Markdown("π **Deploy**: This server can be deployed on Hugging Face Spaces with MCP support")
|
| 209 |
|
| 210 |
if __name__ == "__main__":
|
| 211 |
print("π Starting GitHub MCP Server with Gradio...")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import json
|
| 2 |
import os
|
| 3 |
import base64
|
|
|
|
| 139 |
# Initialize the GitHub MCP server
|
| 140 |
github_server = GitHubMCPServer()
|
| 141 |
|
| 142 |
+
# Create Gradio interfaces for MCP
|
| 143 |
+
demo = gr.TabbedInterface(
|
| 144 |
+
[
|
| 145 |
+
gr.Interface(
|
| 146 |
+
fn=github_server.get_repository_info,
|
| 147 |
+
inputs=[
|
| 148 |
+
gr.Textbox(label="Repository Owner", placeholder="octocat"),
|
| 149 |
+
gr.Textbox(label="Repository Name", placeholder="Hello-World")
|
| 150 |
+
],
|
| 151 |
+
outputs=gr.Textbox(label="Repository Information", lines=15),
|
| 152 |
+
title="Get Repository Information",
|
| 153 |
+
description="Get basic information about a GitHub repository",
|
| 154 |
+
api_name="get_repository_info"
|
| 155 |
+
),
|
| 156 |
+
gr.Interface(
|
| 157 |
+
fn=github_server.get_file_content,
|
| 158 |
+
inputs=[
|
| 159 |
+
gr.Textbox(label="Repository Owner", placeholder="octocat"),
|
| 160 |
+
gr.Textbox(label="Repository Name", placeholder="Hello-World"),
|
| 161 |
+
gr.Textbox(label="File Path", placeholder="README.md")
|
| 162 |
+
],
|
| 163 |
+
outputs=gr.Textbox(label="File Content", lines=20),
|
| 164 |
+
title="Get File Content",
|
| 165 |
+
description="Get the content of a specific file from a GitHub repository",
|
| 166 |
+
api_name="get_file_content"
|
| 167 |
+
),
|
| 168 |
+
gr.Interface(
|
| 169 |
+
fn=github_server.scan_repository,
|
| 170 |
+
inputs=[
|
| 171 |
+
gr.Textbox(label="Repository Owner", placeholder="octocat"),
|
| 172 |
+
gr.Textbox(label="Repository Name", placeholder="Hello-World"),
|
| 173 |
+
gr.Textbox(label="File Extensions", value=".py,.js,.ts,.php,.java", placeholder=".py,.js,.ts,.php,.java")
|
| 174 |
+
],
|
| 175 |
+
outputs=gr.Textbox(label="Scan Results", lines=20),
|
| 176 |
+
title="Scan Repository for Code Files",
|
| 177 |
+
description="Scan a GitHub repository for code files with specified extensions",
|
| 178 |
+
api_name="scan_repository"
|
| 179 |
+
)
|
| 180 |
+
],
|
| 181 |
+
[
|
| 182 |
+
"Repository Info",
|
| 183 |
+
"File Content",
|
| 184 |
+
"Repository Scanner"
|
| 185 |
+
],
|
| 186 |
+
title="π GitHub MCP Server"
|
| 187 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 188 |
|
| 189 |
if __name__ == "__main__":
|
| 190 |
print("π Starting GitHub MCP Server with Gradio...")
|