Skip to main content
Glama
le-yo

MCP Weather Server

by le-yo

getWeather

Retrieve current weather data for any location, including temperature, humidity, and conditions, with configurable units and language options.

Instructions

Get current weather information for a location. Returns weather data including temperature, humidity, and conditions.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
locationNoThe location to get weather for (city name, zip code, coordinates, etc.). If not provided, default location will be used.
optionsNoWeather configuration options, all fields are optional

Implementation Reference

  • index.js:26-47 (handler)
    Handler function that fetches current weather data for the given location using the wttr.in API and returns formatted weather information including temperature, humidity, wind speed, etc.
    handler: async ({ location }) => {
      try {
        // Note: In a real implementation, you would use a proper API key
        // This is using a free weather API that doesn't require authentication
        const response = await axios.get(`https://wttr.in/${encodeURIComponent(location)}?format=j1`);
        
        const weatherData = response.data;
        
        return {
          location: location,
          current_condition: weatherData.current_condition[0],
          weather_description: weatherData.current_condition[0].weatherDesc[0].value,
          temperature_C: weatherData.current_condition[0].temp_C,
          temperature_F: weatherData.current_condition[0].temp_F,
          humidity: weatherData.current_condition[0].humidity,
          wind_speed: weatherData.current_condition[0].windspeedKmph
        };
      } catch (error) {
        console.error('Error fetching weather:', error);
        throw new Error(`Failed to get weather for ${location}: ${error.message}`);
      }
    }
  • Input schema defining the required 'location' parameter as a string.
      type: 'object',
      properties: {
        location: {
          type: 'string',
          description: 'The city name or location to get weather for'
        }
      },
      required: ['location']
    },
  • index.js:13-48 (registration)
    Registration of the 'get_weather' tool with MCP server, including name, description, input schema, and handler function.
    server.registerTool({
      name: 'get_weather',
      description: 'Get current weather information for a location',
      parameters: {
        type: 'object',
        properties: {
          location: {
            type: 'string',
            description: 'The city name or location to get weather for'
          }
        },
        required: ['location']
      },
      handler: async ({ location }) => {
        try {
          // Note: In a real implementation, you would use a proper API key
          // This is using a free weather API that doesn't require authentication
          const response = await axios.get(`https://wttr.in/${encodeURIComponent(location)}?format=j1`);
          
          const weatherData = response.data;
          
          return {
            location: location,
            current_condition: weatherData.current_condition[0],
            weather_description: weatherData.current_condition[0].weatherDesc[0].value,
            temperature_C: weatherData.current_condition[0].temp_C,
            temperature_F: weatherData.current_condition[0].temp_F,
            humidity: weatherData.current_condition[0].humidity,
            wind_speed: weatherData.current_condition[0].windspeedKmph
          };
        } catch (error) {
          console.error('Error fetching weather:', error);
          throw new Error(`Failed to get weather for ${location}: ${error.message}`);
        }
      }
    });
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 mentions the tool 'Returns weather data including temperature, humidity, and conditions' which gives some output context, but lacks critical details like whether this is a read-only operation, if it requires authentication, rate limits, error handling, or what happens when location isn't provided (though schema covers this). For a tool with zero annotation coverage, this is insufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two concise sentences that efficiently convey core functionality. First sentence states purpose, second describes return values. No wasted words, though it could be slightly more structured by separating usage guidance from behavior description.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given 2 parameters with 100% schema coverage but no annotations and no output schema, the description provides basic purpose and return value information. However, for a weather API tool that likely has behavioral considerations (rate limits, authentication needs, error cases), the description should do more to compensate for the lack of structured metadata. It's minimally adequate but has clear gaps.

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 options with units/language). The description adds no parameter-specific information beyond what's in the schema. Baseline 3 is appropriate when schema does all the parameter documentation work.

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: 'Get current weather information for a location' with specific verb ('Get') and resource ('weather information'). It distinguishes from sibling tools by specifying 'current' weather (vs. 'hourly' or 'forecast'), but doesn't explicitly differentiate from 'lookupCity' which might be for location resolution rather than weather 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?

No explicit guidance on when to use this tool versus alternatives like getHourlyWeather or getWeatherForecast. The description implies it's for current weather, but doesn't state when to choose it over siblings or mention any prerequisites or exclusions. Usage context is minimal.

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/le-yo/weather-mcp'

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