get_weather
Retrieve real-time weather data for a specified location with customizable temperature units using this HTTP-based utility on the Simple HTTP MCP Server.
Instructions
Get the current weather in a given location.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| location | Yes | The location to get the weather for | |
| unit | No | The unit of temperature | celsius |
Implementation Reference
- tests/app/tools.py:25-30 (handler)The main handler function that implements the logic for the 'get_weather' tool, which simulates returning weather data for a given location and unit.async def get_weather(args: Arguments[GetWeatherInput]) -> GetWeatherOutput: """Get the current weather in a given location.""" args.get_state_key("context", Context).add_called_tool("get_weather") return GetWeatherOutput( weather=f"The weather in {args.inputs.location} is 25 degrees {args.inputs.unit}", )
- tests/app/tools.py:12-14 (schema)Pydantic input schema for the 'get_weather' tool defining location and unit parameters.class GetWeatherInput(BaseModel): location: str = Field(description="The location to get the weather for") unit: str = Field(description="The unit of temperature", default="celsius")
- tests/app/tools.py:17-19 (schema)Pydantic output schema for the 'get_weather' tool defining the weather response.class GetWeatherOutput(BaseModel): weather: str = Field(description="The weather in the given location")
- tests/app/tools.py:98-102 (registration)Registration of the 'get_weather' tool in the TOOLS tuple using the Tool constructor with handler, input schema, and output schema.func=get_weather, inputs=GetWeatherInput, output=GetWeatherOutput, ), Tool(