init
This commit is contained in:
29
weather_mcp.py
Normal file
29
weather_mcp.py
Normal file
@@ -0,0 +1,29 @@
|
||||
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()
|
||||
Reference in New Issue
Block a user