hefeng-qweather-mcp


Namehefeng-qweather-mcp JSON
Version 0.3.2 PyPI version JSON
download
home_pageNone
Summary和风天气 MCP 服务 - 基于 Model Context Protocol 的天气数据查询服务
upload_time2025-10-30 03:10:24
maintainerNone
docs_urlNone
authorNone
requires_python>=3.11
licenseMIT
keywords weather mcp hefeng qweather climate
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 和风天气 MCP 服务

一个基于 Model Context Protocol (MCP) 的和风天气服务,提供天气预报、气象预警、空气质量、历史数据、天文信息等多种气象数据查询功能。

## 功能特性

- **天气预报**: 获取3-30天详细天气预报(支持3d/7d/10d/15d/30d)
- **气象预警**: 查询实时气象灾害预警信息
- **生活指数**: 获取各类生活指数预报,如洗车、穿衣、感冒等(16种指数)
- **空气质量**: 获取城市的空气质量指数(AQI)及主要污染物信息
- **逐小时预报**: 获取未来 24/72/168 小时逐小时天气(温度、天气状况、风力/风速/风向、相对湿度、气压、降水概率、露点、云量等)
- **实况天气**: 获取近实时天气(温度、体感温度、风、湿度、气压、降水量、能见度、露点、云量等)
- **历史数据**: 获取历史天气和空气质量数据(最多10天)
- **天文数据**: 获取日出日落时间、月相月升月落信息
- **分钟级预报**: 获取未来2小时5分钟级降水预报
- **双认证支持**: 支持 API KEY 和 JWT + EdDSA 数字签名认证
- **详细日志**: 完整的操作日志和错误处理

## 安装

```bash
uv tool install hefeng-qweather-mcp
```

或使用 pip 安装:

```bash
pip install hefeng-qweather-mcp
```

```env
# 推荐配置 - API KEY 认证(简单快捷)
HEFENG_API_HOST=你的API主机地址
HEFENG_API_KEY=你的API KEY

# 备用配置 - JWT 数字签名认证
# HEFENG_PROJECT_ID=你的项目ID
# HEFENG_KEY_ID=你的凭据ID
# HEFENG_PRIVATE_KEY_PATH=./ed25519-private.pem

# 可选:直接加载密钥内容,方便远程部署
# HEFENG_PRIVATE_KEY=
```

## 使用

### 快速开始

1. **配置环境变量**
   ```bash
   # 复制并编辑配置文件
   cp .env.example .env

   # 填入您的和风天气 API 配置
   # 推荐使用 API KEY 认证方式
   ```

2. **启动服务器**
   ```bash
   # STDIO 模式(推荐用于本地开发)
   hefeng-qweather-mcp stdio

   # HTTP 模式(推荐用于远程访问)
   hefeng-qweather-mcp http
   ```

### 运行模式

#### HTTP 模式

HTTP 模式提供 Web API 接口,适合远程访问和 Web 集成:

```bash
hefeng-qweather-mcp http
```

服务器启动后将在 `http://127.0.0.1:8000` 运行,MCP 端点为 `http://127.0.0.1:8000/mcp`。

**VS Code 配置:**
```json
{
  "servers": {
    "hefeng-qweather-mcp": {
      "url": "http://127.0.0.1:8000/mcp",
      "type": "http"
    }
  },
  "inputs": []
}
```

#### STDIO 模式

STDIO 模式通过标准输入输出通信,适合本地开发:

```bash
hefeng-qweather-mcp stdio
```

**VS Code 配置:**
```json
{
  "servers": {
    "hefeng-qweather-mcp": {
      "type": "stdio",
      "command": "hefeng-qweather-mcp stdio"
    }
  },
  "inputs": []
}
```

**使用 uv 运行:**
```json
{
  "servers": {
    "hefeng-qweather-mcp": {
      "type": "stdio",
      "command": "uvx hefeng-qweather-mcp stdio",
      "envFile": "${workspaceFolder}/.env"
    }
  },
  "inputs": []
}
```

### 管理服务器

#### 查看运行状态
```bash
# 查看后台进程
ps aux | grep hefeng-qweather-mcp
```

#### 停止服务器
```bash
# 停止所有模式
pkill -f hefeng-qweather-mcp

# 或分别停止
pkill -f "hefeng-qweather-mcp stdio"
pkill -f "hefeng-qweather-mcp http"
```

#### 验证配置

服务启动后,可以通过以下方式验证配置是否正确:

1. **检查日志输出** - 确认 API 主机和认证信息正确显示
2. **在 VS Code 中测试** - 使用 MCP 工具查询天气数据
3. **检查服务状态** - 确保服务正常运行无错误

如果遇到配置问题,请检查:

- 环境变量是否正确设置
- API KEY 是否有效且未过期
- 网络连接是否正常

### 使用示例

#### 天文数据查询示例

```python
# 查询北京今天的日出日落时间
get_astronomy_sun("北京", "20251029")
# 结果:日出 06:40, 日落 17:17

# 查询上海的月相信息
get_astronomy_moon("上海", "20251101")
# 结果:月升 13:24, 月落 23:09, 月相:上弦月

# 使用经纬度查询(全球任意地点)
get_astronomy_sun("116.41,39.92", "20251029")  # 北京坐标
get_astronomy_moon("121.47,31.23", "20251101")  # 上海坐标

# 查询未来日期的天文数据
get_astronomy_sun("广州", "20251225")  # 圣诞节
get_astronomy_moon("深圳", "20260101")  # 元旦
```

#### 多天天气预报示例

```python
# 查询不同天数的天气预报
get_weather("北京", "3d")   # 3天预报(默认)
get_weather("上海", "7d")   # 7天预报
get_weather("广州", "15d")  # 15天预报
get_weather("深圳", "30d")  # 30天预报
```

### 可用的 MCP 工具

您的 MCP 服务器提供以下天气查询工具:

#### 基础天气工具
- **`get_weather_now`** - 获取实时天气数据
  - 参数:`city`(城市名)或 `location`(位置ID/坐标)
  - 返回:温度、体感温度、天气状况、湿度、气压等

- **`get_weather`** - 获取天气预报
  - 参数:`city`(城市名)、`days`(预报天数:3d/7d/10d/15d/30d,默认3d)
  - 返回:指定天数的每日天气详情

- **`get_hourly_weather`** - 获取逐小时天气预报
  - 参数:`hours`(24h/72h/168h)、`city` 或 `location`
  - 返回:逐小时温度、天气、风力、湿度等

#### 空气质量工具
- **`get_air_quality`** - 获取实时空气质量
  - 参数:`city`(城市名)
  - 返回:AQI、污染物浓度、健康建议

- **`get_air_quality_history`** - 获取历史空气质量
  - 参数:`city`(城市名)、`days`(1-10天)
  - 返回:历史空气质量数据

#### 生活指数工具
- **`get_indices`** - 获取生活指数预报
  - 参数:`city`(城市名)、`days`(1d/3d)、`index_types`(指数类型)
  - 返回:16种生活指数(运动、洗车、穿衣、感冒等)

#### 预警和天文工具
- **`get_warning`** - 获取气象预警信息
  - 参数:`city`(城市名)
  - 返回:实时气象灾害预警

- **`get_astronomy_sun`** - 获取日出日落时间
  - 参数:`location`(城市名/LocationID/坐标)、`date`(yyyyMMdd格式,支持未来60天)
  - 返回:日出日落时间(支持全球任意地点)

- **`get_astronomy_moon`** - 获取月相和月升月落信息
  - 参数:`location`(城市名/LocationID/坐标)、`date`(yyyyMMdd格式,支持未来60天)
  - 返回:月升月落时间、24小时逐小时月相数据(含月相名称、照明度)

#### 历史和详细数据工具
- **`get_weather_history`** - 获取历史天气数据
  - 参数:`city` 或 `location`、`days`(1-10天)
  - 返回:历史天气数据

- **`get_minutely_5m`** - 获取分钟级降水预报
  - 参数:`location`(坐标或城市名)
  - 返回:未来2小时5分钟级降水数据

## 前置要求

- Python >= 3.11
- OpenSSL (用于生成密钥对)
- 和风天气开发者账号

## 开发

### 1. 克隆项目

```bash
git clone https://github.com/fengyucn/hefeng-qweather-mcp.git
cd hefeng-qweather-mcp
```

### 2. 安装依赖

使用 pip:

```bash
pip install -e .
```

或使用 uv (推荐):

```bash
uv sync
```

### 3. 获取和风天气 API 配置

#### 方式一:API KEY 认证(推荐)

1. 访问 [和风天气控制台](https://console.qweather.com/project/)
2. 注册/登录账号
3. 创建项目并获取 **API KEY**
4. 复制配置模板文件:

```bash
cp .env.example .env
```

1. 编辑 `.env` 文件:

```env
# API KEY 认证配置
HEFENG_API_HOST=你的API主机地址
HEFENG_API_KEY=你的API KEY
```

#### 方式二:JWT 数字签名认证(备用)

如果需要使用 JWT 认证:

1. 在和风天气控制台创建项目并记录 **Project ID**
2. 生成 EdDSA 密钥对:

```bash
openssl genpkey -algorithm ED25519 -out ed25519-private.pem \
&& openssl pkey -pubout -in ed25519-private.pem > ed25519-public.pem
```

3. 在控制台中创建数字签名凭据,上传公钥文件
4. 配置 `.env` 文件:

```env
# JWT 认证配置
HEFENG_API_HOST=你的API主机地址
HEFENG_PROJECT_ID=你的项目ID
HEFENG_KEY_ID=你的凭据ID
HEFENG_PRIVATE_KEY_PATH=./ed25519-private.pem
```

**注意:** 推荐优先使用 API KEY 认证,配置更简单。JWT 认证适合需要更高安全性的场景。

### 开发指南

1. **代码风格**: 项目使用 `ruff` 进行代码格式化和检查
2. **类型检查**: 使用 `mypy` 进行静态类型检查
3. **测试**: 建议为新功能添加相应的单元测试
4. **文档**: 确保所有新功能都有详细的 docstring 文档

## 版本历史

### v0.3.0 (最新)

- ✅ 新增天文数据接口:日出日落时间和月相月升月落
- ✅ 新增分钟级降水预报接口(未来2小时5分钟级)
- ✅ 支持多种天气预报时长:3d/7d/10d/15d/30d
- ✅ 支持24/72/168小时逐小时天气预报
- ✅ 完善历史数据查询(天气和空气质量,最多10天)
- ✅ 优化认证系统,优先使用API KEY认证
- ✅ 完善错误处理和日志记录

### v0.2.1

- 基础天气查询功能
- JWT数字签名认证支持
- 空气质量查询
- 生活指数查询

## 许可证

MIT License

## 贡献指南

我们欢迎任何形式的贡献!

### 提交 Issue

如果你发现了 bug 或有功能建议,请:

1. 查看现有的 Issue,避免重复提交
2. 使用清晰的标题和详细的描述
3. 如果是 bug 报告,请包含重现步骤和环境信息

## 相关链接

- [和风天气官网](https://www.qweather.com/)
- [和风天气开发者控制台](https://console.qweather.com/project/)
- [和风天气 API 文档](https://dev.qweather.com/docs/api/)
- [Model Context Protocol](https://modelcontextprotocol.io/)

## 联系方式

如有问题或建议,请通过以下方式联系:


- 🐛 Issues: [GitHub Issues](https://github.com/fengyucn/hefeng-qweather-mcp/issues)
- 💬 讨论: [GitHub Discussions](https://github.com/fengyucn/hefeng-qweather-mcp/discussions)

---

**免责声明**: 本项目仅供学习和研究使用,请遵守和风天气的服务条款和 API 使用规范。

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "hefeng-qweather-mcp",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": null,
    "keywords": "weather, mcp, hefeng, qweather, climate",
    "author": null,
    "author_email": "fengyucn <your-email@example.com>",
    "download_url": "https://files.pythonhosted.org/packages/f2/61/ad997aaf4899eae6a4d80d32fff10788a12dc209347d29a43a2950a89eeb/hefeng_qweather_mcp-0.3.2.tar.gz",
    "platform": null,
    "description": "# \u548c\u98ce\u5929\u6c14 MCP \u670d\u52a1\n\n\u4e00\u4e2a\u57fa\u4e8e Model Context Protocol (MCP) \u7684\u548c\u98ce\u5929\u6c14\u670d\u52a1\uff0c\u63d0\u4f9b\u5929\u6c14\u9884\u62a5\u3001\u6c14\u8c61\u9884\u8b66\u3001\u7a7a\u6c14\u8d28\u91cf\u3001\u5386\u53f2\u6570\u636e\u3001\u5929\u6587\u4fe1\u606f\u7b49\u591a\u79cd\u6c14\u8c61\u6570\u636e\u67e5\u8be2\u529f\u80fd\u3002\n\n## \u529f\u80fd\u7279\u6027\n\n- **\u5929\u6c14\u9884\u62a5**: \u83b7\u53d63-30\u5929\u8be6\u7ec6\u5929\u6c14\u9884\u62a5\uff08\u652f\u63013d/7d/10d/15d/30d\uff09\n- **\u6c14\u8c61\u9884\u8b66**: \u67e5\u8be2\u5b9e\u65f6\u6c14\u8c61\u707e\u5bb3\u9884\u8b66\u4fe1\u606f\n- **\u751f\u6d3b\u6307\u6570**: \u83b7\u53d6\u5404\u7c7b\u751f\u6d3b\u6307\u6570\u9884\u62a5\uff0c\u5982\u6d17\u8f66\u3001\u7a7f\u8863\u3001\u611f\u5192\u7b49\uff0816\u79cd\u6307\u6570\uff09\n- **\u7a7a\u6c14\u8d28\u91cf**: \u83b7\u53d6\u57ce\u5e02\u7684\u7a7a\u6c14\u8d28\u91cf\u6307\u6570\uff08AQI\uff09\u53ca\u4e3b\u8981\u6c61\u67d3\u7269\u4fe1\u606f\n- **\u9010\u5c0f\u65f6\u9884\u62a5**: \u83b7\u53d6\u672a\u6765 24/72/168 \u5c0f\u65f6\u9010\u5c0f\u65f6\u5929\u6c14\uff08\u6e29\u5ea6\u3001\u5929\u6c14\u72b6\u51b5\u3001\u98ce\u529b/\u98ce\u901f/\u98ce\u5411\u3001\u76f8\u5bf9\u6e7f\u5ea6\u3001\u6c14\u538b\u3001\u964d\u6c34\u6982\u7387\u3001\u9732\u70b9\u3001\u4e91\u91cf\u7b49\uff09\n- **\u5b9e\u51b5\u5929\u6c14**: \u83b7\u53d6\u8fd1\u5b9e\u65f6\u5929\u6c14\uff08\u6e29\u5ea6\u3001\u4f53\u611f\u6e29\u5ea6\u3001\u98ce\u3001\u6e7f\u5ea6\u3001\u6c14\u538b\u3001\u964d\u6c34\u91cf\u3001\u80fd\u89c1\u5ea6\u3001\u9732\u70b9\u3001\u4e91\u91cf\u7b49\uff09\n- **\u5386\u53f2\u6570\u636e**: \u83b7\u53d6\u5386\u53f2\u5929\u6c14\u548c\u7a7a\u6c14\u8d28\u91cf\u6570\u636e\uff08\u6700\u591a10\u5929\uff09\n- **\u5929\u6587\u6570\u636e**: \u83b7\u53d6\u65e5\u51fa\u65e5\u843d\u65f6\u95f4\u3001\u6708\u76f8\u6708\u5347\u6708\u843d\u4fe1\u606f\n- **\u5206\u949f\u7ea7\u9884\u62a5**: \u83b7\u53d6\u672a\u67652\u5c0f\u65f65\u5206\u949f\u7ea7\u964d\u6c34\u9884\u62a5\n- **\u53cc\u8ba4\u8bc1\u652f\u6301**: \u652f\u6301 API KEY \u548c JWT + EdDSA \u6570\u5b57\u7b7e\u540d\u8ba4\u8bc1\n- **\u8be6\u7ec6\u65e5\u5fd7**: \u5b8c\u6574\u7684\u64cd\u4f5c\u65e5\u5fd7\u548c\u9519\u8bef\u5904\u7406\n\n## \u5b89\u88c5\n\n```bash\nuv tool install hefeng-qweather-mcp\n```\n\n\u6216\u4f7f\u7528 pip \u5b89\u88c5\uff1a\n\n```bash\npip install hefeng-qweather-mcp\n```\n\n```env\n# \u63a8\u8350\u914d\u7f6e - API KEY \u8ba4\u8bc1\uff08\u7b80\u5355\u5feb\u6377\uff09\nHEFENG_API_HOST=\u4f60\u7684API\u4e3b\u673a\u5730\u5740\nHEFENG_API_KEY=\u4f60\u7684API KEY\n\n# \u5907\u7528\u914d\u7f6e - JWT \u6570\u5b57\u7b7e\u540d\u8ba4\u8bc1\n# HEFENG_PROJECT_ID=\u4f60\u7684\u9879\u76eeID\n# HEFENG_KEY_ID=\u4f60\u7684\u51ed\u636eID\n# HEFENG_PRIVATE_KEY_PATH=./ed25519-private.pem\n\n# \u53ef\u9009\uff1a\u76f4\u63a5\u52a0\u8f7d\u5bc6\u94a5\u5185\u5bb9\uff0c\u65b9\u4fbf\u8fdc\u7a0b\u90e8\u7f72\n# HEFENG_PRIVATE_KEY=\n```\n\n## \u4f7f\u7528\n\n### \u5feb\u901f\u5f00\u59cb\n\n1. **\u914d\u7f6e\u73af\u5883\u53d8\u91cf**\n   ```bash\n   # \u590d\u5236\u5e76\u7f16\u8f91\u914d\u7f6e\u6587\u4ef6\n   cp .env.example .env\n\n   # \u586b\u5165\u60a8\u7684\u548c\u98ce\u5929\u6c14 API \u914d\u7f6e\n   # \u63a8\u8350\u4f7f\u7528 API KEY \u8ba4\u8bc1\u65b9\u5f0f\n   ```\n\n2. **\u542f\u52a8\u670d\u52a1\u5668**\n   ```bash\n   # STDIO \u6a21\u5f0f\uff08\u63a8\u8350\u7528\u4e8e\u672c\u5730\u5f00\u53d1\uff09\n   hefeng-qweather-mcp stdio\n\n   # HTTP \u6a21\u5f0f\uff08\u63a8\u8350\u7528\u4e8e\u8fdc\u7a0b\u8bbf\u95ee\uff09\n   hefeng-qweather-mcp http\n   ```\n\n### \u8fd0\u884c\u6a21\u5f0f\n\n#### HTTP \u6a21\u5f0f\n\nHTTP \u6a21\u5f0f\u63d0\u4f9b Web API \u63a5\u53e3\uff0c\u9002\u5408\u8fdc\u7a0b\u8bbf\u95ee\u548c Web \u96c6\u6210\uff1a\n\n```bash\nhefeng-qweather-mcp http\n```\n\n\u670d\u52a1\u5668\u542f\u52a8\u540e\u5c06\u5728 `http://127.0.0.1:8000` \u8fd0\u884c\uff0cMCP \u7aef\u70b9\u4e3a `http://127.0.0.1:8000/mcp`\u3002\n\n**VS Code \u914d\u7f6e\uff1a**\n```json\n{\n  \"servers\": {\n    \"hefeng-qweather-mcp\": {\n      \"url\": \"http://127.0.0.1:8000/mcp\",\n      \"type\": \"http\"\n    }\n  },\n  \"inputs\": []\n}\n```\n\n#### STDIO \u6a21\u5f0f\n\nSTDIO \u6a21\u5f0f\u901a\u8fc7\u6807\u51c6\u8f93\u5165\u8f93\u51fa\u901a\u4fe1\uff0c\u9002\u5408\u672c\u5730\u5f00\u53d1\uff1a\n\n```bash\nhefeng-qweather-mcp stdio\n```\n\n**VS Code \u914d\u7f6e\uff1a**\n```json\n{\n  \"servers\": {\n    \"hefeng-qweather-mcp\": {\n      \"type\": \"stdio\",\n      \"command\": \"hefeng-qweather-mcp stdio\"\n    }\n  },\n  \"inputs\": []\n}\n```\n\n**\u4f7f\u7528 uv \u8fd0\u884c\uff1a**\n```json\n{\n  \"servers\": {\n    \"hefeng-qweather-mcp\": {\n      \"type\": \"stdio\",\n      \"command\": \"uvx hefeng-qweather-mcp stdio\",\n      \"envFile\": \"${workspaceFolder}/.env\"\n    }\n  },\n  \"inputs\": []\n}\n```\n\n### \u7ba1\u7406\u670d\u52a1\u5668\n\n#### \u67e5\u770b\u8fd0\u884c\u72b6\u6001\n```bash\n# \u67e5\u770b\u540e\u53f0\u8fdb\u7a0b\nps aux | grep hefeng-qweather-mcp\n```\n\n#### \u505c\u6b62\u670d\u52a1\u5668\n```bash\n# \u505c\u6b62\u6240\u6709\u6a21\u5f0f\npkill -f hefeng-qweather-mcp\n\n# \u6216\u5206\u522b\u505c\u6b62\npkill -f \"hefeng-qweather-mcp stdio\"\npkill -f \"hefeng-qweather-mcp http\"\n```\n\n#### \u9a8c\u8bc1\u914d\u7f6e\n\n\u670d\u52a1\u542f\u52a8\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u9a8c\u8bc1\u914d\u7f6e\u662f\u5426\u6b63\u786e\uff1a\n\n1. **\u68c0\u67e5\u65e5\u5fd7\u8f93\u51fa** - \u786e\u8ba4 API \u4e3b\u673a\u548c\u8ba4\u8bc1\u4fe1\u606f\u6b63\u786e\u663e\u793a\n2. **\u5728 VS Code \u4e2d\u6d4b\u8bd5** - \u4f7f\u7528 MCP \u5de5\u5177\u67e5\u8be2\u5929\u6c14\u6570\u636e\n3. **\u68c0\u67e5\u670d\u52a1\u72b6\u6001** - \u786e\u4fdd\u670d\u52a1\u6b63\u5e38\u8fd0\u884c\u65e0\u9519\u8bef\n\n\u5982\u679c\u9047\u5230\u914d\u7f6e\u95ee\u9898\uff0c\u8bf7\u68c0\u67e5\uff1a\n\n- \u73af\u5883\u53d8\u91cf\u662f\u5426\u6b63\u786e\u8bbe\u7f6e\n- API KEY \u662f\u5426\u6709\u6548\u4e14\u672a\u8fc7\u671f\n- \u7f51\u7edc\u8fde\u63a5\u662f\u5426\u6b63\u5e38\n\n### \u4f7f\u7528\u793a\u4f8b\n\n#### \u5929\u6587\u6570\u636e\u67e5\u8be2\u793a\u4f8b\n\n```python\n# \u67e5\u8be2\u5317\u4eac\u4eca\u5929\u7684\u65e5\u51fa\u65e5\u843d\u65f6\u95f4\nget_astronomy_sun(\"\u5317\u4eac\", \"20251029\")\n# \u7ed3\u679c\uff1a\u65e5\u51fa 06:40, \u65e5\u843d 17:17\n\n# \u67e5\u8be2\u4e0a\u6d77\u7684\u6708\u76f8\u4fe1\u606f\nget_astronomy_moon(\"\u4e0a\u6d77\", \"20251101\")\n# \u7ed3\u679c\uff1a\u6708\u5347 13:24, \u6708\u843d 23:09, \u6708\u76f8\uff1a\u4e0a\u5f26\u6708\n\n# \u4f7f\u7528\u7ecf\u7eac\u5ea6\u67e5\u8be2\uff08\u5168\u7403\u4efb\u610f\u5730\u70b9\uff09\nget_astronomy_sun(\"116.41,39.92\", \"20251029\")  # \u5317\u4eac\u5750\u6807\nget_astronomy_moon(\"121.47,31.23\", \"20251101\")  # \u4e0a\u6d77\u5750\u6807\n\n# \u67e5\u8be2\u672a\u6765\u65e5\u671f\u7684\u5929\u6587\u6570\u636e\nget_astronomy_sun(\"\u5e7f\u5dde\", \"20251225\")  # \u5723\u8bde\u8282\nget_astronomy_moon(\"\u6df1\u5733\", \"20260101\")  # \u5143\u65e6\n```\n\n#### \u591a\u5929\u5929\u6c14\u9884\u62a5\u793a\u4f8b\n\n```python\n# \u67e5\u8be2\u4e0d\u540c\u5929\u6570\u7684\u5929\u6c14\u9884\u62a5\nget_weather(\"\u5317\u4eac\", \"3d\")   # 3\u5929\u9884\u62a5\uff08\u9ed8\u8ba4\uff09\nget_weather(\"\u4e0a\u6d77\", \"7d\")   # 7\u5929\u9884\u62a5\nget_weather(\"\u5e7f\u5dde\", \"15d\")  # 15\u5929\u9884\u62a5\nget_weather(\"\u6df1\u5733\", \"30d\")  # 30\u5929\u9884\u62a5\n```\n\n### \u53ef\u7528\u7684 MCP \u5de5\u5177\n\n\u60a8\u7684 MCP \u670d\u52a1\u5668\u63d0\u4f9b\u4ee5\u4e0b\u5929\u6c14\u67e5\u8be2\u5de5\u5177\uff1a\n\n#### \u57fa\u7840\u5929\u6c14\u5de5\u5177\n- **`get_weather_now`** - \u83b7\u53d6\u5b9e\u65f6\u5929\u6c14\u6570\u636e\n  - \u53c2\u6570\uff1a`city`\uff08\u57ce\u5e02\u540d\uff09\u6216 `location`\uff08\u4f4d\u7f6eID/\u5750\u6807\uff09\n  - \u8fd4\u56de\uff1a\u6e29\u5ea6\u3001\u4f53\u611f\u6e29\u5ea6\u3001\u5929\u6c14\u72b6\u51b5\u3001\u6e7f\u5ea6\u3001\u6c14\u538b\u7b49\n\n- **`get_weather`** - \u83b7\u53d6\u5929\u6c14\u9884\u62a5\n  - \u53c2\u6570\uff1a`city`\uff08\u57ce\u5e02\u540d\uff09\u3001`days`\uff08\u9884\u62a5\u5929\u6570\uff1a3d/7d/10d/15d/30d\uff0c\u9ed8\u8ba43d\uff09\n  - \u8fd4\u56de\uff1a\u6307\u5b9a\u5929\u6570\u7684\u6bcf\u65e5\u5929\u6c14\u8be6\u60c5\n\n- **`get_hourly_weather`** - \u83b7\u53d6\u9010\u5c0f\u65f6\u5929\u6c14\u9884\u62a5\n  - \u53c2\u6570\uff1a`hours`\uff0824h/72h/168h\uff09\u3001`city` \u6216 `location`\n  - \u8fd4\u56de\uff1a\u9010\u5c0f\u65f6\u6e29\u5ea6\u3001\u5929\u6c14\u3001\u98ce\u529b\u3001\u6e7f\u5ea6\u7b49\n\n#### \u7a7a\u6c14\u8d28\u91cf\u5de5\u5177\n- **`get_air_quality`** - \u83b7\u53d6\u5b9e\u65f6\u7a7a\u6c14\u8d28\u91cf\n  - \u53c2\u6570\uff1a`city`\uff08\u57ce\u5e02\u540d\uff09\n  - \u8fd4\u56de\uff1aAQI\u3001\u6c61\u67d3\u7269\u6d53\u5ea6\u3001\u5065\u5eb7\u5efa\u8bae\n\n- **`get_air_quality_history`** - \u83b7\u53d6\u5386\u53f2\u7a7a\u6c14\u8d28\u91cf\n  - \u53c2\u6570\uff1a`city`\uff08\u57ce\u5e02\u540d\uff09\u3001`days`\uff081-10\u5929\uff09\n  - \u8fd4\u56de\uff1a\u5386\u53f2\u7a7a\u6c14\u8d28\u91cf\u6570\u636e\n\n#### \u751f\u6d3b\u6307\u6570\u5de5\u5177\n- **`get_indices`** - \u83b7\u53d6\u751f\u6d3b\u6307\u6570\u9884\u62a5\n  - \u53c2\u6570\uff1a`city`\uff08\u57ce\u5e02\u540d\uff09\u3001`days`\uff081d/3d\uff09\u3001`index_types`\uff08\u6307\u6570\u7c7b\u578b\uff09\n  - \u8fd4\u56de\uff1a16\u79cd\u751f\u6d3b\u6307\u6570\uff08\u8fd0\u52a8\u3001\u6d17\u8f66\u3001\u7a7f\u8863\u3001\u611f\u5192\u7b49\uff09\n\n#### \u9884\u8b66\u548c\u5929\u6587\u5de5\u5177\n- **`get_warning`** - \u83b7\u53d6\u6c14\u8c61\u9884\u8b66\u4fe1\u606f\n  - \u53c2\u6570\uff1a`city`\uff08\u57ce\u5e02\u540d\uff09\n  - \u8fd4\u56de\uff1a\u5b9e\u65f6\u6c14\u8c61\u707e\u5bb3\u9884\u8b66\n\n- **`get_astronomy_sun`** - \u83b7\u53d6\u65e5\u51fa\u65e5\u843d\u65f6\u95f4\n  - \u53c2\u6570\uff1a`location`\uff08\u57ce\u5e02\u540d/LocationID/\u5750\u6807\uff09\u3001`date`\uff08yyyyMMdd\u683c\u5f0f\uff0c\u652f\u6301\u672a\u676560\u5929\uff09\n  - \u8fd4\u56de\uff1a\u65e5\u51fa\u65e5\u843d\u65f6\u95f4\uff08\u652f\u6301\u5168\u7403\u4efb\u610f\u5730\u70b9\uff09\n\n- **`get_astronomy_moon`** - \u83b7\u53d6\u6708\u76f8\u548c\u6708\u5347\u6708\u843d\u4fe1\u606f\n  - \u53c2\u6570\uff1a`location`\uff08\u57ce\u5e02\u540d/LocationID/\u5750\u6807\uff09\u3001`date`\uff08yyyyMMdd\u683c\u5f0f\uff0c\u652f\u6301\u672a\u676560\u5929\uff09\n  - \u8fd4\u56de\uff1a\u6708\u5347\u6708\u843d\u65f6\u95f4\u300124\u5c0f\u65f6\u9010\u5c0f\u65f6\u6708\u76f8\u6570\u636e\uff08\u542b\u6708\u76f8\u540d\u79f0\u3001\u7167\u660e\u5ea6\uff09\n\n#### \u5386\u53f2\u548c\u8be6\u7ec6\u6570\u636e\u5de5\u5177\n- **`get_weather_history`** - \u83b7\u53d6\u5386\u53f2\u5929\u6c14\u6570\u636e\n  - \u53c2\u6570\uff1a`city` \u6216 `location`\u3001`days`\uff081-10\u5929\uff09\n  - \u8fd4\u56de\uff1a\u5386\u53f2\u5929\u6c14\u6570\u636e\n\n- **`get_minutely_5m`** - \u83b7\u53d6\u5206\u949f\u7ea7\u964d\u6c34\u9884\u62a5\n  - \u53c2\u6570\uff1a`location`\uff08\u5750\u6807\u6216\u57ce\u5e02\u540d\uff09\n  - \u8fd4\u56de\uff1a\u672a\u67652\u5c0f\u65f65\u5206\u949f\u7ea7\u964d\u6c34\u6570\u636e\n\n## \u524d\u7f6e\u8981\u6c42\n\n- Python >= 3.11\n- OpenSSL (\u7528\u4e8e\u751f\u6210\u5bc6\u94a5\u5bf9)\n- \u548c\u98ce\u5929\u6c14\u5f00\u53d1\u8005\u8d26\u53f7\n\n## \u5f00\u53d1\n\n### 1. \u514b\u9686\u9879\u76ee\n\n```bash\ngit clone https://github.com/fengyucn/hefeng-qweather-mcp.git\ncd hefeng-qweather-mcp\n```\n\n### 2. \u5b89\u88c5\u4f9d\u8d56\n\n\u4f7f\u7528 pip:\n\n```bash\npip install -e .\n```\n\n\u6216\u4f7f\u7528 uv (\u63a8\u8350):\n\n```bash\nuv sync\n```\n\n### 3. \u83b7\u53d6\u548c\u98ce\u5929\u6c14 API \u914d\u7f6e\n\n#### \u65b9\u5f0f\u4e00\uff1aAPI KEY \u8ba4\u8bc1\uff08\u63a8\u8350\uff09\n\n1. \u8bbf\u95ee [\u548c\u98ce\u5929\u6c14\u63a7\u5236\u53f0](https://console.qweather.com/project/)\n2. \u6ce8\u518c/\u767b\u5f55\u8d26\u53f7\n3. \u521b\u5efa\u9879\u76ee\u5e76\u83b7\u53d6 **API KEY**\n4. \u590d\u5236\u914d\u7f6e\u6a21\u677f\u6587\u4ef6\uff1a\n\n```bash\ncp .env.example .env\n```\n\n1. \u7f16\u8f91 `.env` \u6587\u4ef6\uff1a\n\n```env\n# API KEY \u8ba4\u8bc1\u914d\u7f6e\nHEFENG_API_HOST=\u4f60\u7684API\u4e3b\u673a\u5730\u5740\nHEFENG_API_KEY=\u4f60\u7684API KEY\n```\n\n#### \u65b9\u5f0f\u4e8c\uff1aJWT \u6570\u5b57\u7b7e\u540d\u8ba4\u8bc1\uff08\u5907\u7528\uff09\n\n\u5982\u679c\u9700\u8981\u4f7f\u7528 JWT \u8ba4\u8bc1\uff1a\n\n1. \u5728\u548c\u98ce\u5929\u6c14\u63a7\u5236\u53f0\u521b\u5efa\u9879\u76ee\u5e76\u8bb0\u5f55 **Project ID**\n2. \u751f\u6210 EdDSA \u5bc6\u94a5\u5bf9\uff1a\n\n```bash\nopenssl genpkey -algorithm ED25519 -out ed25519-private.pem \\\n&& openssl pkey -pubout -in ed25519-private.pem > ed25519-public.pem\n```\n\n3. \u5728\u63a7\u5236\u53f0\u4e2d\u521b\u5efa\u6570\u5b57\u7b7e\u540d\u51ed\u636e\uff0c\u4e0a\u4f20\u516c\u94a5\u6587\u4ef6\n4. \u914d\u7f6e `.env` \u6587\u4ef6\uff1a\n\n```env\n# JWT \u8ba4\u8bc1\u914d\u7f6e\nHEFENG_API_HOST=\u4f60\u7684API\u4e3b\u673a\u5730\u5740\nHEFENG_PROJECT_ID=\u4f60\u7684\u9879\u76eeID\nHEFENG_KEY_ID=\u4f60\u7684\u51ed\u636eID\nHEFENG_PRIVATE_KEY_PATH=./ed25519-private.pem\n```\n\n**\u6ce8\u610f\uff1a** \u63a8\u8350\u4f18\u5148\u4f7f\u7528 API KEY \u8ba4\u8bc1\uff0c\u914d\u7f6e\u66f4\u7b80\u5355\u3002JWT \u8ba4\u8bc1\u9002\u5408\u9700\u8981\u66f4\u9ad8\u5b89\u5168\u6027\u7684\u573a\u666f\u3002\n\n### \u5f00\u53d1\u6307\u5357\n\n1. **\u4ee3\u7801\u98ce\u683c**: \u9879\u76ee\u4f7f\u7528 `ruff` \u8fdb\u884c\u4ee3\u7801\u683c\u5f0f\u5316\u548c\u68c0\u67e5\n2. **\u7c7b\u578b\u68c0\u67e5**: \u4f7f\u7528 `mypy` \u8fdb\u884c\u9759\u6001\u7c7b\u578b\u68c0\u67e5\n3. **\u6d4b\u8bd5**: \u5efa\u8bae\u4e3a\u65b0\u529f\u80fd\u6dfb\u52a0\u76f8\u5e94\u7684\u5355\u5143\u6d4b\u8bd5\n4. **\u6587\u6863**: \u786e\u4fdd\u6240\u6709\u65b0\u529f\u80fd\u90fd\u6709\u8be6\u7ec6\u7684 docstring \u6587\u6863\n\n## \u7248\u672c\u5386\u53f2\n\n### v0.3.0 (\u6700\u65b0)\n\n- \u2705 \u65b0\u589e\u5929\u6587\u6570\u636e\u63a5\u53e3\uff1a\u65e5\u51fa\u65e5\u843d\u65f6\u95f4\u548c\u6708\u76f8\u6708\u5347\u6708\u843d\n- \u2705 \u65b0\u589e\u5206\u949f\u7ea7\u964d\u6c34\u9884\u62a5\u63a5\u53e3\uff08\u672a\u67652\u5c0f\u65f65\u5206\u949f\u7ea7\uff09\n- \u2705 \u652f\u6301\u591a\u79cd\u5929\u6c14\u9884\u62a5\u65f6\u957f\uff1a3d/7d/10d/15d/30d\n- \u2705 \u652f\u630124/72/168\u5c0f\u65f6\u9010\u5c0f\u65f6\u5929\u6c14\u9884\u62a5\n- \u2705 \u5b8c\u5584\u5386\u53f2\u6570\u636e\u67e5\u8be2\uff08\u5929\u6c14\u548c\u7a7a\u6c14\u8d28\u91cf\uff0c\u6700\u591a10\u5929\uff09\n- \u2705 \u4f18\u5316\u8ba4\u8bc1\u7cfb\u7edf\uff0c\u4f18\u5148\u4f7f\u7528API KEY\u8ba4\u8bc1\n- \u2705 \u5b8c\u5584\u9519\u8bef\u5904\u7406\u548c\u65e5\u5fd7\u8bb0\u5f55\n\n### v0.2.1\n\n- \u57fa\u7840\u5929\u6c14\u67e5\u8be2\u529f\u80fd\n- JWT\u6570\u5b57\u7b7e\u540d\u8ba4\u8bc1\u652f\u6301\n- \u7a7a\u6c14\u8d28\u91cf\u67e5\u8be2\n- \u751f\u6d3b\u6307\u6570\u67e5\u8be2\n\n## \u8bb8\u53ef\u8bc1\n\nMIT License\n\n## \u8d21\u732e\u6307\u5357\n\n\u6211\u4eec\u6b22\u8fce\u4efb\u4f55\u5f62\u5f0f\u7684\u8d21\u732e\uff01\n\n### \u63d0\u4ea4 Issue\n\n\u5982\u679c\u4f60\u53d1\u73b0\u4e86 bug \u6216\u6709\u529f\u80fd\u5efa\u8bae\uff0c\u8bf7\uff1a\n\n1. \u67e5\u770b\u73b0\u6709\u7684 Issue\uff0c\u907f\u514d\u91cd\u590d\u63d0\u4ea4\n2. \u4f7f\u7528\u6e05\u6670\u7684\u6807\u9898\u548c\u8be6\u7ec6\u7684\u63cf\u8ff0\n3. \u5982\u679c\u662f bug \u62a5\u544a\uff0c\u8bf7\u5305\u542b\u91cd\u73b0\u6b65\u9aa4\u548c\u73af\u5883\u4fe1\u606f\n\n## \u76f8\u5173\u94fe\u63a5\n\n- [\u548c\u98ce\u5929\u6c14\u5b98\u7f51](https://www.qweather.com/)\n- [\u548c\u98ce\u5929\u6c14\u5f00\u53d1\u8005\u63a7\u5236\u53f0](https://console.qweather.com/project/)\n- [\u548c\u98ce\u5929\u6c14 API \u6587\u6863](https://dev.qweather.com/docs/api/)\n- [Model Context Protocol](https://modelcontextprotocol.io/)\n\n## \u8054\u7cfb\u65b9\u5f0f\n\n\u5982\u6709\u95ee\u9898\u6216\u5efa\u8bae\uff0c\u8bf7\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u8054\u7cfb\uff1a\n\n\n- \ud83d\udc1b Issues: [GitHub Issues](https://github.com/fengyucn/hefeng-qweather-mcp/issues)\n- \ud83d\udcac \u8ba8\u8bba: [GitHub Discussions](https://github.com/fengyucn/hefeng-qweather-mcp/discussions)\n\n---\n\n**\u514d\u8d23\u58f0\u660e**: \u672c\u9879\u76ee\u4ec5\u4f9b\u5b66\u4e60\u548c\u7814\u7a76\u4f7f\u7528\uff0c\u8bf7\u9075\u5b88\u548c\u98ce\u5929\u6c14\u7684\u670d\u52a1\u6761\u6b3e\u548c API \u4f7f\u7528\u89c4\u8303\u3002\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "\u548c\u98ce\u5929\u6c14 MCP \u670d\u52a1 - \u57fa\u4e8e Model Context Protocol \u7684\u5929\u6c14\u6570\u636e\u67e5\u8be2\u670d\u52a1",
    "version": "0.3.2",
    "project_urls": {
        "Documentation": "https://github.com/fengyucn/hefeng-qweather-mcp#readme",
        "Homepage": "https://github.com/fengyucn/hefeng-qweather-mcp",
        "Issues": "https://github.com/fengyucn/hefeng-qweather-mcp/issues",
        "Repository": "https://github.com/fengyucn/hefeng-qweather-mcp.git"
    },
    "split_keywords": [
        "weather",
        " mcp",
        " hefeng",
        " qweather",
        " climate"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "9f04f7222b6d401616f33b5bd2b48e1f6112ccfd8867d10f7cca56f0b5202152",
                "md5": "bcc28f21282f53873e5d7512601caea7",
                "sha256": "9edef7c9c16742f4c7f1a7aef36d1406eead9227dfdddef5d16d178f407badf8"
            },
            "downloads": -1,
            "filename": "hefeng_qweather_mcp-0.3.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "bcc28f21282f53873e5d7512601caea7",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 13503,
            "upload_time": "2025-10-30T03:10:22",
            "upload_time_iso_8601": "2025-10-30T03:10:22.868278Z",
            "url": "https://files.pythonhosted.org/packages/9f/04/f7222b6d401616f33b5bd2b48e1f6112ccfd8867d10f7cca56f0b5202152/hefeng_qweather_mcp-0.3.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "f261ad997aaf4899eae6a4d80d32fff10788a12dc209347d29a43a2950a89eeb",
                "md5": "218c74e15e24a6ed95208e91e4c1e1b5",
                "sha256": "2798ec885308b88a78b962049877b302a30f5e366dbfe24a468ddb30805cab19"
            },
            "downloads": -1,
            "filename": "hefeng_qweather_mcp-0.3.2.tar.gz",
            "has_sig": false,
            "md5_digest": "218c74e15e24a6ed95208e91e4c1e1b5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 17034,
            "upload_time": "2025-10-30T03:10:24",
            "upload_time_iso_8601": "2025-10-30T03:10:24.992472Z",
            "url": "https://files.pythonhosted.org/packages/f2/61/ad997aaf4899eae6a4d80d32fff10788a12dc209347d29a43a2950a89eeb/hefeng_qweather_mcp-0.3.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-10-30 03:10:24",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "fengyucn",
    "github_project": "hefeng-qweather-mcp#readme",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "hefeng-qweather-mcp"
}
        
Elapsed time: 0.86046s