Spaces:
Runtime error
Runtime error
Upload mcp_server_fastmcp.py
Browse files- mcp_server_fastmcp.py +13 -8
mcp_server_fastmcp.py
CHANGED
|
@@ -200,16 +200,21 @@ def advanced_search_company(company_input: str) -> dict:
|
|
| 200 |
# For production deployment
|
| 201 |
if __name__ == "__main__":
|
| 202 |
import os
|
| 203 |
-
import uvicorn
|
| 204 |
|
| 205 |
-
#
|
| 206 |
port = int(os.getenv("PORT", "7860"))
|
| 207 |
host = os.getenv("HOST", "0.0.0.0")
|
| 208 |
|
| 209 |
-
#
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 214 |
|
| 215 |
-
|
|
|
|
|
|
| 200 |
# For production deployment
|
| 201 |
if __name__ == "__main__":
|
| 202 |
import os
|
|
|
|
| 203 |
|
| 204 |
+
# Set port from environment (HF Space sets PORT=7860)
|
| 205 |
port = int(os.getenv("PORT", "7860"))
|
| 206 |
host = os.getenv("HOST", "0.0.0.0")
|
| 207 |
|
| 208 |
+
# Monkeypatch uvicorn.Config to use our port
|
| 209 |
+
import uvicorn
|
| 210 |
+
original_config_init = uvicorn.Config.__init__
|
| 211 |
+
|
| 212 |
+
def patched_init(self, *args, **kwargs):
|
| 213 |
+
kwargs['host'] = host
|
| 214 |
+
kwargs['port'] = port
|
| 215 |
+
return original_config_init(self, *args, **kwargs)
|
| 216 |
+
|
| 217 |
+
uvicorn.Config.__init__ = patched_init
|
| 218 |
|
| 219 |
+
# Run FastMCP with SSE transport (it will use our patched config)
|
| 220 |
+
mcp.run(transport="sse")
|