Skip to main content
Glama

MCP 天气服务器

npm 版本 执照 节点版本 问题 每周下载量

模型上下文协议 (MCP) 服务器使用 AccuWeather API 提供每小时和每日天气预报。


快速入门

您需要一个 AccuWeather API 密钥(提供免费套餐)。
在此注册并创建一个应用程序来获取您的密钥。

将您的 API 密钥导出为环境变量:

export ACCUWEATHER_API_KEY=your_api_key_here

然后直接运行 MCP Weather 服务器:

npx -y @timlukahorstmann/mcp-weather

或者,通过超级网关进行 HTTP/REST 访问:

npx -y supergateway --stdio "npx -y @timlukahorstmann/mcp-weather" \
  --port 4004 \
  --baseUrl http://127.0.0.1:4004 \
  --ssePath /messages \
  --messagePath /message \
  --cors "*" \
  --env ACCUWEATHER_API_KEY="$ACCUWEATHER_API_KEY"

Related MCP server: Weather MCP Server

MCP 服务器配置示例

为了与 Claude Desktop 或其他 MCP 兼容客户端集成,请将其添加到您的配置中(例如claude_desktop_config.json ):

{
  "mcpServers": {
    "weather": {
      "command": "npx",
      "args": ["-y", "@timlukahorstmann/mcp-weather"],
      "env": {
        "ACCUWEATHER_API_KEY": "your_api_key_here"
      }
    }
  }
}

概述

该 MCP 服务器允许大型语言模型(例如 Claude)访问实时天气数据。与 LLM 集成后,该服务器可使模型实现以下功能:

  • 获取准确、最新的天气预报

  • 提供未来 12 小时每小时的天气数据

  • 获取长达 15 天的每日天气预报

  • 以公制(°C)和英制(°F)单位显示数据

  • 查看温度、天气状况、降水信息和其他天气详情

先决条件

  • Node.js ≥18

  • AccuWeather API 密钥(通过.env或您的 shell 设置)

设置

  1. 克隆此存储库:

    git clone https://github.com/TimLukaHorstmann/mcp-weather.git
    cd mcp-weather
  2. 安装依赖项:

    npm install
  3. 获取 AccuWeather API 密钥:

  4. 使用您的 API 密钥创建一个.env文件:

    ACCUWEATHER_API_KEY=your_api_key_here
  5. 构建项目:

    npm run build

与 Claude Desktop 一起使用

  1. 配置 Claude Desktop 以使用此 MCP 服务器:

    • 打开 Claude 桌面

    • 前往“设置”>“开发者”>“编辑配置”

    • 将以下内容添加到您的claude_desktop_config.json中:

    {
      "mcpServers": {
        "weather": {
          "command": "npx",
          "args": ["-y", "@timlukahorstmann/mcp-weather"],
          "env": {
            "ACCUWEATHER_API_KEY": "your_api_key_here"
          }
        }
      }
    }
  2. 重启Claude桌面

  3. 在新对话中,单击插头图标并选择“天气”以启用 MCP 服务器

  4. 现在你可以向克劳德询问天气预报,例如:

    • “纽约市每小时的天气预报是什么?”

    • “请告诉我伦敦未来五天的天气预报。”

    • “本周东京的天气是华氏多少度?”

    • “明天旧金山会下雨吗?”

可用工具

每小时天气预报

  • 工具名称: weather-get_hourly

  • 提供未来 12 小时的每小时预报

  • 参数:

    • sessionId (必需):会话的唯一标识符

    • location (必填):城市或地点名称

    • units (可选):“公制”(摄氏度,默认)或“英制”(华氏度)

每日天气预报

  • 工具名称: weather-get_daily

  • 提供长达 15 天的每日预报

  • 参数:

    • sessionId (必需):会话的唯一标识符

    • location (必填):城市或地点名称

    • days (可选):预测天数(1、5、10 或 15;默认为 5)

    • units (可选):“公制”(摄氏度,默认)或“英制”(华氏度)

发展

  • 安装开发依赖项: npm install

  • 检查你的代码: npm run lint

  • 构建: npm run build

  • 运行测试: npm test

  • 以开发模式启动: npm run dev

贡献

欢迎贡献代码!欢迎提交 Pull 请求。

未来的增强功能

我们始终致力于改进 MCP 天气服务器。以下是我们计划在未来版本中推出的一些功能:

  • **延长每小时预报:**超过 12 小时,例如 24 或 48 小时。

  • **天气警报:**与 AccuWeather 的恶劣天气警报 API 集成。

  • **位置自动完成:**通过自动完成建议改进位置搜索。

  • **历史天气数据:**了解过去的天气状况。

如果您对其他功能有想法,请随时提出问题!

执照

该项目根据 MIT 许可证获得许可 - 有关详细信息,请参阅LICENSE文件。

Available Tools

2 tools
weather-get_dailyA

Get daily weather forecast for up to 15 days

ParametersJSON Schema
NameRequiredDescriptionDefault
locationYesThe city or location for which to retrieve the weather forecast.
daysNoNumber of days to forecast (1, 5, 10, or 15). Default is 5.
unitsNoTemperature unit system (metric for Celsius, imperial for Fahrenheit). Default is metric.

TDQS

A3.8/5.0
Behavior3/5

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

There are no annotations, so the description carries the behavioral transparency burden. It communicates a read-only forecast lookup via 'Get' and adds the 15-day maximum, but it does not disclose response shape, potential errors, timezone behavior, or whether any authentication is needed. For a simple read operation this is acceptable but not thorough.

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 sentence with no wasted words. It front-loads the verb and resource and immediately gives the key constraint of 15 days.

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

Completeness4/5

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

For a simple weather lookup with three fully documented parameters, the description is largely complete and an agent can invoke the tool correctly. The only notable gap is that there is no output schema and the description does not hint at the shape of the returned forecast payload.

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%: location, days, and units are all clearly documented in the input schema. The description adds no additional parameter meaning, which is acceptable because the structured schema already handles the documentation fully.

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

Purpose5/5

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

The description explicitly states the action ('Get'), the resource ('daily weather forecast'), and the scope ('up to 15 days'). This clearly distinguishes it from the sibling tool weather-get_hourly without requiring any additional inference.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The word 'daily' and the tool name imply that this is for day-level forecasts rather than hourly ones, which is useful context. However, the description does not explicitly state when to use this tool versus weather-get_hourly or provide any exclusion criteria.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

weather-get_hourlyA

Get hourly weather forecast for the next 12 hours

ParametersJSON Schema
NameRequiredDescriptionDefault
locationYesThe city or location for which to retrieve the weather forecast.
unitsNoTemperature unit system (metric for Celsius, imperial for Fahrenheit). Default is metric.

TDQS

A3.8/5.0
Behavior3/5

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

With no annotations, the description carries the full burden of behavioral disclosure. It states the scope (hourly, next 12 hours) and implies a read-only operation, but does not mention return format, error behavior, or data source limitations. It is adequate but not rich.

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 concise sentence with no filler. It front-loads the core action and scope, making it easy for an agent to process quickly.

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

Completeness4/5

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

For a simple two-parameter tool, the description is largely complete: it states the forecast type, granularity, and time window. It does not describe the return payload, but no output schema exists and the tool's purpose is straightforward enough that an agent can infer expected weather data fields.

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 both parameters are already documented in the schema. The description adds no additional parameter-level details beyond what the schema provides, so the baseline score of 3 applies.

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

Purpose5/5

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

The description uses a specific verb ('Get') and resource ('hourly weather forecast') with a clear time bound ('next 12 hours'). This clearly distinguishes it from the sibling tool weather-get_daily, which is for daily forecasts.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The time range and 'hourly' granularity imply when to use this tool, but the description never explicitly names the alternative or states when to choose it instead. The guidance is present by inference, not direct instruction.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 2 tool updates
    • First observedweather-get_daily
    • First observedweather-get_hourly

TDQS

B3.2/5.0

Scored across 2 tools

Disambiguation5/5

The two tools have clearly distinct purposes: one provides daily forecasts for up to 15 days, while the other provides hourly forecasts for the next 12 hours. There is no overlap in functionality, and an agent can easily differentiate between them based on the time granularity and forecast duration.

Naming Consistency5/5

Both tools follow a consistent naming pattern with a prefix 'weather-' followed by a verb_noun structure (get_daily, get_hourly). This pattern is predictable and enhances readability, making it easy for agents to understand the tool's purpose at a glance.

Tool Count2/5

With only 2 tools, the server feels under-scoped for a weather domain. While the tools cover forecast retrieval, there are obvious gaps such as current weather conditions, historical data, or location-based searches, making the set too thin for comprehensive weather-related tasks.

Completeness2/5

The tool surface is severely incomplete for a weather server. It lacks essential operations like getting current weather, searching locations, or accessing historical data, which are core to weather applications. Agents will face dead ends when trying to perform basic weather queries beyond forecasts.

Maintenance

ActivityInactive
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    D
    maintenance
    A Model Context Protocol server that provides current weather information and 3-day forecasts for specified cities using the Open-Meteo API.
    1
    -
  • F
    license
    Not graded
    quality
    C
    maintenance
    A Model Context Protocol server that interfaces with OpenWeatherMap API to provide real-time weather information and forecasts for cities worldwide.
    -