JSPM

@mariox/weather-mcp-server

1.0.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 7
  • Score
    100M100P100Q39388F
  • License MIT

MCP server for querying weather by current IP location using Open-Meteo free API

Package Exports

  • @mariox/weather-mcp-server
  • @mariox/weather-mcp-server/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@mariox/weather-mcp-server) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Weather MCP Server

一个基于 Model Context Protocol (MCP) 的天气查询服务器,可以查询当前 IP 地址的天气信息。使用免费的 Open-Meteo API,无需注册或 API 密钥。

功能特性

  • 🌍 自动获取当前 IP 位置信息:自动识别用户的地理位置
  • 🌤️ 当前 IP 天气查询:根据当前 IP 地址获取实时天气信息
  • 📍 经纬度天气查询:支持按坐标查询天气信息
  • 📅 天气预报:支持未来7天天气预报
  • 🆓 完全免费:使用 Open-Meteo 免费 API,无需注册
  • 🚀 即装即用:一行命令安装,无需额外配置

可用工具

  1. get_current_ip_weather - 获取当前IP地址的天气信息
  2. get_weather_by_coordinates - 根据经纬度获取天气信息
  3. get_current_ip_info - 获取当前IP地址的详细信息
  4. get_weather_forecast - 获取天气预报(未来7天)

快速开始

方法一:通过 npm 安装(推荐)

# 全局安装
npm install -g @mariox/weather-mcp-server

# 或者使用 npx(无需全局安装)
npx @mariox/weather-mcp-server

方法二:本地开发

# 克隆仓库
git clone https://github.com/mariox/weather-mcp-server.git
cd weather-mcp-server

# 安装依赖
npm install

# 启动服务器
npm start

MCP 客户端配置

Claude Desktop 配置

在 Claude Desktop 的配置文件中添加以下内容:

Windows: %APPDATA%\Claude\claude_desktop_config.json macOS: ~/Library/Application Support/Claude/claude_desktop_config.json Linux: ~/.config/claude/claude_desktop_config.json

{
  "mcpServers": {
    "weather": {
      "command": "npx",
      "args": ["@mariox/weather-mcp-server"]
    }
  }
}

Cursor 配置

在 Cursor 的 MCP 配置中添加:

{
  "mcpServers": {
    "weather": {
      "command": "npx",
      "args": ["-y", "@mariox/weather-mcp-server"]
    }
  }
}

其他 MCP 客户端配置

对于支持 MCP 的其他客户端,使用以下通用配置:

{
  "mcpServers": {
    "weather": {
      "command": "npx",
      "args": ["@mariox/weather-mcp-server"],
      "env": {}
    }
  }
}

本地开发配置

如果您是从源码本地运行,请使用:

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

配置验证

配置完成后,重启您的 MCP 客户端,您应该能看到以下工具可用:

  • get_current_ip_weather - 获取当前位置天气
  • get_weather_by_coordinates - 根据坐标获取天气
  • get_current_ip_info - 获取IP位置信息
  • get_weather_forecast - 获取天气预报

使用示例

查询当前 IP 天气

获取当前IP的天气信息

查询指定坐标天气

查询北京的天气 (纬度: 39.9042, 经度: 116.4074)

获取天气预报

获取未来3天的天气预报

获取当前IP信息

显示我当前的IP地址和位置信息

故障排除

1. 工具无法识别

如果客户端显示 "No tools available":

  1. 确认已正确配置 claude_desktop_config.json 文件
  2. 重启 Claude Desktop 或相关客户端
  3. 检查 npm 包是否正确安装:npm list -g @mariox/weather-mcp-server

2. 网络连接问题

确保您的网络可以访问以下服务:

  • ip-api.com (IP地理位置服务)
  • api.open-meteo.com (天气数据服务)

3. Node.js 版本要求

确保 Node.js 版本 >= 18.0.0:

node --version

技术栈

  • 运行环境: Node.js 18+
  • MCP 协议: @modelcontextprotocol/sdk ^0.5.0
  • HTTP 客户端: axios ^1.6.0
  • 天气数据: Open-Meteo API(免费服务)
  • 地理位置: ip-api.com(免费服务)

API 数据源

  • IP 地理位置信息ip-api.com(免费服务,无需API密钥)
  • 天气数据Open-Meteo API(完全免费,无需注册)

许可证

MIT License - 详见 LICENSE 文件

贡献

欢迎提交 Issues 和 Pull Requests!

  1. Fork 本仓库
  2. 创建特性分支:git checkout -b feature/new-feature
  3. 提交更改:git commit -am 'Add new feature'
  4. 推送分支:git push origin feature/new-feature
  5. 提交 Pull Request

更新日志

v1.0.0 (2024-12-19)

  • 🎉 初始版本发布
  • ✨ 支持当前 IP 天气查询
  • ✨ 支持经纬度天气查询
  • ✨ 支持 IP 信息查询
  • ✨ 支持天气预报功能
  • 📦 发布到 npm: @mariox/weather-mcp-server

联系方式