Skip to main content
Glama
Yarflam

Weather MCP Server

by Yarflam

get_weather_forecast

Retrieve 7-day weather forecasts for any global location using the Open-Meteo API, with Sydney as the default city. Specify city, country, and forecast duration (1-7 days) for accurate planning.

Instructions

Récupère les prévisions météo sur 7 jours (Sydney par défaut)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cityNoNom de la ville (optionnel, Sydney par défaut)Sydney
countryNoCode pays optionnel
daysNoNombre de jours de prévision (1-7)

Implementation Reference

  • The primary handler function for the get_weather_forecast tool. It geocodes the city (using helper), fetches daily forecast data from Open-Meteo API, formats it into a structured text response with temperatures, conditions, wind, sunrise/sunset for each day.
    async getWeatherForecast(city, country, days) {
      let location;
      
      if (city.toLowerCase() === 'sydney' && !country) {
        location = DEFAULT_LOCATION;
      } else {
        location = await this.getCoordinates(city, country);
      }
    
      const url = `${WEATHER_API}?latitude=${location.latitude}&longitude=${location.longitude}&daily=weather_code,temperature_2m_max,temperature_2m_min,apparent_temperature_max,apparent_temperature_min,sunrise,sunset,precipitation_sum,rain_sum,showers_sum,snowfall_sum,precipitation_hours,wind_speed_10m_max,wind_gusts_10m_max,wind_direction_10m_dominant&timezone=auto&forecast_days=${days}`;
      
      const response = await fetch(url);
      const data = await response.json();
    
      if (!response.ok) {
        throw new Error('Erreur lors de la récupération des prévisions');
      }
    
      const daily = data.daily;
      let forecastText = `🗓️ Prévisions météo ${days} jours pour ${location.name || location.admin1}${location.country ? `, ${location.country}` : ''}\n\n`;
      
      for (let i = 0; i < days; i++) {
        const date = new Date(daily.time[i]);
        const dayName = date.toLocaleDateString('fr-FR', { weekday: 'long' });
        const dateStr = date.toLocaleDateString('fr-FR');
        const weatherDesc = this.getWeatherDescription(daily.weather_code[i]);
        const windDir = this.getWindDirection(daily.wind_direction_10m_dominant[i]);
        
        forecastText += `📅 **${dayName.charAt(0).toUpperCase() + dayName.slice(1)} ${dateStr}**\n`;
        forecastText += `🌡️ ${Math.round(daily.temperature_2m_min[i])}°C → ${Math.round(daily.temperature_2m_max[i])}°C\n`;
        forecastText += `🤔 Ressenti: ${Math.round(daily.apparent_temperature_min[i])}°C → ${Math.round(daily.apparent_temperature_max[i])}°C\n`;
        forecastText += `☁️ ${weatherDesc}\n`;
        forecastText += `🌬️ Vent: ${Math.round(daily.wind_speed_10m_max[i])} km/h ${windDir}\n`;
        
        if (daily.precipitation_sum[i] > 0) {
          forecastText += `🌧️ Précipitations: ${daily.precipitation_sum[i]}mm\n`;
        }
        
        forecastText += `🌅 Lever: ${new Date(daily.sunrise[i]).toLocaleTimeString('fr-FR', {hour: '2-digit', minute: '2-digit'})}\n`;
        forecastText += `🌇 Coucher: ${new Date(daily.sunset[i]).toLocaleTimeString('fr-FR', {hour: '2-digit', minute: '2-digit'})}\n\n`;
      }
    
      return {
        content: [
          {
            type: 'text',
            text: forecastText.trim(),
          },
        ],
      };
    }
  • Tool schema definition in the ListTools response, specifying name, description, and input schema with optional parameters city, country, and days.
    {
      name: 'get_weather_forecast',
      description: 'Récupère les prévisions météo sur 7 jours (Sydney par défaut)',
      inputSchema: {
        type: 'object',
        properties: {
          city: {
            type: 'string',
            description: 'Nom de la ville (optionnel, Sydney par défaut)',
            default: 'Sydney'
          },
          country: {
            type: 'string',
            description: 'Code pays optionnel',
          },
          days: {
            type: 'number',
            description: 'Nombre de jours de prévision (1-7)',
            default: 7,
            minimum: 1,
            maximum: 7
          }
        },
        required: [],
      },
    },
  • src/index.js:149-150 (registration)
    Registration in the CallToolRequestSchema switch statement that dispatches to the getWeatherForecast handler with default parameters.
    case 'get_weather_forecast':
      return await this.getWeatherForecast(args.city || 'Sydney', args.country, args.days || 7);
  • Helper function used by the handler to resolve city/country to latitude/longitude coordinates via Open-Meteo geocoding API.
    async getCoordinates(city, country) {
      const query = country ? `${city}, ${country}` : city;
      const url = `${GEOCODING_API}?name=${encodeURIComponent(query)}&count=1&language=fr&format=json`;
      
      const response = await fetch(url);
      const data = await response.json();
    
      if (!response.ok || !data.results || data.results.length === 0) {
        throw new Error(`Ville "${query}" non trouvée`);
      }
    
      return data.results[0];
    }
  • Helper utility to translate weather codes to human-readable French descriptions, used in forecast formatting.
    getWeatherDescription(code) {
      const descriptions = {
        0: 'Ciel dégagé',
        1: 'Principalement dégagé',
        2: 'Partiellement nuageux',
        3: 'Couvert',
        45: 'Brouillard',
        48: 'Brouillard givrant',
        51: 'Bruine légère',
        53: 'Bruine modérée',
        55: 'Bruine dense',
        56: 'Bruine verglaçante légère',
        57: 'Bruine verglaçante dense',
        61: 'Pluie légère',
        63: 'Pluie modérée',
        65: 'Pluie forte',
        66: 'Pluie verglaçante légère',
        67: 'Pluie verglaçante forte',
        71: 'Neige légère',
        73: 'Neige modérée',
        75: 'Neige forte',
        77: 'Grains de neige',
        80: 'Averses légères',
        81: 'Averses modérées',
        82: 'Averses violentes',
        85: 'Averses de neige légères',
        86: 'Averses de neige fortes',
        95: 'Orage',
        96: 'Orage avec grêle légère',
        99: 'Orage avec grêle forte'
      };
      
      return descriptions[code] || 'Conditions inconnues';
    }
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 the tool retrieves forecasts but lacks critical details: whether it's a read-only operation, any rate limits, authentication requirements, error handling, or response format. For a tool with no annotation coverage, this leaves significant behavioral gaps unaddressed.

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 extremely concise—a single sentence in French that efficiently conveys the core functionality. It's front-loaded with the main purpose and includes key details (7-day forecast, Sydney default) without any fluff or redundant information. Every word earns its place.

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 tool's moderate complexity (3 parameters, no annotations, no output schema), the description is incomplete. It doesn't explain what the forecast data includes (e.g., temperature, precipitation), how results are structured, or any limitations beyond the 7-day range. Without annotations or output schema, the description should provide more context about behavior and returns.

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 fully documents all three parameters (city, country, days) with descriptions, defaults, and constraints. The description adds marginal value by mentioning the 7-day forecast scope and Sydney default, but doesn't provide additional semantic context beyond what's already in the schema. Baseline 3 is appropriate when 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 tool's purpose: 'Récupère les prévisions météo sur 7 jours' (Retrieves 7-day weather forecasts). It specifies the verb ('récupère'), resource ('prévisions météo'), and scope ('sur 7 jours'). However, it doesn't explicitly differentiate from sibling tools like 'get_current_weather' or 'get_weather_by_coordinates' beyond implying a forecast vs. current weather distinction.

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 minimal usage guidance. It mentions 'Sydney par défaut' (Sydney by default), which hints at optional city parameter usage, but offers no explicit when-to-use rules, no comparison to alternatives like 'get_current_weather' for current vs. forecast data, and no prerequisites or exclusions. The agent must infer usage from context 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

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

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