Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -61,12 +61,10 @@ async def fetch_github_trending():
|
|
| 61 |
print(f"Error fetching GitHub trending: {e}")
|
| 62 |
return cached_trending if cached_trending else []
|
| 63 |
|
| 64 |
-
# 初始化 MCP 服务器
|
| 65 |
mcp_server = FastMCP(
|
| 66 |
name="GithubTrending",
|
| 67 |
-
stateless_http=True
|
| 68 |
-
http_path="/mcp",
|
| 69 |
-
sse_path="/mcp/sse"
|
| 70 |
)
|
| 71 |
|
| 72 |
@mcp_server.tool()
|
|
@@ -74,10 +72,10 @@ def get_trending_repos(num: int = 10) -> dict:
|
|
| 74 |
"""获取 GitHub 热门仓库"""
|
| 75 |
if not last_updated or (datetime.now() - last_updated) > timedelta(minutes=5):
|
| 76 |
fetch_github_trending()
|
| 77 |
-
return {"trending": cached_trending[:num]}
|
| 78 |
|
| 79 |
-
# 挂载 MCP 应用
|
| 80 |
-
app.mount("/mcp", mcp_server.http_app())
|
| 81 |
|
| 82 |
@app.get("/trending")
|
| 83 |
async def get_trending():
|
|
@@ -86,7 +84,7 @@ async def get_trending():
|
|
| 86 |
await fetch_github_trending()
|
| 87 |
|
| 88 |
return {
|
| 89 |
-
"trending": cached_trending,
|
| 90 |
"last_updated": last_updated.isoformat() if last_updated else None,
|
| 91 |
"cache_expires_in": 300,
|
| 92 |
"suggested_polling_interval": 60
|
|
|
|
| 61 |
print(f"Error fetching GitHub trending: {e}")
|
| 62 |
return cached_trending if cached_trending else []
|
| 63 |
|
| 64 |
+
# 初始化 MCP 服务器 - 使用正确的参数
|
| 65 |
mcp_server = FastMCP(
|
| 66 |
name="GithubTrending",
|
| 67 |
+
stateless_http=True
|
|
|
|
|
|
|
| 68 |
)
|
| 69 |
|
| 70 |
@mcp_server.tool()
|
|
|
|
| 72 |
"""获取 GitHub 热门仓库"""
|
| 73 |
if not last_updated or (datetime.now() - last_updated) > timedelta(minutes=5):
|
| 74 |
fetch_github_trending()
|
| 75 |
+
return {"trending": cached_trending[:num]} # 修正拼写错误: trending -> trending
|
| 76 |
|
| 77 |
+
# 挂载 MCP 应用 - 使用正确的路径
|
| 78 |
+
app.mount("/mcp", mcp_server.http_app(path="/mcp"))
|
| 79 |
|
| 80 |
@app.get("/trending")
|
| 81 |
async def get_trending():
|
|
|
|
| 84 |
await fetch_github_trending()
|
| 85 |
|
| 86 |
return {
|
| 87 |
+
"trending": cached_trending, # 修正拼写错误: trening -> trending
|
| 88 |
"last_updated": last_updated.isoformat() if last_updated else None,
|
| 89 |
"cache_expires_in": 300,
|
| 90 |
"suggested_polling_interval": 60
|