Spaces:
Paused
Paused
Update calculator_server.py
Browse files- calculator_server.py +2 -4
calculator_server.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
# calculator_server.py
|
| 2 |
-
from fastmcp import FastMCP
|
|
|
|
| 3 |
|
| 4 |
# 1. Create a FastMCP server instance
|
| 5 |
mcp = FastMCP(name="Calculator 🧮")
|
|
@@ -27,10 +28,7 @@ def divide(a: float, b: float) -> float:
|
|
| 27 |
return a / b
|
| 28 |
|
| 29 |
# 3. Add a main block to run the server
|
| 30 |
-
# For Hugging Face Spaces, it's best to run on host '0.0.0.0'
|
| 31 |
-
# and the port specified by the PORT environment variable (defaulting to 7860).
|
| 32 |
if __name__ == "__main__":
|
| 33 |
import os
|
| 34 |
-
# Get port from environment or default to 7860 for Hugging Face
|
| 35 |
port = int(os.environ.get("PORT", 7860))
|
| 36 |
mcp.run(transport="streamable-http", host="0.0.0.0", port=port)
|
|
|
|
| 1 |
# calculator_server.py
|
| 2 |
+
from fastmcp import FastMCP
|
| 3 |
+
from fastmcp.exceptions import ToolError
|
| 4 |
|
| 5 |
# 1. Create a FastMCP server instance
|
| 6 |
mcp = FastMCP(name="Calculator 🧮")
|
|
|
|
| 28 |
return a / b
|
| 29 |
|
| 30 |
# 3. Add a main block to run the server
|
|
|
|
|
|
|
| 31 |
if __name__ == "__main__":
|
| 32 |
import os
|
|
|
|
| 33 |
port = int(os.environ.get("PORT", 7860))
|
| 34 |
mcp.run(transport="streamable-http", host="0.0.0.0", port=port)
|