30 lines
593 B
Python
30 lines
593 B
Python
from mcp.server.fastmcp import FastMCP
|
|
from pydantic import BaseModel
|
|
|
|
|
|
class WeatherResult(BaseModel):
|
|
city: str
|
|
temperature: int
|
|
units: str
|
|
condition: str
|
|
|
|
|
|
server = FastMCP(name="weather")
|
|
|
|
|
|
@server.tool(
|
|
name="get_weather",
|
|
description="Возвращает актуальную погоду по городу",
|
|
)
|
|
async def get_weather(city: str, units: str = "metric") -> WeatherResult:
|
|
return WeatherResult(
|
|
city=city,
|
|
temperature=18,
|
|
units=units,
|
|
condition="partly cloudy",
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
server.run()
|