/ 目录 / 演练场 / weather-mcp-server
● 社区 ezh0v ⚡ 即开即用

weather-mcp-server

作者 ezh0v · ezh0v/weather-mcp-server

一个小巧的Go MCP,用WeatherAPI回答'X地天气怎样?'——一个工具、一个环境变量、零配置。

weather-mcp-server是一个最小化的Go服务器,暴露一个调用WeatherAPI.com的current_weather工具。适合作为'hello world' MCP演示、构建位置感知智能体的基础,或快速增加天气功能而不需要引入更重的地图MCP。

为什么要用

核心特性

实时演示

实际使用效果

weather.replay ▶ 就绪
0/0

安装

选择你的客户端

~/Library/Application Support/Claude/claude_desktop_config.json  · Windows: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "weather": {
      "command": "TODO",
      "args": [
        "See README: https://github.com/ezh0v/weather-mcp-server"
      ],
      "_inferred": true
    }
  }
}

打开 Claude Desktop → Settings → Developer → Edit Config。保存后重启应用。

~/.cursor/mcp.json · .cursor/mcp.json
{
  "mcpServers": {
    "weather": {
      "command": "TODO",
      "args": [
        "See README: https://github.com/ezh0v/weather-mcp-server"
      ],
      "_inferred": true
    }
  }
}

Cursor 使用与 Claude Desktop 相同的 mcpServers 格式。项目级配置优先于全局。

VS Code → Cline → MCP Servers → Edit
{
  "mcpServers": {
    "weather": {
      "command": "TODO",
      "args": [
        "See README: https://github.com/ezh0v/weather-mcp-server"
      ],
      "_inferred": true
    }
  }
}

点击 Cline 侧栏中的 MCP Servers 图标,然后选 "Edit Configuration"。

~/.codeium/windsurf/mcp_config.json
{
  "mcpServers": {
    "weather": {
      "command": "TODO",
      "args": [
        "See README: https://github.com/ezh0v/weather-mcp-server"
      ],
      "_inferred": true
    }
  }
}

格式与 Claude Desktop 相同。重启 Windsurf 生效。

~/.continue/config.json
{
  "mcpServers": [
    {
      "name": "weather",
      "command": "TODO",
      "args": [
        "See README: https://github.com/ezh0v/weather-mcp-server"
      ]
    }
  ]
}

Continue 使用服务器对象数组,而非映射。

~/.config/zed/settings.json
{
  "context_servers": {
    "weather": {
      "command": {
        "path": "TODO",
        "args": [
          "See README: https://github.com/ezh0v/weather-mcp-server"
        ]
      }
    }
  }
}

加入 context_servers。Zed 保存后热重载。

claude mcp add weather -- TODO 'See README: https://github.com/ezh0v/weather-mcp-server'

一行命令搞定。用 claude mcp list 验证,claude mcp remove 卸载。

使用场景

实战用法: weather-mcp-server

让你的个人助手具有天气意识

👤 任何使用Claude作为日常助手的人 ⏱ ~10 min beginner

何时使用: 你问Claude天气,它一直说'我没有实时数据'。5分钟内解决这个问题。

前置条件
  • WeatherAPI.com免费API密钥 — weatherapi.com/signup——每月免费100万次调用
步骤
  1. 配置和连接
    通过Docker安装weather-mcp-server,设置WEATHER_API_KEY=...,从Claude Desktop连接。✓ 已复制
    current_weather工具可见
  2. 自然提问
    东京现在天气怎样?散步需要带夹克吗?✓ 已复制
    → 实时条件+可行建议

结果: 无需单独应用即可即时查询天气。

注意事项
  • 免费层限制+这里没有预报端点 — 这个工具仅支持当前条件;使用weatherapi的REST API直接获取7天预报,或者切换到功能更丰富的weather MCP

为多个城市生成早晨出行简报

👤 经常出差的人、远程团队 ⏱ ~5 min beginner

何时使用: 你与4个时区的同事协调,想在早上9点的电话会议前知道纽约团队是否在暴风雪中。

步骤
  1. 逐城市查询
    获取纽约、伦敦、东京、圣保罗的当前天气。每个用一句话总结。✓ 已复制
    → 四城市简报

结果: 30秒内了解分布式团队的日常运营状况。

注意事项
  • 如果每分钟调用多个城市的API会触发速率限制 — 缓存15分钟;天气变化没那么快

组合

与其他 MCP 搭配,撬动十倍杠杆

weather + google-map

规划户外活动时同时考虑路线和天气

规划洛杉矶3个户外站点的路线。对每一个,也检查当前天气;如有降水则警告。✓ 已复制

工具

此 MCP 暴露的能力

工具输入参数何时调用成本
current_weather city: str 任何与天气相关的事情 1 WeatherAPI call (free up to 1M/mo)

成本与限制

运行它的成本

API 配额
WeatherAPI免费:每月100万次调用,10次/秒
每次调用 Token 数
每个响应约200个token
费用
个人使用免费;付费计划从$4/月起可获得更高层级
提示
缓存结果10-15分钟——天气变化没那么快。

安全

权限、密钥、影响范围

凭据存储: WEATHER_API_KEY环境变量
数据出站: 仅出站到api.weatherapi.com

故障排查

常见错误与修复

WeatherAPI返回401

WEATHER_API_KEY未设置或无效。在weatherapi.com/my/获取。

验证: curl 'http://api.weatherapi.com/v1/current.json?key=$KEY&q=London'
找不到城市

使用完整名称含国家:'Paris, France'而非'Paris'。或使用坐标'lat,lng'。

构建失败:go模块错误

需要Go 1.21+。用go version检查。或使用Docker镜像。

替代方案

weather-mcp-server 对比其他方案

替代方案何时用它替代权衡
Open-Meteo MCP你不想要任何API密钥免费、无需密钥,但需要经纬度(无城市名称地理编码)
National Weather Service MCP仅限美国,并且你想要预报+告警仅限美国;更丰富的数据

更多

资源

📖 阅读 GitHub 上的官方 README

🐙 查看未解决的 issue

🔍 浏览全部 400+ MCP 服务器和 Skills