Skip to content

Server Structured Output Temperature example is outside of range of expectation (documentation only) #1327

@monkeywithacupcake

Description

@monkeywithacupcake

This is a documentation only issue.

In the examples/snippets/servers/structured_output.py, we have the following (extract from file):

class WeatherData(BaseModel):
    """Weather information structure."""

    temperature: float = Field(description="Temperature in Celsius")
    humidity: float = Field(description="Humidity percentage")
    condition: str
    wind_speed: float


@mcp.tool()
def get_weather(city: str) -> WeatherData:
    """Get weather for a city - returns structured data."""
    # Simulated weather data
    return WeatherData(
        temperature=72.5,
        humidity=45.0,
        condition="sunny",
        wind_speed=5.2,
    )

Note that the definition of temperature is in Celsius, but then the example values of returning structured data several lines later says 72.5. 72.5C is death hot - like 160 F.

This doesn't matter in any way for the project. However, for reading through what a structure is, the examples should probably make something that makes sense immediately. If the weather structure is for data on earth where humans live, and we say that the value is in Celsius, we should have example data that are reasonable for that result.

Recommend documentation change only this file either to change the description to 'Temperature in Fahrenheit' or to change the temperature returned to something less deadly, like 22.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions