Skip to main content
Glama
hanweg

mcp-tool-builder

by hanweg

get_weather_forecast

Retrieve weather forecasts for any US ZIP code using National Weather Service data to plan activities and prepare for conditions.

Instructions

Retrieves weather forecast for a given ZIP code using NWS API

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
zip_codeYes

Implementation Reference

  • The main handler function for the get_weather_forecast tool. It takes a zip_code, uses geopy to get coordinates, fetches weather grid and forecast from NWS API, extracts next 4 periods' forecast, and returns location and forecast summary or error.
    def get_weather_forecast(zip_code):
        try:
            # Initialize geocoder
            geolocator = Nominatim(user_agent="weather_forecast_app")
            
            # Get location coordinates from ZIP code
            location = geolocator.geocode(zip_code)
            if not location:
                return {"error": "Unable to find coordinates for the given ZIP code"}
            
            # Get NWS grid point
            grid_url = f"https://api.weather.gov/points/{location.latitude},{location.longitude}"
            grid_response = requests.get(grid_url, headers={'User-Agent': 'WeatherApp/1.0'})
            grid_data = grid_response.json()
            
            if grid_response.status_code != 200:
                return {"error": "Unable to retrieve grid information"}
            
            # Get forecast
            forecast_url = grid_data['properties']['forecast']
            forecast_response = requests.get(forecast_url, headers={'User-Agent': 'WeatherApp/1.0'})
            forecast_data = forecast_response.json()
            
            if forecast_response.status_code != 200:
                return {"error": "Unable to retrieve forecast"}
            
            # Extract key forecast information
            periods = forecast_data['properties']['periods']
            forecast_summary = []
            for period in periods[:4]:  # First 4 periods
                forecast_summary.append({
                    "name": period['name'],
                    "temperature": f"{period['temperature']}°{period['temperatureUnit']}",
                    "short_forecast": period['shortForecast'],
                    "detailed_forecast": period['detailedForecast']
                })
            
            return {
                "location": f"{location.address}",
                "forecast": forecast_summary
            }
        
        except Exception as e:
            return {"error": f"An error occurred: {str(e)}"}
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions the data source ('NWS API'), which hints at external dependencies and potential rate limits or availability issues, but doesn't explicitly state these. It doesn't describe error handling, response format, or whether the operation is idempotent or has side effects, leaving significant gaps for a tool that interacts with an external API.

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

Conciseness5/5

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

The description is a single, well-structured sentence that efficiently conveys the core functionality without unnecessary words. It is front-loaded with the main action and resource, and every part of the sentence adds value (e.g., specifying the API source). There is no redundancy or fluff.

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

Completeness2/5

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

Given the lack of annotations and output schema, the description is incomplete for a tool that interacts with an external API. It doesn't explain what the forecast includes (e.g., temperature, precipitation), how the data is returned, or any error scenarios. For a tool with no structured support, more detail is needed to guide the agent effectively.

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 description specifies that the forecast is for a 'ZIP code', which clarifies the meaning of the zip_code parameter beyond the schema's generic string type. However, with 0% schema description coverage and only one parameter, the description adds some value but doesn't fully compensate for the lack of schema details (e.g., format constraints or validation rules). The baseline is 3 since the schema coverage is low but the parameter count is minimal.

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 action ('Retrieves weather forecast') and the resource ('for a given ZIP code'), with the specific data source ('using NWS API') adding useful context. It distinguishes itself from sibling tools like get_bitcoin_price by focusing on weather data rather than financial data. However, it doesn't explicitly differentiate from other potential weather-related tools that might exist in a broader context.

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 any prerequisites, limitations, or suggest other tools for related tasks (e.g., historical weather data or different location formats). The agent must infer usage solely from the tool name and description without explicit context.

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/hanweg/mcp-tool-builder'

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