Skip to main content
Glama
agentventure

Weather MCP Server

by agentventure

get_alerts

Retrieve active weather alerts for any US state using the National Weather Service API to monitor severe conditions and stay informed.

Instructions

Get weather alerts for a US state.

Args:
    state: Two-letter US state code (e.g. CA, NY)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
stateYes

Implementation Reference

  • Main handler function for the 'get_alerts' tool. Registered via @mcp.tool() decorator. Takes a US state code, fetches active alerts from NWS API, handles errors, formats output using helper functions.
    @mcp.tool()
    async def get_alerts(state: str) -> str:
        """Get weather alerts for a US state.
    
        Args:
            state: Two-letter US state code (e.g. CA, NY)
        """
        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)
  • Helper function to make HTTP requests to NWS API with headers, timeout, and error handling. Used by get_alerts.
    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
  • Helper function to format a single alert feature into a human-readable string. Used in get_alerts for each alert.
    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')}
    """
  • weather.py:37-37 (registration)
    Registration of the get_alerts tool via the FastMCP @tool decorator.
    @mcp.tool()
  • Input schema defined in the tool's docstring: parameter 'state' as two-letter US state code.
    """Get weather alerts for a US state.
    
    Args:
        state: Two-letter US state code (e.g. CA, NY)
    """
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 that alerts are for a 'US state,' implying geographic limitations, but doesn't describe other behaviors such as error handling, rate limits, authentication needs, or what the return format looks like (e.g., list of alerts, timestamps, severity). For a tool with no annotations, this leaves significant gaps.

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 front-loaded with the core purpose in the first sentence, followed by a concise parameter explanation. Every sentence adds value without redundancy, and the structure is clear and efficient, making it easy for an agent to parse quickly.

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 (one parameter, no annotations, no output schema), the description is minimally adequate. It covers the basic purpose and parameter format but lacks details on behavioral traits, error handling, and output structure. Without annotations or an output schema, more context would improve completeness for reliable agent use.

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

Parameters4/5

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

The description adds meaningful context for the single parameter 'state' by specifying it as a 'Two-letter US state code (e.g. CA, NY),' which clarifies the expected format beyond the schema's basic 'string' type. With 0% schema description coverage and only one parameter, this adequately compensates, though it doesn't cover edge cases like invalid codes.

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: 'Get weather alerts for a US state.' It specifies the verb ('Get') and resource ('weather alerts') with geographic scope ('US state'). However, it doesn't explicitly differentiate from its sibling tool 'get_forecast' beyond the resource type, which prevents 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 like 'get_forecast.' It states what the tool does but offers no context about appropriate use cases, prerequisites, or exclusions. The agent must infer usage from the tool name and description alone.

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/agentventure/mcp_server_python_getting_started'

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