天气信息服务器

一个通过Claude Desktop提供天气信息的模型上下文协议(MCP)服务器,支持获取任意城市或坐标的天气信息、自动定位天气以及OpenWeatherMap集成。

  • by Jayanth1312
  • TypeScript
  • 本地部署
  • 更新于
在 GitHub 查看 Jayanth1312/weather-mcp

使用说明

天气MCP服务器

一个通过Claude Desktop提供天气信息的模型上下文协议(MCP)服务器。

特点/特性

  • ☀️ 获取当前天气 - 获取任意城市或坐标的天气信息
  • 📍 自动定位天气 - 自动检测您的位置(基于IP或手动)
  • 🔄 翻译成中文是:循环(或“旋转”、“回转”等,具体根据上下文确定) 缓存 10分钟缓存以减少API调用
  • 🌐(表示互联网或全球网络的符号,可译为“互联网”或“全球网络”,但在此作为单独符号使用时,通常不直接翻译,而是保留原样或根据上下文意译为“网络世界”等) OpenWeatherMap 集成 - 可靠的天气数据

Claude桌面版快速设置

1. 克隆并安装

git clone https://github.com/Jayanth1312/weather-mcp.git
cd weather-mcp
npm install && npm run build

2. 获取OpenWeatherMap API密钥

在https://openweathermap.org/api获取免费的API密钥

3. 配置环境

创造 .env 文件:

# Required
OPENWEATHER_API_KEY=your_api_key_here

# Optional: For accurate "current location" weather (recommended)
# IP-based detection can be off by 50-200km
DEFAULT_LOCATION_CITY=YourCity
DEFAULT_LOCATION_COUNTRY=YourCountry
DEFAULT_LOCATION_COUNTRY_CODE=US
DEFAULT_LOCATION_TIMEZONE=America/New_York

4. 添加到Claude桌面配置

配置文件位置:

  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

添加此配置:

{
  "mcpServers": {
    "weather": {
      "command": "node",
      "args": ["/path/to/weather-mcp/dist/mcp/mcp-server.js"]
    }
  }
}

替换 /absolute/path/to/weather-mcp 使用你实际的路径(例如。, C:/Users/YourName/weather-mcp (在Windows上)。

5. 重启Claude桌面版

完全关闭并重新打开Claude桌面程序。

使用方法

问克劳德:

  • “伦敦的天气怎么样?”
  • “获取纽约的天气信息”
  • “我所在地的天气怎么样?”(使用您设置的城市或IP检测)
  • “这儿的天气怎么样?”

可用工具

get_current_weather

获取特定地点的天气信息。

  • 参数: city (可选), lat (可选), lon (可选)

get_current_location_weather

获取您当前位置的天气(自动检测或从 .env)。

  • 参数: 无

注: 基于IP的地理位置定位指向您的互联网服务提供商(ISP)的中心城市。设置 DEFAULT_LOCATION_CITY 在 .env 为了准确起见。