Skip to main content
Glama
bobbyyng

Weather MCP Server

by bobbyyng

get_weather_alerts

Retrieve weather alert details for a specific location or all areas using the Weather MCP Server. Input a location name to view targeted alerts or leave blank for comprehensive updates.

Instructions

Get weather alert information

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
locationNoLocation name (optional, if not provided, get all alerts)

Implementation Reference

  • The core handler function that implements the logic for the get_weather_alerts tool, filtering mock weather alerts based on location.
    async getWeatherAlerts(location?: string): Promise<WeatherAlert[]> {
      if (!location) {
        return mockWeatherAlerts;
      }
      
      const normalizedLocation = this.normalizeLocation(location);
      const locationName = mockWeatherData[normalizedLocation]?.location || location;
      
      return mockWeatherAlerts.filter(alert => 
        alert.areas.some(area => 
          area.toLowerCase().includes(locationName.toLowerCase()) ||
          locationName.toLowerCase().includes(area.toLowerCase()) ||
          area.toLowerCase().includes(normalizedLocation) ||
          normalizedLocation.includes(area.toLowerCase())
        )
      );
    }
  • JSON Schema definition for the input parameters of the get_weather_alerts tool.
    {
      name: 'get_weather_alerts',
      description: 'Get weather alert information',
      inputSchema: {
        type: 'object',
        properties: {
          location: {
            type: 'string',
            description: 'Location name (optional, if not provided, get all alerts)',
          },
        },
      },
    },
  • src/index.ts:143-154 (registration)
    Registration of the tool call handler for get_weather_alerts in the main MCP stdio server.
    case 'get_weather_alerts': {
      const { location } = args as { location?: string };
      const alerts = await this.weatherService.getWeatherAlerts(location);
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(alerts, null, 2),
          },
        ],
      };
    }
  • TypeScript interface defining the WeatherAlert type used for output validation.
    export interface WeatherAlert {
      id: string;
      type: string;
      severity: 'minor' | 'moderate' | 'severe' | 'extreme';
      title: string;
      description: string;
      areas: string[];
      startTime: string;
      endTime: string;
    } 
  • Mock data array of WeatherAlert objects used by the handler to provide sample weather alerts.
    export const mockWeatherAlerts: WeatherAlert[] = [
      {
        id: 'hk-typhoon-001',
        type: 'Typhoon',
        severity: 'severe',
        title: 'Typhoon Warning Signal No. 8',
        description: 'Strong winds and heavy rain expected. Stay indoors and avoid unnecessary travel. Public transport may be suspended.',
        areas: ['Hong Kong Island', 'Kowloon', 'New Territories'],
        startTime: new Date().toISOString(),
        endTime: new Date(Date.now() + 12 * 60 * 60 * 1000).toISOString()
      },
      {
        id: 'tokyo-heatwave-001',
        type: 'Heat Wave',
        severity: 'moderate',
        title: 'High Temperature Advisory',
        description: 'Temperatures may exceed 35°C. Stay hydrated and avoid prolonged outdoor activities during peak hours.',
        areas: ['Tokyo Metropolitan Area', 'Chiba', 'Saitama'],
        startTime: new Date().toISOString(),
        endTime: new Date(Date.now() + 24 * 60 * 60 * 1000).toISOString()
      },
      {
        id: 'osaka-thunderstorm-001',
        type: 'Thunderstorm',
        severity: 'moderate',
        title: 'Severe Thunderstorm Warning',
        description: 'Heavy rain, lightning, and strong winds expected. Avoid outdoor activities and seek shelter.',
        areas: ['Osaka Prefecture', 'Kyoto', 'Nara'],
        startTime: new Date(Date.now() + 2 * 60 * 60 * 1000).toISOString(),
        endTime: new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString()
      },
      {
        id: 'sapporo-snow-001',
        type: 'Snow',
        severity: 'minor',
        title: 'Late Season Snow Advisory',
        description: 'Unexpected late spring snowfall possible. Roads may become slippery, drive with caution.',
        areas: ['Sapporo City', 'Hokkaido Central'],
        startTime: new Date(Date.now() + 6 * 60 * 60 * 1000).toISOString(),
        endTime: new Date(Date.now() + 18 * 60 * 60 * 1000).toISOString()
      },
      {
        id: 'london-flood-001',
        type: 'Flood',
        severity: 'moderate',
        title: 'Flood Warning',
        description: 'Heavy rainfall may cause flooding in low-lying areas. Avoid driving through flooded roads.',
        areas: ['Thames Valley', 'South London', 'Surrey'],
        startTime: new Date().toISOString(),
        endTime: new Date(Date.now() + 6 * 60 * 60 * 1000).toISOString()
      },
      {
        id: 'fukuoka-typhoon-001',
        type: 'Typhoon',
        severity: 'severe',
        title: 'Typhoon Approach Warning',
        description: 'Typhoon approaching southern Japan. Prepare for strong winds, heavy rain, and possible power outages.',
        areas: ['Fukuoka Prefecture', 'Kumamoto', 'Kagoshima'],
        startTime: new Date(Date.now() + 4 * 60 * 60 * 1000).toISOString(),
        endTime: new Date(Date.now() + 20 * 60 * 60 * 1000).toISOString()
      }
    ];
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure but offers minimal insight. It doesn't describe whether this is a read-only operation, potential rate limits, authentication needs, data sources, or what 'weather alert information' entails (e.g., severity levels, expiration times). The agent must infer behavior from the generic 'get' verb.

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 a single, efficient sentence with no wasted words. It's front-loaded with the core purpose, though it could be more informative. The brevity is appropriate but risks under-specification rather than true conciseness.

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 is incomplete for a tool that likely returns structured alert data. It doesn't explain return values (e.g., list of alerts, timestamps, types), error handling, or how optional location filtering affects results. For a tool with potential complexity in weather data, this leaves significant gaps.

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?

Schema description coverage is 100%, with the parameter 'location' documented as optional for retrieving all alerts. The description adds no parameter-specific details beyond what the schema provides, such as format examples (e.g., city names, coordinates) or how location filtering works. Baseline 3 is appropriate since the schema handles parameter documentation adequately.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose2/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Get weather alert information' restates the tool name with minimal added specificity. While it includes the verb 'get' and resource 'weather alert information', it doesn't distinguish this tool from its siblings (like get_current_weather or get_weather_forecast) beyond the general alert focus. This is borderline tautological with the name.

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. The description doesn't mention its siblings (e.g., get_current_weather for current conditions, get_weather_forecast for predictions, or search_locations for location lookup), nor does it specify contexts like emergency planning or risk assessment where alerts are most relevant.

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

Related 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/bobbyyng/weather-mcp-ts'

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