Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,27 @@
|
|
1 |
-
|
|
|
2 |
|
3 |
-
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import httpx
|
2 |
+
from mcp.server.fastmcp import FastMCP
|
3 |
|
4 |
+
mcp = FastMCP("My App")
|
5 |
|
6 |
+
|
7 |
+
@mcp.tool()
|
8 |
+
def calculate_bmi(weight_kg: float, height_m: float) -> float:
|
9 |
+
"""Calculate BMI given weight in kg and height in meters"""
|
10 |
+
return weight_kg / (height_m**2)
|
11 |
+
|
12 |
+
|
13 |
+
@mcp.tool()
|
14 |
+
async def fetch_weather(city: str) -> str:
|
15 |
+
"""Fetch current weather for a city"""
|
16 |
+
async with httpx.AsyncClient() as client:
|
17 |
+
response = await client.get(f"https://api.weather.com/{city}")
|
18 |
+
return response.text
|
19 |
+
|
20 |
+
|
21 |
+
#from fastapi import FastAPI
|
22 |
+
#
|
23 |
+
#app = FastAPI()
|
24 |
+
#
|
25 |
+
#@app.get("/")
|
26 |
+
#def greet_json():
|
27 |
+
# return {"Hello": "World!"}
|