Skip to main content
Glama
suryanshp1

Weather MCP Server

by suryanshp1

get_alerts

Retrieve weather alerts for any US state by providing its two-letter code to monitor hazardous conditions and stay informed about local weather warnings.

Instructions

Get weather alerts for US state Args: state: Two letter US state code (e.g CA, NY etc)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
stateYes

Implementation Reference

  • The primary handler function for the 'get_alerts' tool. It fetches active weather alerts for a given US state using the National Weather Service API and formats them for output. Registered via @mcp.tool() decorator.
    @mcp.tool()
    async def get_alerts(state: str) -> str:
        """Get weather alerts for US state
        Args:
            state: Two letter US state code (e.g CA, NY etc)
        """
        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.get("features"):
            return "No active alerts for this state"
    
        alerts = [format_alert(feature) for feature in data.get("features")]
    
        return "\n--------------\n".join(alerts)
  • Helper function that makes HTTP requests to the NWS 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 as e:
                return None
  • Helper function that formats a single weather alert feature into a human-readable 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 instrucy+tion provided")}
    """
  • Duplicate handler function for the 'get_alerts' tool, identical implementation as in mcpserver/server.py, likely for stdio transport usage.
    @mcp.tool()
    async def get_alerts(state: str) -> str:
        """Get weather alerts for US state
        Args:
            state: Two letter US state code (e.g CA, NY etc)
        """
        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.get("features"):
            return "No active alerts for this state"
    
        alerts = [format_alert(feature) for feature in data.get("features")]
    
        return "\n--------------\n".join(alerts)
  • Input schema defined in the tool's docstring, specifying the 'state' parameter as a two-letter US state code.
    """Get weather alerts for US state
    Args:
        state: Two letter US state code (e.g CA, NY etc)
    """
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 tool 'Get weather alerts' but does not describe behavioral traits such as rate limits, authentication needs, error handling, or what the return format looks like. For a tool with no annotations, this is a significant gap in transparency.

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

Conciseness3/5

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

The description is appropriately sized with two sentences, but it is not optimally structured. The first sentence states the purpose, and the second explains the parameter, but it could be more front-loaded with key details. It avoids waste but lacks polish in organization.

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 complexity (simple tool with one parameter), no annotations, and no output schema, the description is incomplete. It covers the purpose and parameter semantics but misses behavioral context, usage guidelines, and output details. For a tool with no structured support, more comprehensive description is needed.

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 schema description coverage is 0%, so the description must compensate. It adds meaning by specifying that the 'state' parameter is a 'Two letter US state code (e.g CA, NY etc)', which clarifies the format and provides examples. This is valuable beyond the basic schema, though it could be more detailed (e.g., list of valid 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 US state' specifies the verb ('Get'), resource ('weather alerts'), and geographic scope ('US state'). It distinguishes the tool's function well, though without sibling tools, full differentiation isn't tested. The purpose is specific and actionable.

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, prerequisites, or context for invocation. It only states what the tool does without indicating scenarios, limitations, or comparisons to other tools. This leaves the agent without usage direction.

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/suryanshp1/mcpcrashcourse'

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