mcpField
W
weatherport

weatherport

本地服务
github.com/CloudCorpRecords地图与出行02 周前更新

关于 weatherport

weatherport 是用于查询 OpenWeather 的命令行工具和 stdio MCP 服务,支持城市天气、预报、坐标天气与空气质量数据,以及地理编码;调用需要 OpenWeather API 密钥。

主要功能

  1. 01查询城市当前天气
  2. 02获取五天逐三小时预报
  3. 03获取 One Call 3.0 天气摘要
  4. 04查询空气污染与 AQI
  5. 05将地名转换为坐标

适用场景

  1. 01查看某城市当前天气
  2. 02按三小时间隔查看天气预报
  3. 03查询指定坐标的空气质量
  4. 04将地点名称解析为坐标

MCP 相关

它可作为 stdio MCP 服务运行,向 MCP 客户端提供当前天气、预报、One Call 数据、空气污染和地理编码工具。

配置

本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。

mcp.json · 通用配置
{
"mcpServers": {
"cloudcorprecords-weatherport": {
"command": "npx",
"args": [
"-y",
"@reneturcios/weatherport"
]
}
}
}
启动命令npx -y @reneturcios/weatherport

本地服务需要在你的电脑上安装运行环境(如 Node.js 18+)。各客户端的配置文件位置不同,请参考客户端文档。

安装包
npm@reneturcios/weatherport0.1.0
ocighcr.io/cloudcorprecords/weatherport:0.1.0

工具

5

收录的工具列表 · 更新于 1 周前

参数类型必填说明
unitsstring否响应的单位制:standard、metric 或 imperial。
locationstring是要获取当前天气的城市或地点名称;必须为非空字符串。

详细介绍

weatherport

weatherport 将 OpenWeather 带到终端和 MCP 客户端中。 它可以回答人们实际会向这项服务提出的问题:某座城市 此刻的天气如何,未来五天每三小时的天气如何,地图上 某个精确点位的 One Call 3.0 完整视图显示了什么,那里的 空气质量如何,以及某个地名的确切位置在哪里?同一个 二进制文件既提供命令行界面,也提供 stdio MCP 服务。

每次调用都需要 OpenWeather API 密钥。将密钥放入 OPENWEATHER_API_KEY 环境变量中;weatherport 会将其作为 appid 查询参数发送到 https://api.openweathermap.org,且 绝不会打印密钥。如果变量缺失或为空,调用会在发出任何 请求之前失败,并报错指出该变量。请注意,One Call 3.0 实际上需要单独订阅上游服务,尽管它使用相同的密钥。

适用时,单位均为可选项:standard、metric 或 imperial。其他值会在发出请求之前被拒绝。

安装

npx @reneturcios/weatherport current Paris --units metric

也可以运行容器镜像:

docker run -i -e OPENWEATHER_API_KEY ghcr.io/cloudcorprecords/weatherport

容器默认启动 MCP 服务。传入 CLI 参数即可将其用作 CLI。

CLI

export OPENWEATHER_API_KEY=<your key>

weatherport current Paris --units metric
weatherport forecast Berlin --units imperial --count 5
weatherport onecall 51.5 -0.12 --units metric
weatherport pollution 51.5 -0.12
weatherport geocode Paris --limit 3

weatherport --version

每条命令都会打印上游 JSON 载荷。退出代码:成功时为 0, 调用失败时为 1(包括缺少 OPENWEATHER_API_KEY 或 API 错误),用法错误时为 2。

MCP 服务

npx -y @reneturcios/weatherport mcp

MCP 客户端配置:

{
  "mcpServers": {
    "weatherport": {
      "command": "npx",
      "args": ["-y", "@reneturcios/weatherport", "mcp"],
      "env": { "OPENWEATHER_API_KEY": "..." }
    }
  }
}
工具
工具输入返回内容
get_current_weatherlocation(必填)、units(可选)城市的当前天气。
get_forecastlocation(必填)、units、count(可选)未来 5 天每 3 小时的天气预报。
get_onecall_weatherlat、lon(必填)、units(可选)One Call 3.0 的当前、每小时和每日摘要。
get_air_pollutionlat、lon(必填)当前 AQI 和污染物成分。
geocode_locationquery(必填)、limit(可选)地名对应的坐标。

纬度必须在 [-90, 90] 范围内,经度必须在 [-180, 180] 范围内; 超出范围的值会在发出任何请求之前被拒绝。HTTP 失败会显示状态码;如果上游 JSON 中提供了 OpenWeather 的 message 字段,也会一并显示。

开发

npm install
npm run build   # tsc -> dist/
npm test        # node test runner over test/*.test.ts, no network (fake fetch fixtures)
npm run dev     # run the CLI from source via tsx

许可证

MIT — 详见 LICENSE。

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。