Spaces:
Sleeping
Sleeping
Update server.py
Browse files
server.py
CHANGED
|
@@ -3,6 +3,8 @@ import logging
|
|
| 3 |
import sys
|
| 4 |
from pathlib import Path
|
| 5 |
import os
|
|
|
|
|
|
|
| 6 |
# Must set this BEFORE importing FastMCP
|
| 7 |
os.environ["MCP_ALLOW_HTTP"] = "1"
|
| 8 |
|
|
@@ -81,10 +83,10 @@ async def generate_quiz(chapter_name: str, difficulty: str = "medium") -> str:
|
|
| 81 |
# # mcp.run(transport="sse") and set env vars MCP_HOST and MCP_PORT
|
| 82 |
|
| 83 |
if __name__ == "__main__":
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
)
|
|
|
|
| 3 |
import sys
|
| 4 |
from pathlib import Path
|
| 5 |
import os
|
| 6 |
+
import uvicorn
|
| 7 |
+
|
| 8 |
# Must set this BEFORE importing FastMCP
|
| 9 |
os.environ["MCP_ALLOW_HTTP"] = "1"
|
| 10 |
|
|
|
|
| 83 |
# # mcp.run(transport="sse") and set env vars MCP_HOST and MCP_PORT
|
| 84 |
|
| 85 |
if __name__ == "__main__":
|
| 86 |
+
port = int(os.getenv("PORT", 7860))
|
| 87 |
+
host = "0.0.0.0"
|
| 88 |
+
|
| 89 |
+
logger.info(f"Starting MCP Server via SSE on {host}:{port}")
|
| 90 |
+
|
| 91 |
+
# We use the 'starlette_app' property of FastMCP to run via uvicorn
|
| 92 |
+
uvicorn.run(mcp.starlette_app, host=host, port=port)
|