Skip to main content
Glama
pragaurav44

WeatherMCP

by pragaurav44

get_alerts

Retrieve weather alerts for any US state using two-letter state codes to monitor severe conditions and stay informed about local warnings.

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

  • The handler function for the 'get_alerts' tool. Decorated with @mcp.tool() for registration. Fetches active weather alerts for a given US state from the NWS API, handles errors, and formats the results 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 the 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 weather alert feature into a human-readable string. Used by get_alerts.
    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')}
                """
  • Docstring providing the tool description and input parameter schema (state: 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 states what the tool does but lacks details on behavioral traits such as rate limits, authentication needs, error handling, or response format. The description does not contradict any annotations (since none exist), but it fails to provide sufficient context for safe and effective use.

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 sized and front-loaded, with the main purpose stated first followed by parameter details. It uses two sentences efficiently, with no wasted words. However, the structure could be slightly improved by integrating parameter info more seamlessly, but it remains clear and concise.

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, no output schema, no annotations), the description is minimally adequate. It covers the purpose and parameter semantics but lacks behavioral context and usage guidelines. Without annotations or output schema, the description should do more to explain what to expect from the tool, but it meets a basic threshold for this simple case.

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 semantics beyond the input schema. The schema has 0% description coverage (only titles), but the description explains that 'state' is a 'Two-letter US state code (e.g. CA, NY)', clarifying the format and providing examples. This compensates well for the low schema coverage, though it doesn't cover all potential edge cases.

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'), and distinguishes it from the sibling tool 'get_forecast' by focusing on alerts rather than forecasts. However, it doesn't explicitly differentiate from potential other alert-related tools beyond the sibling.

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 mentions the sibling tool 'get_forecast' in context signals, but the description itself does not compare or contrast usage scenarios, prerequisites, or exclusions. Usage is implied by the purpose but not explicitly stated.

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/pragaurav44/WeatherMCP'

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