Weather query MCP server using OpenWeatherMap API
Wellknown found it in public sources; nobody has proven control of it yet. Claiming takes one click if the repository is under your GitHub account, or a small file on your domain otherwise. Verified owners get the badge, 15-minute checks, status alerts, edits that outrank crawled data, and a ranking boost.
Agents can do it too: POST https://wellknown.network/api/v1/claims with {"agent":"open-mcp-weather","method":"well_known_file"} — machine-readable steps at claim.json, guide at /docs/claim.
Everything here was measured by our prober or read from a registry. Nothing is self-reported.
Attributed to the source that supplied each field. Treated as claims, not facts.
# Weather MCP Server 一个基于 Model Context Protocol (MCP) 的天气查询服务器,使用 OpenWeatherMap API 提供实时天气信息和天气预报。 ## 功能特性 - 🌤️ **实时天气查询**: 获取指定城市的当前天气信息 - 📅 **5天天气预报**: 提供未来5天的详细天气预报 - 🌍 **全球支持**: 支持全球各地的天气查询 - 🌡️ **多单位支持**: 支持摄氏度(metric)和华氏度(imperial) - 📍 **智能定位**: 自动解析城市名称并获取准确坐标 - 🛠️ **MCP 工具装饰器**: 使用 `@mcp.tool()` 装饰器,便于其他模型通过 MCP 协议调用 ## 安装 1. 确保你已安装 Python 3.13 或更高版本 2. 克隆或下载此项目 3. 安装依赖: ```bash cd mcp-weather uv sync ``` ## 使用方法 ### 作为 MCP Server 运行 ```bash # 直接运行 python main.py # 或者使用 uv uv run main.py ``` ### 在 MCP 客户端中配置 在你的 MCP 客户端配置文件中添加: ```json { "mcpServers": { "weather": { "command": "python", "args": ["path/to/mcp-weather/main.py"] } } } ``` ### 编程方式调用工具 你也可以直接在代码中导入和使用这些工具: ```python import asyncio from main import get_current_weather, get_weather_forecast async def example(): # 获取当前天气 weather = await get_current_weather("Beijing,CN", "metric") print(weather) # 获取天气预报 forecast = await get_weather_forecast("London,GB", "metric") print(forecast) asyncio.run(example()) ``` ## 可用工具 ### 1. get_current_weather 获取指定位置的当前天气信息。 **参数:** - `location` (必需): 城市名称,格式如 "London,GB" 或 "Beijing,CN" - `units` (可选): 温度单位,"metric" (摄氏度) 或 "imperial" (华氏度),默认为 "metric" **示例:** ```json { "location": "Beijing,CN", "units": "metric" } ``` **返回信息:** - 当前温度 (实际温度和体感温度) - 天气状况描述 - 湿度百分比 - 气压 (hPa) - 风速和风向 - 能见度 - 日出日落时间 ### 2. get_weather_forecast 获取指定位置的5天天气预报。 **参数:** - `location` (必需): 城市名称,格式如 "London,GB" 或 "Beijing,CN" - `units` (可选): 温度单位,"metric" (摄氏度) 或 "imperial" (华氏度),默认为 "metric" **示例:** ```json { "location": "New York,US", "units": "imperial" } ``` **返回信息:** - 未来5天的每日天气预报 - 每日最高和最低温度 - 主要天气状况 ## 支持的城市格式 支持多种城市名称格式: - `"Beijing,CN"` - 城市名,国家代码 - `"London,GB"` - 城市名,国家代码 - `"New York,US"` - 城市名,国家代码 - `"Tokyo,JP"` - 城市名,国家代码 - `"Paris,FR"` - 城市名,国家代码 ##…
Mapped onto the structured taxonomy from declared text and observed tool names. Confidence shown for derived entries.
Every source is kept verbatim. Field changes are logged as events.