Skip to main content
Glama
bobbyyng

Weather MCP Server

by bobbyyng

get_weather_forecast

Retrieve accurate weather forecasts for any location with customizable timeframes. Specify the location and the number of days (1-7) to predict weather conditions effectively.

Instructions

Get weather forecast for a specified location

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
daysNoForecast days (1-7 days, default is 3 days)
locationYesLocation name

Implementation Reference

  • Core handler function that implements the get_weather_forecast tool logic. Normalizes location, fetches from mock data if available, or generates synthetic forecast.
    async getWeatherForecast(location: string, days: number = 3): Promise<WeatherForecast> {
      const normalizedLocation = this.normalizeLocation(location);
      
      if (mockForecastData[normalizedLocation]) {
        const forecast = mockForecastData[normalizedLocation];
        return {
          ...forecast,
          forecast: forecast.forecast.slice(0, days)
        };
      }
      
      // If location not found, generate mock forecast data
      return this.generateMockForecast(location, days);
    }
  • TypeScript interface definitions for the WeatherForecast output type used by the tool.
    export interface WeatherForecast {
      location: string;
      forecast: DailyForecast[];
    }
    
    export interface DailyForecast {
      date: string;
      highTemp: number;
      lowTemp: number;
      condition: string;
      description: string;
      chanceOfRain: number;
      humidity: number;
    }
  • src/index.ts:53-71 (registration)
    Tool registration in the main stdio MCP server (index.ts), defining name, description, and input schema for ListTools response.
      name: 'get_weather_forecast',
      description: 'Get weather forecast for a specified location',
      inputSchema: {
        type: 'object',
        properties: {
          location: {
            type: 'string',
            description: 'Location name',
          },
          days: {
            type: 'number',
            description: 'Forecast days (1-7 days, default is 3 days)',
            minimum: 1,
            maximum: 7,
          },
        },
        required: ['location'],
      },
    },
  • Tool registration in the SSE MCP server.
    name: "get_weather_forecast",
    description: "Get weather forecast for a specified location",
    inputSchema: {
      type: "object",
      properties: {
        location: {
          type: "string",
          description: "Location name",
        },
        days: {
          type: "number",
          description: "Forecast days (1-7 days, default 3 days)",
          minimum: 1,
          maximum: 7,
        },
      },
      required: ["location"],
    },
  • Private helper method called by the handler to generate synthetic forecast data when no mock data is available for the location.
    private generateMockForecast(location: string, days: number): WeatherForecast {
      const forecast = [];
      const baseTemp = 20 + Math.random() * 15; // Temperature between 20-35°C
      const conditions = ['Sunny', 'Partly Cloudy', 'Cloudy', 'Rainy', 'Thunderstorms', 'Overcast', 'Light Rain'];
      const descriptions = {
        'Sunny': 'Clear skies with bright sunshine',
        'Partly Cloudy': 'Mix of sun and clouds',
        'Cloudy': 'Overcast skies with mild temperatures',
        'Rainy': 'Rain showers expected',
        'Thunderstorms': 'Thunderstorms with heavy rain',
        'Overcast': 'Cloudy skies throughout the day',
        'Light Rain': 'Light rain showers'
      };
      
      for (let i = 1; i <= days; i++) {
        const date = new Date(Date.now() + i * 24 * 60 * 60 * 1000);
        const tempVariation = (Math.random() - 0.5) * 10;
        const condition = conditions[Math.floor(Math.random() * conditions.length)];
        
        forecast.push({
          date: date.toISOString().split('T')[0],
          highTemp: Math.round(baseTemp + tempVariation + 5),
          lowTemp: Math.round(baseTemp + tempVariation - 5),
          condition,
          description: descriptions[condition as keyof typeof descriptions] || `${condition} conditions expected`,
          chanceOfRain: condition.includes('Rain') || condition.includes('Thunder') ? 70 + Math.random() * 30 : Math.random() * 40,
          humidity: 50 + Math.random() * 40
        });
      }
      
      return {
        location,
        forecast
      };
    }
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. It states what the tool does but doesn't describe important traits: whether it's read-only or has side effects, authentication requirements, rate limits, error handling, or what the forecast includes (e.g., temperature, precipitation). This leaves significant gaps for a tool that likely queries external data.

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, clear sentence with zero wasted words. It's appropriately sized for a simple tool and front-loads the core purpose immediately. Every word earns its place without redundancy.

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 no annotations and no output schema, the description is incomplete for a weather forecast tool. It doesn't explain what the forecast returns (e.g., time periods, metrics), potential limitations (e.g., accuracy, data sources), or error cases (e.g., invalid location). For a tool with external dependencies and likely structured output, this leaves the agent under-informed.

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%, so the schema already fully documents both parameters ('location' and 'days'). The description adds no additional parameter semantics beyond what's in the schema. It mentions 'for a specified location' which aligns with the 'location' parameter but provides no extra context about format or constraints.

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 with a specific verb ('Get') and resource ('weather forecast'), and specifies the target ('for a specified location'). It distinguishes from sibling 'get_current_weather' by focusing on forecast rather than current conditions. However, it doesn't explicitly differentiate from 'get_weather_stats' which might also involve forecast data.

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 doesn't mention when to choose 'get_weather_forecast' over 'get_current_weather' or 'get_weather_stats', nor does it specify prerequisites or exclusions. The agent must infer usage from the name alone.

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