Skip to main content
Glama
chenshuai2144

MCP-Server

get-weather-forecast

Retrieve weather forecasts by providing city names to access current conditions and predictions through structured API calls.

Instructions

根据经纬度获取天气信息

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cityNo

Implementation Reference

  • The handler function that implements the core logic of the 'get-weather-forecast' tool. It constructs the API URL using the gaode endpoint and key, fetches the weather data for the given city, types it as Root, and returns a standardized content response with the JSON stringified data.
    async ({ city }) => {
      // 获取网格点数据的 URL
      const pointsUrl = `${gaode}?key=${key}&city=${city}`;
    
      const data: Root = await fetch(pointsUrl).then((response) =>
        response.json(),
      );
    
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(data),
          },
        ],
      };
    },
  • TypeScript interfaces defining the expected structure of the weather API response data, used for typing the 'data' variable in the handler.
    export interface Root {
      status: string;
      count: string;
      info: string;
      infocode: string;
      lives: Lfe[];
    }
    
    export interface Lfe {
      province: string;
      city: string;
      adcode: string;
      weather: string;
      temperature: string;
      winddirection: string;
      windpower: string;
      humidity: string;
      reporttime: string;
      temperature_float: string;
      humidity_float: string;
    }
  • Zod validation schema for the tool's input parameters. Defines an optional 'city' string parameter.
    {
      city: z.string().optional(),
    },
    // 工具的异步处理函数
  • src/index.ts:46-74 (registration)
    The MCP server.tool registration for the 'get-weather-forecast' tool, including name, description, input schema, and inline handler implementation.
    // 注册获取天气预报的工具
    server.tool(
      // 工具名称
      'get-weather-forecast',
      // 工具描述
      '根据经纬度获取天气信息',
      // 工具参数
      {
        city: z.string().optional(),
      },
      // 工具的异步处理函数
      async ({ city }) => {
        // 获取网格点数据的 URL
        const pointsUrl = `${gaode}?key=${key}&city=${city}`;
    
        const data: Root = await fetch(pointsUrl).then((response) =>
          response.json(),
        );
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(data),
            },
          ],
        };
      },
    );
  • Constants defining the Amap (Gaode) weather API endpoint URL and the API key loaded from environment variables, used in the tool handler.
    const gaode = 'https://restapi.amap.com/v3/weather/weatherInfo';
    const key = process.env.GAODE_KEY;
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 what the tool does but doesn't describe how it behaves: no information on error handling, rate limits, authentication needs, data freshness, or what happens if inputs are invalid. The description is minimal and doesn't compensate for the lack of annotations.

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?

The description is very concise: a single sentence in Chinese. It's front-loaded with the core purpose and has no wasted words. However, it might be overly brief given the tool's complexity and parameter issues, but as a standalone statement, it's efficient.

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 has no annotations, no output schema, and low schema description coverage (0%), the description is incomplete. It doesn't explain the return values, error conditions, or clarify the parameter mismatch. For a tool with one parameter and potential ambiguity, more context is needed to make it fully usable.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description mentions '经纬度' (latitude and longitude) as the expected input, but the input schema only has a 'city' parameter of type string with 0% schema description coverage. This creates a contradiction: the description implies coordinates are needed, while the schema suggests a city name. The description doesn't clarify this discrepancy or add meaningful semantics beyond what's implied, failing to compensate for the low 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: '根据经纬度获取天气信息' (Get weather information based on latitude and longitude). It uses a specific verb ('获取' - get) and resource ('天气信息' - weather information). However, it doesn't distinguish from the sibling tool 'get-github-user', which is unrelated, so differentiation isn't needed here.

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. It doesn't mention any prerequisites, constraints, or comparison with other weather-related tools (though none are listed as siblings). The usage is implied from the purpose but lacks explicit context or exclusions.

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/chenshuai2144/mcp-server'

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