Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -65,17 +65,29 @@ async def get_trending_repos(num: int = 10) -> dict:
|
|
| 65 |
await fetch_github_trending()
|
| 66 |
return {"trending": cached_trending[:num]}
|
| 67 |
|
| 68 |
-
#
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
|
| 73 |
@app.get("/")
|
| 74 |
async def root():
|
|
|
|
| 75 |
return {
|
| 76 |
"message": "API is running",
|
| 77 |
"endpoints": {
|
| 78 |
-
"
|
|
|
|
|
|
|
| 79 |
"trending": "/trending"
|
| 80 |
}
|
| 81 |
}
|
|
|
|
| 65 |
await fetch_github_trending()
|
| 66 |
return {"trending": cached_trending[:num]}
|
| 67 |
|
| 68 |
+
# 关键修改:正确挂载MCP路由
|
| 69 |
+
# 方案1:直接挂载整个MCP应用
|
| 70 |
+
app.mount("/mcp", mcp_server.http_app())
|
| 71 |
+
|
| 72 |
+
# 方案2:或者使用APIRouter(如果方案1不行)
|
| 73 |
+
# mcp_router = APIRouter()
|
| 74 |
+
# mcp_router.include_router(mcp_server.http_app().router, prefix="")
|
| 75 |
+
# app.include_router(mcp_router, prefix="/mcp")
|
| 76 |
+
|
| 77 |
+
# 添加MCP健康检查路由
|
| 78 |
+
@app.get("/mcp/health")
|
| 79 |
+
async def mcp_health_check():
|
| 80 |
+
return {"status": "ok", "mcp_version": "1.0"}
|
| 81 |
|
| 82 |
@app.get("/")
|
| 83 |
async def root():
|
| 84 |
+
# 添加更多有用的调试信息
|
| 85 |
return {
|
| 86 |
"message": "API is running",
|
| 87 |
"endpoints": {
|
| 88 |
+
"mcp_tool": "/mcp/tool/get_trending_repos",
|
| 89 |
+
"mcp_schema": "/mcp/schema",
|
| 90 |
+
"mcp_health": "/mcp/health",
|
| 91 |
"trending": "/trending"
|
| 92 |
}
|
| 93 |
}
|