Skip to main content
Glama
jeannassereldine

MCP Weather Server

get_forecast

Retrieve weather forecast data for any location by providing its latitude and longitude coordinates.

Instructions

Get weather forecast for a location. Args: latitude: Latitude of the location longitude: Longitude of the location

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
latitudeYes
longitudeYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function that implements the logic for the 'get_forecast' tool. It uses hardcoded weather data for a specific location and formats it into a string using the format_forecast helper.
    def get_forecast(latitude: float, longitude: float) -> str:
       """Get weather forecast for a location.
       Args:
           latitude: Latitude of the location
           longitude: Longitude of the location
       """
    
       forecasts = [
       {
           "name": "This Afternoon",
           "temperature": "68°F",
           "wind": "18 mph WSW",
           "forecast": "Sunny. High near 68, with temperatures falling to around 66 in the afternoon. West southwest wind around 18 mph, with gusts as high as 23 mph."
       },
       {
           "name": "Tonight",
           "temperature": "55°F",
           "wind": "8 to 17 mph WSW",
           "forecast": "Mostly clear, with a low around 55. West southwest wind 8 to 17 mph, with gusts as high as 22 mph."
       },
      
       ]
         # Hardcode replace it with you api , you can call https://api.weather.gov ... 
       return format_forecast(forecasts)
  • The @mcp.tool() decorator registers the get_forecast function as an MCP tool within the register function.
    @mcp.tool()
    def get_forecast(latitude: float, longitude: float) -> str:
  • weather.py:2-7 (registration)
    Imports the get_forcast module containing the tool definitions and calls its register(mcp) function to register the tools, including get_forecast, with the MCP server instance.
    from tools import get_forcast
    # Initialize FastMCP server
    mcp = FastMCP("weather")
    
    
    get_forcast.register(mcp)
  • Helper function used by get_forecast to format the list of forecast dictionaries into a human-readable string.
    def format_forecast(forecasts: List[Dict]) -> str:
            """
            Format a list of forecast dictionaries into a readable string.
            """
            return "\n---\n".join(
                f"{f['name']}:\nTemperature: {f['temperature']}\nWind: {f['wind']}\nForecast: {f['forecast']}"
                for f in forecasts
            )
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It states what the tool does but doesn't describe important behavioral aspects: whether this is a read-only operation, what data format is returned, if there are rate limits, authentication requirements, or error conditions. The description is minimal and lacks operational context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately concise with a clear purpose statement followed by parameter documentation. The two-sentence structure is efficient with no wasted words. However, the 'Args:' formatting is slightly redundant since parameters are already documented in the schema, preventing a perfect score.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has an output schema (which handles return values) and simple parameters, the description is minimally adequate. However, for a weather forecasting tool with no annotations, users would benefit from more context about forecast type, time horizon, data sources, or common use cases. The description meets basic requirements but leaves important questions unanswered.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 0%, so the description must compensate. It explicitly lists both parameters (latitude, longitude) and their purpose ('of the location'), which adds value beyond the bare schema. However, it doesn't provide format details (e.g., decimal degrees), valid ranges, or examples. The baseline would be lower without this parameter listing.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with 'Get weather forecast for a location' - a specific verb ('Get') and resource ('weather forecast'). It distinguishes from the sibling tool 'get_coordinates' by focusing on forecast rather than location data. However, it doesn't specify what type of forecast (e.g., daily, hourly, current) or time range, keeping it from a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention the sibling tool 'get_coordinates' or suggest when one might be preferred over the other (e.g., use get_coordinates first to obtain coordinates, then get_forecast). There's no context about prerequisites or limitations.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/jeannassereldine/mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server