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