Spaces:
Sleeping
Sleeping
Update mcp_server.py
Browse files- mcp_server.py +45 -48
mcp_server.py
CHANGED
|
@@ -1,48 +1,45 @@
|
|
| 1 |
-
"""MCP server exposing repo analysis and Q&A tools.
|
| 2 |
-
|
| 3 |
-
This allows any MCP-capable client (e.g., Claude Desktop, Cursor, Windsurf)
|
| 4 |
-
to reuse the same backend logic that powers the Gradio UI.
|
| 5 |
-
"""
|
| 6 |
-
|
| 7 |
-
from mcp.server.fastmcp import FastMCP
|
| 8 |
-
|
| 9 |
-
from agent import analyze_github_repo, qa_on_repo, fetch_youtube_transcript
|
| 10 |
-
|
| 11 |
-
server = FastMCP("github-doc-generator")
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
@server.tool()
|
| 15 |
-
def analyze_repository(repo_url: str) -> dict:
|
| 16 |
-
"""Clone and inspect a GitHub repository.
|
| 17 |
-
|
| 18 |
-
Returns the same payload as the Gradio analyzer, including documentation
|
| 19 |
-
status, structure, and extracted doc content. Errors are surfaced as a
|
| 20 |
-
dictionary with an ``error`` key.
|
| 21 |
-
"""
|
| 22 |
-
|
| 23 |
-
return analyze_github_repo(repo_url)
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
@server.tool()
|
| 27 |
-
def ask_repository_question(repo_url: str, question: str) -> str:
|
| 28 |
-
"""Answer a natural-language question about the given repository."""
|
| 29 |
-
|
| 30 |
-
return qa_on_repo(repo_url, question)
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
@server.tool()
|
| 34 |
-
def get_youtube_transcript(video_url: str, lang: str = "en") -> dict:
|
| 35 |
-
"""Fetch a YouTube video's transcript via the
|
| 36 |
-
|
| 37 |
-
This delegates to the shared `fetch_youtube_transcript` helper used by the
|
| 38 |
-
Gradio app
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
if __name__ == "__main__":
|
| 48 |
-
server.run()
|
|
|
|
| 1 |
+
"""MCP server exposing repo analysis and Q&A tools.
|
| 2 |
+
|
| 3 |
+
This allows any MCP-capable client (e.g., Claude Desktop, Cursor, Windsurf)
|
| 4 |
+
to reuse the same backend logic that powers the Gradio UI.
|
| 5 |
+
"""
|
| 6 |
+
|
| 7 |
+
from mcp.server.fastmcp import FastMCP
|
| 8 |
+
|
| 9 |
+
from agent import analyze_github_repo, qa_on_repo, fetch_youtube_transcript
|
| 10 |
+
|
| 11 |
+
server = FastMCP("github-doc-generator")
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
@server.tool()
|
| 15 |
+
def analyze_repository(repo_url: str) -> dict:
|
| 16 |
+
"""Clone and inspect a GitHub repository.
|
| 17 |
+
|
| 18 |
+
Returns the same payload as the Gradio analyzer, including documentation
|
| 19 |
+
status, structure, and extracted doc content. Errors are surfaced as a
|
| 20 |
+
dictionary with an ``error`` key.
|
| 21 |
+
"""
|
| 22 |
+
|
| 23 |
+
return analyze_github_repo(repo_url)
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
@server.tool()
|
| 27 |
+
def ask_repository_question(repo_url: str, question: str) -> str:
|
| 28 |
+
"""Answer a natural-language question about the given repository."""
|
| 29 |
+
|
| 30 |
+
return qa_on_repo(repo_url, question)
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
@server.tool()
|
| 34 |
+
def get_youtube_transcript(video_url: str, lang: str = "en") -> dict:
|
| 35 |
+
"""Fetch a YouTube video's transcript via the RapidAPI backend.
|
| 36 |
+
|
| 37 |
+
This delegates to the shared `fetch_youtube_transcript` helper used by the
|
| 38 |
+
Gradio app. The response includes a raw transcript string and metadata.
|
| 39 |
+
"""
|
| 40 |
+
|
| 41 |
+
return fetch_youtube_transcript(video_url, lang=lang)
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
if __name__ == "__main__":
|
| 45 |
+
server.run()
|
|
|
|
|
|
|
|
|