Skip to main content

mcp-server-weather

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


特性

  • 查询任意城市的实时天气
  • 支持 MCP 协议,易于集成

安装

推荐使用 pip 安装:

pip install .

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

python -m pangerl_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

{
  "mcpServers": {
    "weather": {
      "disabled": false,
      "timeout": 60,
      "type": "stdio",
      "command": "uvx",
      "args": [
        "pangerl-mcp-server-weather"
      ],
      "env": {
        "QWEATHER_API_KEY": "xxx",
        "QWEATHER_API_HOST": "https://xxx.re.qweatherapi.com"
      }
    }
  }
}

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


工具参数说明

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

开发与贡献

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


参考资料

Metadata

Release files for pangerl-mcp-server-weather 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pangerl-mcp-server-weather 0.1.2
File Size Uploaded Provenance Actions
pangerl_mcp_server_weather-0.1.2.tar.gz 19.7 kB Without provenance Details for pangerl_mcp_server_weather-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pangerl-mcp-server-weather 0.1.2
File Interpreter ABI Platform Actions
pangerl_mcp_server_weather-0.1.2-py3-none-any.whl Python 3 none any Details for pangerl_mcp_server_weather-0.1.2-py3-none-any.whl

Total release size: 24.1 kB

Release files / pangerl_mcp_server_weather-0.1.2.tar.gz

Download URL pangerl_mcp_server_weather-0.1.2.tar.gz
Size 19.7 kB
Tags Source
SHA-256 checksum
How to use checksums
53157cb421388d2ce72692967381b89e5d2ed8e2aa7a902e0231ab39c964c2eb
BLAKE2b-256 checksum
How to use checksums
7dc8cde0ef201a28430b7a5d8f2b4d17bb7e642739c8e82c2063023f14f09b89
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.6

Release files / pangerl_mcp_server_weather-0.1.2-py3-none-any.whl

Download URL pangerl_mcp_server_weather-0.1.2-py3-none-any.whl
Size 4.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ccecefc9c8c0257cbbfed11750bf736ba532fa85e9e72788195085a04fb8b2b8
BLAKE2b-256 checksum
How to use checksums
56af84ce48383984a1e4f2aa9584916887e0a8e5895b22cd477f3bc1e9ef778e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.6

Security for pangerl-mcp-server-weather 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page