Skip to main content
Glama

fetch-Weather

Retrieve current weather data for any city location to inform planning and decision-making based on real-time atmospheric conditions.

Instructions

Get the weather for a given location

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cityYescity name like 'Bogotá'

Implementation Reference

  • main.ts:26-50 (handler)
    Handler function that geocodes the city, fetches current weather from Open-Meteo API, determines condition using helper, and returns formatted text response.
    async (params) => {
    
        const info = await fetch(`https://geocoding-api.open-meteo.com/v1/search?name=${params.city}`);
    
        const data = await info.json();
    
        const latitude = data.results[0].latitude;
        const longitude = data.results[0].longitude;
    
        const weather = await fetch(`https://api.open-meteo.com/v1/forecast?latitude=${latitude}&longitude=${longitude}¤t_weather=true`);
    
        const weatherData = await weather.json();
    
        const temperature = weatherData.current_weather.temperature;
        const condition = getWeatherCondition(temperature);
    
        return {
            content: [
                {
                    type: "text",
                    text: `The weather in ${params.city} is ${condition} with a temperature of ${temperature}°C`,
                }
            ]
        }
    }
  • main.ts:23-25 (schema)
    Input schema validating the 'city' parameter as a string.
    {
        city: z.string().describe("city name like 'Bogotá'")
    },
  • main.ts:20-51 (registration)
    Registers the 'fetch-Weather' tool using McpServer.tool() with name, description, schema, and handler.
    server.tool(
        'fetch-Weather',
        'Get the weather for a given location',
        {
            city: z.string().describe("city name like 'Bogotá'")
        },
        async (params) => {
    
            const info = await fetch(`https://geocoding-api.open-meteo.com/v1/search?name=${params.city}`);
    
            const data = await info.json();
    
            const latitude = data.results[0].latitude;
            const longitude = data.results[0].longitude;
    
            const weather = await fetch(`https://api.open-meteo.com/v1/forecast?latitude=${latitude}&longitude=${longitude}¤t_weather=true`);
    
            const weatherData = await weather.json();
    
            const temperature = weatherData.current_weather.temperature;
            const condition = getWeatherCondition(temperature);
    
            return {
                content: [
                    {
                        type: "text",
                        text: `The weather in ${params.city} is ${condition} with a temperature of ${temperature}°C`,
                    }
                ]
            }
        }
    );
  • main.ts:10-18 (helper)
    Helper utility to map temperature to a descriptive condition with emoji.
    function getWeatherCondition(temperature: number): string {
        if (temperature < 0) return "freezing ❄️";
        if (temperature < 10) return "cold 🥶";
        if (temperature < 15) return "cool 🌤️";
        if (temperature < 20) return "mild 😊";
        if (temperature < 25) return "warm ☀️";
        if (temperature < 30) return "hot 🔥";
        return "very hot 🌡️";
    }
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. It mentions 'Get the weather' but doesn't disclose behavioral traits like rate limits, error handling, data freshness, or authentication needs. This leaves significant gaps for a tool that likely interacts with 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 no wasted words, making it highly concise and front-loaded. Every part of the sentence contributes directly to understanding the tool's function.

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 weather data is returned (e.g., temperature, conditions), potential errors, or usage constraints, which are crucial for effective tool invocation in this context.

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 description implies a 'location' parameter, but the input schema already fully documents the single parameter 'city' with 100% coverage. No additional semantic details are added beyond what the schema provides, so it meets the baseline for high schema coverage.

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'), specifying it's for a given location. It's not a tautology of the name, but since there are no sibling tools, it doesn't need to differentiate from alternatives, so it doesn't achieve the highest score.

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, prerequisites, or exclusions. It only states what it does, without context for usage, which is minimal guidance.

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/alesanabriav7/mcpWeather'

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