Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,6 +3,11 @@ from __future__ import annotations
|
|
| 3 |
|
| 4 |
from typing import Any, Dict, List, Optional
|
| 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
from mcp.server.fastmcp import FastMCP
|
| 7 |
|
| 8 |
from github_client import GitHubAPIError, GitHubClient
|
|
@@ -837,25 +842,16 @@ async def search_repos(query: str, sort: Optional[str] = None, order: str = "des
|
|
| 837 |
data = await _client.search_repositories(query, sort, order, limit)
|
| 838 |
return [_summarize_repo(repo) for repo in data]
|
| 839 |
|
| 840 |
-
|
| 841 |
-
fastapi_app = server.asgi.app # underlying FastAPI app
|
| 842 |
-
except AttributeError:
|
| 843 |
-
raise RuntimeError("Your FastMCP version does not expose server.asgi.app")
|
| 844 |
|
| 845 |
-
|
|
|
|
| 846 |
def health():
|
| 847 |
return {"status": "ok"}
|
| 848 |
|
|
|
|
|
|
|
| 849 |
|
| 850 |
if __name__ == "__main__":
|
| 851 |
-
import os
|
| 852 |
-
import uvicorn
|
| 853 |
-
|
| 854 |
port = int(os.getenv("PORT", 8000))
|
| 855 |
-
|
| 856 |
-
uvicorn.run(
|
| 857 |
-
server.asgi, # ASGI app to run
|
| 858 |
-
host="0.0.0.0",
|
| 859 |
-
port=port,
|
| 860 |
-
log_level="info",
|
| 861 |
-
)
|
|
|
|
| 3 |
|
| 4 |
from typing import Any, Dict, List, Optional
|
| 5 |
|
| 6 |
+
import os
|
| 7 |
+
|
| 8 |
+
from fastapi import FastAPI
|
| 9 |
+
import uvicorn
|
| 10 |
+
|
| 11 |
from mcp.server.fastmcp import FastMCP
|
| 12 |
|
| 13 |
from github_client import GitHubAPIError, GitHubClient
|
|
|
|
| 842 |
data = await _client.search_repositories(query, sort, order, limit)
|
| 843 |
return [_summarize_repo(repo) for repo in data]
|
| 844 |
|
| 845 |
+
app = FastAPI()
|
|
|
|
|
|
|
|
|
|
| 846 |
|
| 847 |
+
# Health endpoint for HF Spaces
|
| 848 |
+
@app.get("/")
|
| 849 |
def health():
|
| 850 |
return {"status": "ok"}
|
| 851 |
|
| 852 |
+
# Mount MCP server under /mcp
|
| 853 |
+
app.mount("/mcp", server.create_http_router())
|
| 854 |
|
| 855 |
if __name__ == "__main__":
|
|
|
|
|
|
|
|
|
|
| 856 |
port = int(os.getenv("PORT", 8000))
|
| 857 |
+
uvicorn.run(app, host="0.0.0.0", port=port, log_level="info")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|