Skip to main content
Glama
akaramanapp

Weather MCP Server

by akaramanapp

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 state

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
stateYesTwo-letter state code (e.g. CA, NY)

Implementation Reference

  • src/index.ts:96-141 (registration)
    Registration of the 'get-alerts' MCP tool, including input schema and inline handler function that fetches and formats weather alerts for a US state.
    server.tool(
      "get-alerts",
      "Get weather alerts for a state",
      {
        state: z.string().length(2).describe("Two-letter state code (e.g. CA, NY)"),
      },
      async ({ state }) => {
        const stateCode = state.toUpperCase();
        const alertsData = await makeNWSRequest<AlertsResponse>(`/alerts?area=${stateCode}`);
    
        if (!alertsData) {
          return {
            content: [
              {
                type: "text",
                text: "Failed to retrieve alerts data",
              },
            ],
          };
        }
    
        const features = alertsData.features || [];
        if (features.length === 0) {
          return {
            content: [
              {
                type: "text",
                text: `No active alerts for ${stateCode}`,
              },
            ],
          };
        }
    
        const formattedAlerts = features.map(formatAlert);
        const alertsText = `Active alerts for ${stateCode}:\n\n${formattedAlerts.join("\n")}`;
    
        return {
          content: [
            {
              type: "text",
              text: alertsText,
            },
          ],
        };
      },
    );
  • The handler function for 'get-alerts' tool: fetches alerts from National Weather Service API using the provided state code, handles errors/no data, formats alerts using helper, and returns formatted text content.
    async ({ state }) => {
      const stateCode = state.toUpperCase();
      const alertsData = await makeNWSRequest<AlertsResponse>(`/alerts?area=${stateCode}`);
    
      if (!alertsData) {
        return {
          content: [
            {
              type: "text",
              text: "Failed to retrieve alerts data",
            },
          ],
        };
      }
    
      const features = alertsData.features || [];
      if (features.length === 0) {
        return {
          content: [
            {
              type: "text",
              text: `No active alerts for ${stateCode}`,
            },
          ],
        };
      }
    
      const formattedAlerts = features.map(formatAlert);
      const alertsText = `Active alerts for ${stateCode}:\n\n${formattedAlerts.join("\n")}`;
    
      return {
        content: [
          {
            type: "text",
            text: alertsText,
          },
        ],
      };
    },
  • Input schema for 'get-alerts' tool using Zod: requires a 2-letter state code.
    {
      state: z.string().length(2).describe("Two-letter state code (e.g. CA, NY)"),
    },
  • Helper function to format individual alert feature into a readable string.
    function formatAlert(feature: AlertFeature): string {
      const props = feature.properties;
      return [
        `Event: ${props.event || "Unknown"}`,
        `Area: ${props.areaDesc || "Unknown"}`,
        `Severity: ${props.severity || "Unknown"}`,
        `Status: ${props.status || "Unknown"}`,
        `Headline: ${props.headline || "No headline"}`,
        "---",
      ].join("\n");
    }
  • Helper function to make API requests to the National Weather Service with error handling using axios.
    async function makeNWSRequest<T>(url: string): Promise<T | null> {
      try {
        const response = await api.get<T>(url);
        return response.data;
      } catch (error) {
        if (axios.isAxiosError(error)) {
          console.error("Error making NWS request:", error.message);
          if (error.response) {
            console.error("Response status:", error.response.status);
            console.error("Response data:", error.response.data);
          }
        } else {
          console.error("Unexpected error:", error);
        }
        return null;
      }
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions 'Get weather alerts' which implies a read-only operation, but doesn't specify whether this requires authentication, has rate limits, what format the alerts are returned in, or any error conditions. For a tool with zero annotation coverage, this is insufficient.

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 states the core functionality without any wasted words. It's appropriately sized for this simple tool and gets straight to the point.

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 should provide more context about what the tool returns and its behavioral characteristics. A simple 'Get weather alerts for a state' is inadequate for a tool that presumably returns structured alert data. The agent needs more information about the nature of the response.

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 schema description coverage is 100%, with the single parameter 'state' fully documented in the schema. The description doesn't add any additional parameter semantics beyond what's already in the schema (which specifies it's a two-letter state code). This meets the baseline of 3 when the schema does the heavy lifting.

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 the resource 'weather alerts for a state', making the purpose immediately understandable. However, it doesn't differentiate from the sibling tool 'get-forecast' (which presumably provides weather forecasts rather than alerts), so it doesn't reach the highest score of 5.

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 the sibling 'get-forecast' or any other alternatives. It states what the tool does but offers no context about appropriate use cases, prerequisites, or exclusions.

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/akaramanapp/weather-mcp-server'

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