Skip to main content
Glama

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() } ];

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