Skip to main content
Glama

get_alerts

Retrieve weather alerts for any US state to monitor hazardous conditions and stay informed about local warnings.

Instructions

Get weather alerts for a US state.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
stateYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main handler function for the 'get_alerts' tool. It fetches active weather alerts for a given US state from the National Weather Service API, processes the response, formats each alert using the 'format_alert' helper, and returns a concatenated string of formatted alerts.
    async def get_alerts(state: str) -> str:
        """Get weather alerts for a US state."""
        url = f"{NWS_API_BASE}/alerts/active/area/{state}"
        data = await make_nws_request(url)
        if not data or "features" not in data:
            return "Unable to fetch alerts or no alerts found."
        if not data["features"]:
            return "No active alerts for this state."
        alerts = [format_alert(feature) for feature in data["features"]]
        return "\n---\n".join(alerts)
  • Registers the 'get_alerts' tool (along with 'get_forecast') using the MCP 'mcp.tool()' decorator within the register_weather_tools function.
    def register_weather_tools(mcp):
        """Register all weather tools with the MCP server."""
        mcp.tool()(get_alerts)
        mcp.tool()(get_forecast)
  • Helper function specifically used by 'get_alerts' to format individual alert features from the API response into a human-readable multi-line string.
    def format_alert(feature: dict) -> str:
        """Format an alert feature into a readable string."""
        props = feature["properties"]
        return f"""
    Event: {props.get('event', 'Unknown')}
    Area: {props.get('areaDesc', 'Unknown')}
    Severity: {props.get('severity', 'Unknown')}
    Description: {props.get('description', 'No description available')}
    Instructions: {props.get('instruction', 'No specific instructions provided')}
    """
  • Shared helper function used by 'get_alerts' (and 'get_forecast') to make asynchronous HTTP requests to the National Weather Service API with proper headers, timeout, and error handling.
    async def make_nws_request(url: str) -> dict[str, Any] | None:
        """Make a request to the NWS API with proper error handling."""
        headers = {
            "User-Agent": USER_AGENT,
            "Accept": "application/geo+json"
        }
        async with httpx.AsyncClient() as client:
            try:
                response = await client.get(url, headers=headers, timeout=30.0)
                response.raise_for_status()
                return response.json()
            except Exception:
                return None
Behavior2/5

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

With no annotations provided, the description carries full burden but only states what the tool does, not how it behaves. It doesn't disclose whether this is a read-only operation, potential rate limits, error conditions, authentication needs, or what the output contains beyond the implied alerts. This leaves significant behavioral gaps for an agent.

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, efficient sentence that front-loads the core purpose with zero wasted words. It's appropriately sized for a simple tool with one parameter and clear output schema.

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's low complexity (1 parameter, output schema exists), the description is minimally complete but lacks behavioral context. The output schema likely covers return values, so the description doesn't need to explain those, but it should address usage guidelines and transparency more thoroughly for better agent guidance.

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 adds minimal semantics by implying the 'state' parameter refers to a US state, but the schema already has a 'State' title with 0% coverage. Since there's only one parameter and the description provides some context (US state), it meets the baseline for adequate but not detailed parameter explanation.

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 verb ('Get') and resource ('weather alerts') with geographic scope ('for a US state'), making the purpose immediately understandable. It doesn't distinguish from siblings like 'get_forecast' which suggests different weather data, but the core functionality is well-defined.

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?

No guidance is provided on when to use this tool versus alternatives like 'get_forecast' or other siblings. The description implies usage for weather alerts specifically, but lacks explicit context, prerequisites, or exclusions that would help an agent choose appropriately.

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/webdevtodayjason/slim-MCP'

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