weather-mcp
🌤️ 天气 MCP 服务器与 Cursor 聊天机器人界面
一个简单、完整的 Python 项目,实现了适用于 Cursor IDE 的 模型上下文协议(MCP) 天气服务器,并配有 聊天机器人 Web 界面,用于测试和与天气代理对话。
🌟 功能特性
🌐 MCP 服务器(
weather_mcp_server.py):基于 FastMCP 通过 stdio 传输构建。向 Cursor 和其他 MCP 客户端暴露天气工具。⚡ 免费实时天气(
weather_service.py):由 Open-Meteo 提供支持。无需 API 密钥。适用于全球任何城市。🤖 天气代理(
agent.py):将自然语言查询(“东京的天气”、“伦敦的 5 天预报”、“巴黎的空气质量”)转换为工具调用。💻 现代聊天机器人界面(
static/和app.py):深色模式、玻璃拟态 Web 界面,带有可视化天气卡片、预报表格和工具执行徽章。🔌 Cursor 集成(
.cursor/mcp.json):为 Cursor 设置预配置的 JSON。
Related MCP server: bridgemcp-server-weather
📁 项目结构
weather-mcp-chatbot/
│── .cursor/
│ └── mcp.json # Cursor MCP configuration
│── weather_service.py # Free Open-Meteo weather & geocoding integration
│── weather_mcp_server.py # MCP Server (stdio transport for Cursor)
│── agent.py # Weather agent NLP & tool caller
│── app.py # FastAPI web server & chat endpoint
│── static/
│ ├── index.html # Chatbot UI
│ ├── style.css # Modern dark-mode styling
│ └── app.js # Chatbot frontend logic
│── test_mcp.py # Automated test suite
│── requirements.txt # Python dependencies
└── README.md # Documentation & quickstart🚀 快速开始
1. 安装依赖
pip install -r requirements.txt2. 运行 Web 聊天机器人界面
python app.py打开浏览器并导航至:http://127.0.0.1:8000
3. 运行自动化测试
python test_mcp.py🔌 如何与 Cursor 连接
Cursor 可以直接连接到你的 Python MCP 服务器,以在 Cursor Chat / Composer 中提供实时天气数据。
选项 A:使用 .cursor/mcp.json(推荐)
在 Cursor 中打开此项目目录:
File -> Open Folder -> weather-mcp-chatbot项目中的
.cursor/mcp.json文件会被 Cursor 自动检测到。
选项 B:在 Cursor 设置中添加
在 Cursor 中,打开 设置(
Ctrl + ,或Cmd + ,)。转到 功能 -> MCP 服务器。
点击 添加新的 MCP 服务器:
名称:
weather类型:
command(stdio)命令:
python C:\Users\admin\.gemini\antigravity\scratch\weather-mcp-chatbot\weather_mcp_server.py
点击 保存 并验证绿色状态指示器。
在 Cursor Chat 中使用:
在 Cursor Composer 或 Chat 中,你现在可以询问:
“东京当前的天气如何?”
“使用 @weather 查看柏林 5 天预报”
“巴黎的空气质量如何?”
Cursor 将调用 MCP 工具(get_current_weather、get_weather_forecast、get_air_quality)来获取实时数据!
🛠️ 暴露的 MCP 工具
工具名称 | 参数 | 描述 |
|
| 实时温度、天气状况、湿度、风速、气压 |
|
| 多日预报,包含每日最高/最低气温和降雨概率 |
|
| 空气质量指数(美国与欧盟 AQI)、PM2.5、PM10、臭氧水平 |
This server cannot be deployed
Maintenance
Related MCP Connectors
The official Model Context Protocol server for Ambee. It gives any MCP-compatible AI assistant — Claude, ChatGPT, Cursor, VS Code, Ollama, and more direct access to live air quality, pollen, and weather data. To get started, including information on signing up and obtaining your Ambee key, check out the Ambee documentation on https://docs.ambeedata.com
Weather, code search, currency & Solana trust scoring as MCP tools. Free, no API key needed.
Global weather via Open-Meteo: forecast, historical, marine, air quality, geocoding, elevation.
Weather MCP — wraps Open-Meteo API (free, no auth)
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables querying current weather, 7-day forecast, UV index, and air quality for any city using the free Open-Meteo API, without requiring an API key.22 npm-
- AlicenseNot gradedqualityCmaintenanceProvides weather data including current conditions, forecasts, and summaries via Open-Meteo with no API key required, enabling natural language queries through an MCP interface.MIT
- FlicenseAqualityCmaintenanceProvides current weather data for any city using the Open-Meteo API, exposed as an MCP tool for integration with MCP clients.1-
- AlicenseAqualityCmaintenanceEnables real-time weather forecasts for any city using the Open-Meteo API, with automatic geocoding and no API keys required.112 npmMIT