get_weather
Retrieve current weather data for any specified city using this Python MCP server tool.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"city": "<city>"
},
"name": "get_weather"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| city | Yes |
Implementation Reference
- mcp_server.py:17-17 (registration)Decorator that registers the get_weather function as a tool in the MCP server.
@mcp.tool() - mcp_server.py:18-20 (handler)The main handler function implementing the get_weather tool logic by querying the wttr.in API for the specified city.
async def get_weather(city: str) -> str: response = httpx.get(f"https://wttr.in/{city}?format=3") return response.text - mcp_server.py:18-18 (schema)Type hints define the input schema (city: str) and output (str).
async def get_weather(city: str) -> str: