Skip to main content
Glama

query_weather

Get current weather conditions for any city using this tool. Enter a city name to receive weather data for planning activities or travel.

Instructions

Query the weather

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cityYesThe City of the weather query

Implementation Reference

  • Handler implementation for the query_weather tool, which fetches weather data based on city coordinates.
    case "query_weather": {
      const city = String(request.params.arguments?.city);
      if (!city) {
        throw new Error("City is required");
      }
    
      const cityCoordinates: Record<string, { lat: number; lon: number }> = {
        '哈尔滨': { lat: 45.75, lon: 126.65 },
        '三亚': { lat: 18.25, lon: 109.51 },
        '北京': { lat: 39.90, lon: 116.41 },
        '上海': { lat: 31.23, lon: 121.47 },
        '广州': { lat: 23.13, lon: 113.26 },
        '深圳': { lat: 22.54, lon: 114.06 },
        '成都': { lat: 30.57, lon: 104.07 },
        '杭州': { lat: 30.27, lon: 120.16 },
        '重庆': { lat: 29.56, lon: 106.55 },
        '西安': { lat: 34.27, lon: 108.93 },
        '武汉': { lat: 30.59, lon: 114.30 }
      };
    
      // 获取城市经纬度,默认使用北京坐标
      const coords = cityCoordinates[city] || { lat: 39.90, lon: 116.41 };
      const url = `https://api.open-meteo.com/v1/forecast?latitude=${coords.lat}&longitude=${coords.lon}¤t_weather=true&hourly=temperature_2m,precipitation`;
      const weatherClient = new WeatherClient({ apiUrl: url });
      const result = await weatherClient.getWeather({ city });
    
      return {
        content: [{
          type: "text",
          text: `The weather report is: ${JSON.stringify(result)}`
        }]
      };
    }
  • src/index.ts:183-196 (registration)
    Tool definition and schema registration for query_weather.
    {
      name: "query_weather",
      description: "Query the weather",
      inputSchema: {
        type: "object",
        properties: {
          city: {
            type: "string",
            description: "The City of the weather query"
          }
        },
        required: ["city"]
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It fails to confirm whether this is idempotent, what happens when a city is unknown, data freshness/staleness, or whether it requires external API availability. The term 'Query' implies read-only but lacks explicit confirmation.

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

Conciseness3/5

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

The description is a single short sentence with no structural waste, but its brevity reflects under-specification rather than efficient communication. It front-loads the action but lacks the substantive details required to make the sentence 'earn 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?

Despite having only one parameter and no output schema, the description is incomplete. It omits what constitutes 'weather' data (temperature, humidity, wind), expected response structure, and error handling scenarios, leaving critical gaps for an agent attempting to use the tool effectively.

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 for the single 'city' parameter. The description adds no semantic details (e.g., examples like 'London, UK', format expectations, or disambiguation for duplicate city names), meriting the baseline score for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose2/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Query the weather' is tautological, essentially restating the tool name 'query_weather'. It fails to specify what weather data is returned (current conditions, forecast, alerts) or the scope of coverage, though it implicitly distinguishes from the sibling 'write_note' by suggesting a read operation.

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 guidance is provided on when to use this tool versus alternatives, prerequisites (such as needing specific city name formats), or error conditions (e.g., city not found). The description offers no 'when-not-to-use' boundaries.

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

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