使用说明
天气应用程序
一个基于Python的天气应用程序,使用美国国家气象局(NWS)API提供天气信息。该项目使用现代Python工具构建,支持同步和异步HTTP请求。
特性
- 🌤️ 来自美国国家气象局API的实时天气数据
- 🚀 内置FastMCP,实现高效的服务器通信
- 📡 httpx支持HTTP客户端
- 🐍 现代Python 3.13+兼容性
- 🔧 易于设置和配置
先决条件
- Python 3.13或更高版本
- 紫外线 (推荐)或pip用于包管理
安装
-
克隆存储库:
git clone https://github.com/pro-gramming/weather-mcp-server.git cd weather -
安装依赖项:
使用紫外线(推荐):
uv sync使用pip:
pip install -e .
项目结构
weather/
├── main.py # Main application entry point
├── weather.py # Core weather functionality and API integration
├── pyproject.toml # Project configuration and dependencies
├── README.md # This file
└── uv.lock # Locked dependency versions
依赖项
- httpx (>=0.28.1):支持异步的Python现代HTTP客户端
- mcp[cli] (>=1.9.4):用于高效通信的FastMCP服务器框架
用法
基本用法
运行主应用程序:
python main.py
天气API集成
该项目旨在与美国国家气象局API整合:
# Example usage (to be implemented)
from weather import get_weather_data
# Get weather for specific coordinates
weather_info = await get_weather_data(latitude=40.7128, longitude=-74.0060)
API配置
该应用程序配置为使用美国国家气象局API:
- 基本URL:
https://api.weather.gov - 用户代理:
weather-app/1.0
发展
建立开发环境
-
安装开发依赖项:
uv sync --dev -
运行应用程序:
python main.py
项目配置
该项目使用 pyproject.toml 用于配置,包括:
- Python版本要求(>=3.13)
- 项目元数据
- 依赖关系规范
许可证
此项目根据MIT许可证获得许可-请参阅 许可证 文件以获取详细信息。