Skip to main content
Glama
Yarflam

Weather MCP Server

by Yarflam

get_weather_by_coordinates

Retrieve weather data and forecasts for specific geographic coordinates using latitude and longitude values.

Instructions

Récupère la météo selon les coordonnées géographiques

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
latNoLatitude (-33.8688 pour Sydney par défaut)
lonNoLongitude (151.2093 pour Sydney par défaut)
daysNoNombre de jours de prévision (1-7)

Implementation Reference

  • The primary handler function executing the tool logic. Fetches current weather (days=1) or forecast (days>1) using Open-Meteo API for given coordinates, formats and returns formatted text response.
      async getWeatherByCoordinates(lat, lon, days) {
        const currentUrl = `${WEATHER_API}?latitude=${lat}&longitude=${lon}¤t=temperature_2m,relative_humidity_2m,apparent_temperature,is_day,precipitation,weather_code,cloud_cover,pressure_msl,wind_speed_10m,wind_direction_10m&timezone=auto`;
        
        if (days === 1) {
          const response = await fetch(currentUrl);
          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 aux coordonnées ${lat}°, ${lon}°
    
    🌡️ **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}
    🔽 **Pression:** ${Math.round(current.pressure_msl)} hPa
    ☁️ **Couverture nuageuse:** ${current.cloud_cover}%
    
    ⏰ **Dernière mise à jour:** ${new Date(current.time).toLocaleString('fr-FR')}`,
              },
            ],
          };
        } else {
          // Prévisions multi-jours
          const forecastUrl = `${WEATHER_API}?latitude=${lat}&longitude=${lon}&daily=weather_code,temperature_2m_max,temperature_2m_min,precipitation_sum,wind_speed_10m_max&timezone=auto&forecast_days=${days}`;
          const response = await fetch(forecastUrl);
          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 ${days} jours aux coordonnées ${lat}°, ${lon}°\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]);
            
            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 += `☁️ ${weatherDesc}\n`;
            if (daily.precipitation_sum[i] > 0) {
              forecastText += `🌧️ ${daily.precipitation_sum[i]}mm\n`;
            }
            forecastText += `\n`;
          }
    
          return {
            content: [
              {
                type: 'text',
                text: forecastText.trim(),
              },
            ],
          };
        }
      }
  • Input schema defining parameters: lat (number, default -33.8688), lon (number, default 151.2093), days (number 1-7, default 1). No required fields.
    inputSchema: {
      type: 'object',
      properties: {
        lat: {
          type: 'number',
          description: 'Latitude (-33.8688 pour Sydney par défaut)',
          default: -33.8688
        },
        lon: {
          type: 'number',
          description: 'Longitude (151.2093 pour Sydney par défaut)',
          default: 151.2093
        },
        days: {
          type: 'number',
          description: 'Nombre de jours de prévision (1-7)',
          default: 1,
          minimum: 1,
          maximum: 7
        }
      },
      required: [],
    },
  • src/index.js:96-122 (registration)
    Tool registration in the ListTools response, specifying name, description, and input schema.
    {
      name: 'get_weather_by_coordinates',
      description: 'Récupère la météo selon les coordonnées géographiques',
      inputSchema: {
        type: 'object',
        properties: {
          lat: {
            type: 'number',
            description: 'Latitude (-33.8688 pour Sydney par défaut)',
            default: -33.8688
          },
          lon: {
            type: 'number',
            description: 'Longitude (151.2093 pour Sydney par défaut)',
            default: 151.2093
          },
          days: {
            type: 'number',
            description: 'Nombre de jours de prévision (1-7)',
            default: 1,
            minimum: 1,
            maximum: 7
          }
        },
        required: [],
      },
    },
  • src/index.js:152-157 (registration)
    Dispatch logic in CallToolRequest handler switch statement, mapping tool name to the getWeatherByCoordinates method with default args.
    case 'get_weather_by_coordinates':
      return await this.getWeatherByCoordinates(
        args.lat || DEFAULT_LOCATION.latitude, 
        args.lon || DEFAULT_LOCATION.longitude, 
        args.days || 1
      );
  • Helper function to translate weather codes to French descriptions, used in getWeatherByCoordinates.
    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 weather but doesn't disclose any behavioral traits such as rate limits, authentication needs, error handling, or what the output looks like (e.g., current conditions, forecast details). For a tool with no annotations, this is a significant gap in transparency.

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 directly states the tool's function. It's front-loaded with the core purpose and has no wasted words. This is appropriately concise for a simple retrieval tool.

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 complexity (3 parameters, no annotations, no output schema), the description is incomplete. It lacks details on output format (e.g., what weather data is returned), behavioral aspects like error cases, and differentiation from siblings. Without annotations or output schema, the description should provide more context to be fully helpful.

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?

The input schema has 100% description coverage, with clear documentation for 'lat', 'lon', and 'days' including defaults and constraints. The description adds no additional parameter semantics beyond what's in the schema—it doesn't explain coordinate formats, units, or how 'days' affects the output. Given high schema coverage, the baseline score of 3 is appropriate, as the description doesn't compensate but doesn't need to.

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 selon les coordonnées géographiques' (Retrieves weather based on geographic coordinates). It specifies the verb ('récupère') and resource ('météo'), and while it doesn't explicitly distinguish from siblings like 'get_current_weather' or 'get_weather_forecast', the mention of coordinates provides some differentiation. However, it's not fully specific about scope (e.g., current vs. forecast) compared to siblings.

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 like 'get_current_weather' or 'get_weather_forecast'. It doesn't mention any prerequisites, exclusions, or contextual factors (e.g., use this for coordinates-based queries, use others for city names). The lack of usage context leaves the agent to infer based on tool names 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