Skip to main content
Glama
Yarflam

Weather MCP Server

by Yarflam

get_current_weather

Retrieve current weather conditions for any city worldwide, with Sydney as the default location, using global weather data from the Open-Meteo API.

Instructions

Récupère la météo actuelle pour une ville (Sydney par défaut)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cityNoNom de la ville (optionnel, Sydney par défaut)Sydney
countryNoCode pays optionnel (ex: AU, FR, US)

Implementation Reference

  • The main handler function that fetches current weather data for a specified city (default Sydney) using Open-Meteo APIs, formats and returns the response.
      async getCurrentWeather(city, country) {
        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}¤t=temperature_2m,relative_humidity_2m,apparent_temperature,is_day,precipitation,rain,showers,snowfall,weather_code,cloud_cover,pressure_msl,surface_pressure,wind_speed_10m,wind_direction_10m,wind_gusts_10m&timezone=auto`;
        
        const response = await fetch(url);
        const data = await response.json();
    
        if (!response.ok) {
          throw new Error('Erreur lors de la récupération de la météo');
        }
    
        const current = data.current;
        const weatherDesc = this.getWeatherDescription(current.weather_code);
        const windDir = this.getWindDirection(current.wind_direction_10m);
        
        return {
          content: [
            {
              type: 'text',
              text: `🌤️ Météo actuelle à ${location.name || location.admin1 || 'Localisation'}${location.country ? `, ${location.country}` : ''}
    
    📍 **Localisation:** ${location.latitude}°, ${location.longitude}°
    🌡️ **Température:** ${Math.round(current.temperature_2m)}°C
    🤔 **Ressenti:** ${Math.round(current.apparent_temperature)}°C
    ☁️ **Conditions:** ${weatherDesc} ${current.is_day ? '☀️' : '🌙'}
    💧 **Humidité:** ${current.relative_humidity_2m}%
    🌬️ **Vent:** ${Math.round(current.wind_speed_10m)} km/h ${windDir}
    💨 **Rafales:** ${Math.round(current.wind_gusts_10m)} km/h
    🔽 **Pression:** ${Math.round(current.pressure_msl)} hPa
    ☁️ **Couverture nuageuse:** ${current.cloud_cover}%
    
    ${current.precipitation > 0 ? `🌧️ **Précipitations:** ${current.precipitation} mm` : ''}
    ${current.rain > 0 ? `🌧️ **Pluie:** ${current.rain} mm` : ''}
    ${current.snowfall > 0 ? `❄️ **Neige:** ${current.snowfall} cm` : ''}
    
    ⏰ **Dernière mise à jour:** ${new Date(current.time).toLocaleString('fr-FR')}`,
            },
          ],
        };
      }
  • src/index.js:51-69 (registration)
    Registration of the 'get_current_weather' tool in the ListTools response, including name, description, and input schema.
    {
      name: 'get_current_weather',
      description: 'Récupère la météo actuelle pour une ville (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 (ex: AU, FR, US)',
          }
        },
        required: [],
      },
    },
  • src/index.js:146-147 (registration)
    Dispatcher case in CallToolRequestSchema handler that routes calls to the getCurrentWeather method.
    case 'get_current_weather':
      return await this.getCurrentWeather(args.city || 'Sydney', args.country);
  • Helper function to resolve city name to coordinates using geocoding API, used by getCurrentWeather.
    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 to translate weather codes to human-readable descriptions.
    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?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool retrieves current weather, implying a read-only operation, but doesn't cover important aspects like rate limits, error handling, data freshness, or authentication needs. For a tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

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 in French that conveys the core purpose and default behavior without any wasted words. It's appropriately sized and front-loaded, making it easy for an agent to parse quickly.

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. It doesn't explain what the return values look like (e.g., temperature, conditions), potential errors, or how it differs from sibling tools. For a tool with no structured output and zero annotation coverage, more contextual information is needed to guide effective use.

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 clear documentation for both parameters (city and country). The description adds minimal value beyond the schema: it mentions the default city (Sydney) and that the city parameter is optional, but this is already covered in the schema. Since the schema does the heavy lifting, the baseline score of 3 is appropriate.

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 la météo actuelle pour une ville' (Retrieves current weather for a city). It specifies the verb ('récupère') and resource ('météo actuelle'), and mentions the default city (Sydney). However, it doesn't explicitly differentiate from sibling tools like get_weather_by_coordinates or get_weather_forecast, which prevents a 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 minimal usage guidance: it mentions the default city (Sydney) but offers no explicit advice on when to use this tool versus alternatives like get_weather_by_coordinates or get_weather_forecast. There's no context on prerequisites, limitations, or comparisons to siblings, leaving the agent with little direction.

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