Skip to main content
Glama
marcusbai

Caiyun Weather MCP Server

by marcusbai

get_weather_by_address

Retrieve weather details for a specific address, including real-time conditions, hourly forecasts, and daily predictions. Customize output with language, unit preferences, and forecast steps.

Instructions

根据地址获取天气信息

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressYes地址,如"北京市海淀区"
daily_stepsNo每日预报天数 (1-15)
hourly_stepsNo小时预报数量 (1-360)
languageNo语言zh_CN
unitNo单位制 (metric: 公制, imperial: 英制)metric

Implementation Reference

  • Handler for the get_weather_by_address tool: validates input using isValidAddressArgs, geocodes the address to longitude/latitude using GeocodeService, fetches comprehensive weather data using CaiyunWeatherService.getWeather, formats it, and returns as JSON text content.
    case 'get_weather_by_address': {
      if (!this.isValidAddressArgs(args)) {
        throw new McpError(
          ErrorCode.InvalidParams,
          '无效的地址参数'
        );
      }
      
      const { address, daily_steps = 5, hourly_steps = 24 } = args;
      
      // 将地址转换为经纬度
      const [longitude, latitude] = await this.geocodeService.geocode(address);
      
      const weatherData = await weatherService.getWeather(
        longitude, 
        latitude, 
        daily_steps, 
        hourly_steps
      );
      
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(weatherService.formatWeatherData(weatherData), null, 2),
          },
        ],
      };
    }
  • Input schema for get_weather_by_address tool defining required 'address' parameter and optional forecast steps, language, and unit preferences.
    inputSchema: {
      type: 'object',
      properties: {
        address: {
          type: 'string',
          description: '地址,如"北京市海淀区"',
        },
        daily_steps: {
          type: 'number',
          description: '每日预报天数 (1-15)',
          minimum: 1,
          maximum: 15,
          default: 5,
        },
        hourly_steps: {
          type: 'number',
          description: '小时预报数量 (1-360)',
          minimum: 1,
          maximum: 360,
          default: 24,
        },
        language: {
          type: 'string',
          enum: ['zh_CN', 'en_US'],
          description: '语言',
          default: 'zh_CN',
        },
        unit: {
          type: 'string',
          enum: ['metric', 'imperial'],
          description: '单位制 (metric: 公制, imperial: 英制)',
          default: 'metric',
        },
      },
      required: ['address'],
    },
  • src/index.ts:116-155 (registration)
    Registration of the get_weather_by_address tool in the ListTools response, including name, description, and full input schema.
    {
      name: 'get_weather_by_address',
      description: '根据地址获取天气信息',
      inputSchema: {
        type: 'object',
        properties: {
          address: {
            type: 'string',
            description: '地址,如"北京市海淀区"',
          },
          daily_steps: {
            type: 'number',
            description: '每日预报天数 (1-15)',
            minimum: 1,
            maximum: 15,
            default: 5,
          },
          hourly_steps: {
            type: 'number',
            description: '小时预报数量 (1-360)',
            minimum: 1,
            maximum: 360,
            default: 24,
          },
          language: {
            type: 'string',
            enum: ['zh_CN', 'en_US'],
            description: '语言',
            default: 'zh_CN',
          },
          unit: {
            type: 'string',
            enum: ['metric', 'imperial'],
            description: '单位制 (metric: 公制, imperial: 英制)',
            default: 'metric',
          },
        },
        required: ['address'],
      },
    },
  • Helper function to validate arguments for the get_weather_by_address tool, checking types for address and optional numeric parameters.
    private isValidAddressArgs(args: any): args is { address: string; daily_steps?: number; hourly_steps?: number } {
      return (
        typeof args === 'object' &&
        args !== null &&
        typeof args.address === 'string' &&
        (args.daily_steps === undefined || typeof args.daily_steps === 'number') &&
        (args.hourly_steps === undefined || typeof args.hourly_steps === 'number')
      );
    }
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 but offers minimal information. It doesn't mention whether this is a read-only operation, what data sources it uses, potential rate limits, authentication requirements, or what format the weather information will be returned in. The description only states what the tool does at a high level without behavioral context.

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 extremely concise at just 8 Chinese characters ('根据地址获取天气信息'), which translates to 'get weather information by address.' This is front-loaded with the core purpose and contains no unnecessary words or sentences. For a simple weather lookup tool, this brevity is appropriate.

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 5 parameters, no annotations, no output schema, and multiple sibling tools, the description is insufficiently complete. It doesn't explain what weather information is returned (current conditions, forecasts, alerts), how the address is resolved, error handling for invalid addresses, or differentiation from similar tools. The agent would need to guess about many important usage aspects.

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 mentions 'by address' which aligns with the required 'address' parameter, but adds no additional semantic context beyond what the schema already provides. With 100% schema description coverage and detailed parameter documentation in the schema (including defaults, ranges, and enums), the description doesn't enhance parameter understanding. The baseline score of 3 reflects adequate but minimal value added.

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 as '根据地址获取天气信息' (get weather information by address), which specifies both the action (get weather information) and the resource (by address). However, it doesn't distinguish this tool from its sibling 'get_weather_by_location' which likely serves a similar purpose with different input parameters.

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. With six sibling weather tools available (including get_daily_forecast, get_hourly_forecast, get_weather_by_location), the agent receives no indication of when this address-based weather tool is preferable to location-based or specialized forecast tools.

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

Related 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/marcusbai/caiyun-weather-mcp'

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