Skip to main content

Add your description here

Project description

mcp-server-weather

基于 Model Context Protocol (MCP) 的天气查询服务,支持通过 MCP 工具获取指定城市的实时天气、历史天气和时区时间信息。适用于 AI 助手、自动化脚本等场景。


特性

  • 查询任意城市的实时天气
  • 查询指定日期范围内的历史天气
  • 获取指定时区的当前时间
  • 支持 MCP 协议,易于集成

安装

推荐使用 pip 安装:

pip install .

或直接在本地开发环境运行:

python -m mcp_server_weather.server

获取和风天气 API Key

本服务依赖和风天气(QWeather)的 API Key。请按照以下步骤获取:

  1. 访问和风天气开发者平台:https://dev.qweather.com/docs/api/weather/weather-now
  2. 注册并登录账号。
  3. 创建项目并获取你的 API Key。
  4. 在服务配置或环境变量中填写你的 API Key。

详细开发配置和 API 使用说明请参考和风天气官方文档:和风天气开发文档


MCP 配置

在 Cursor、Claude Code 或其他支持 MCP 的客户端中,添加如下配置到 .cursor/mcp.json 或全局 MCP 配置文件:

uv 本地调试

{
  "mcpServers": {
    "weather": {
      "disabled": false,
      "timeout": 60,
      "type": "stdio",
      "command": "uv",
      "args": [
        "--directory",
        "/path/to/weather-python",
        "run",
        "main.py"
      ],
      "env": {
        "QWEATHER_API_KEY": "xxx",
        "QWEATHER_API_HOST": "https://xxx.re.qweatherapi.com"
      }
    }
  }
}

uvx


添加后,重启或刷新 MCP 设置即可。


工具参数说明

  • get_current_weather
    • city (string, 必填): 城市名称。例如:"beijing"、"上海"。

开发与贡献

欢迎提交 issue 和 PR 进行功能完善与 bug 修复。


参考资料

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pangerl_mcp_server_weather-0.1.1.tar.gz (19.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pangerl_mcp_server_weather-0.1.1-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file pangerl_mcp_server_weather-0.1.1.tar.gz.

File metadata

File hashes

Hashes for pangerl_mcp_server_weather-0.1.1.tar.gz
Algorithm Hash digest
SHA256 2db2e44bc7f52ef9d7126beb543e7207c6bac931c1dcc8834c2b110fb6cc85ac
MD5 0d80b20ce516c3c73a1f9809763df9c5
BLAKE2b-256 4a486af705775475bf44e9c79066a3c87057c984632ea97867aafd96631047ac

See more details on using hashes here.

File details

Details for the file pangerl_mcp_server_weather-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pangerl_mcp_server_weather-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 724f197a6d561e0a183d8f8444c5411763261c47c4e6ceee3ac68aaa6c00dbe2
MD5 d0f2c335849c6cd0eca73f55faad1297
BLAKE2b-256 4de71bfdcfe9934b0f1c66a821180e5534d02794eff50ca929da0bc1f8be3523

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page