albertvillanova HF Staff commited on
Commit
163e93e
·
verified ·
1 Parent(s): 4b430f2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -5
app.py CHANGED
@@ -1,7 +1,27 @@
1
- from fastapi import FastAPI
 
2
 
3
- app = FastAPI()
4
 
5
- @app.get("/")
6
- def greet_json():
7
- return {"Hello": "World!"}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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!"}