weather-mcp

weather-mcp

Enables natural language queries for real-time weather and 16-day forecasts globally via Open-Meteo, with Chinese output and no API key needed.

Category
Visit Server

README

weather-mcp

一个用于查询天气的 MCP(Model Context Protocol) 服务,基于免费的 Open-Meteo 接口实现。

✅ 无需 API Key ✅ 支持全球任意地点 ✅ 实时天气 + 未来 16 天预报 ✅ 中文输出

LLM 客户端(Claude Desktop、Cursor、Cline 等)接入后,就能直接用自然语言问"北京现在多少度""东京未来三天天气怎么样"。


✨ 功能

工具 说明
get_current_weather 查询指定地点的实时天气(温度、体感、天气状况、湿度、风、观测时间)
get_weather_forecast 查询指定地点未来 1–16 天的逐日预报(天气、最高/最低温、降水)
  • 支持城市名(如 北京、Shanghai、Tokyo)或经纬度(如 39.9,116.4)
  • 地点解析使用 Open-Meteo 地理编码接口,返回中文地名
  • WMO 天气代码已映射为中文描述,风向转换为中文方位

📦 安装

要求 Python ≥ 3.10。

方式一:用 uv(推荐)

uv tool install weather-mcp

或直接从源码安装:

git clone https://github.com/your-username/weather-mcp.git
cd weather-mcp
uv pip install -e .

方式二:用 pip

git clone https://github.com/your-username/weather-mcp.git
cd weather-mcp
pip install -e .

也可以不安装、直接用 requirements.txt:

pip install -r requirements.txt

🔌 接入 MCP 客户端

Claude Desktop

编辑配置文件(macOS:~/Library/Application Support/Claude/claude_desktop_config.json,Windows:%APPDATA%\Claude\claude_desktop_config.json):

{
  "mcpServers": {
    "weather": {
      "command": "weather-mcp"
    }
  }
}

如果是用 pip install -r requirements.txt 而非可编辑安装,请改用模块方式启动:

{
  "mcpServers": {
    "weather": {
      "command": "python",
      "args": ["-m", "weather_mcp"]
    }
  }
}

💡 在 VS Code / Cursor 中若使用 .venv,把 command 指向虚拟环境里的 python 或脚本路径即可。

Cursor / Cline / 其他支持 MCP 的客户端

配置方式类似,使用 stdio 传输,命令为 weather-mcp(或 python -m weather_mcp)。


🛠 本地开发

git clone https://github.com/your-username/weather-mcp.git
cd weather-mcp

# 创建虚拟环境并安装
python -m venv .venv
source .venv/bin/activate        # Windows: .venv\Scripts\activate
pip install -e .

# 以开发模式运行(带可视化调试界面)
mcp dev src/weather_mcp/server.py

# 直接启动 stdio 服务
python -m weather_mcp

项目结构

weather-mcp/
├── pyproject.toml          # 打包配置(hatchling)+ 入口脚本
├── requirements.txt        # 运行依赖
├── README.md
├── LICENSE                 # MIT
├── .gitignore
└── src/
    └── weather_mcp/
        ├── __init__.py
        ├── __main__.py     # python -m weather_mcp 入口
        ├── server.py       # MCP 服务与工具定义(FastMCP)
        └── weather.py      # Open-Meteo 接口封装与解析

📝 示例

接入后,你可以直接在对话里问:

  • "北京现在天气怎么样?"
  • "帮我查一下上海未来 5 天的天气预报"
  • "39.9,116.4 当前温度是多少?"

📄 许可证

MIT © weather-mcp contributors

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured