Skip to main content
Glama

🌤️ 天气 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: weather-mcp-server

📁 项目结构

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.txt

2. 运行 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(推荐)

  1. 在 Cursor 中打开此项目目录:

    File -> Open Folder -> weather-mcp-chatbot
  2. 项目中的 .cursor/mcp.json 文件会被 Cursor 自动检测到。

选项 B:在 Cursor 设置中添加

  1. 在 Cursor 中,打开 设置Ctrl + ,Cmd + ,)。

  2. 转到 功能 -> MCP 服务器

  3. 点击 添加新的 MCP 服务器

    • 名称weather

    • 类型command(stdio)

    • 命令python C:\Users\admin\.gemini\antigravity\scratch\weather-mcp-chatbot\weather_mcp_server.py

  4. 点击 保存 并验证绿色状态指示器。

在 Cursor Chat 中使用:

在 Cursor Composer 或 Chat 中,你现在可以询问:

  • “东京当前的天气如何?”

  • “使用 @weather 查看柏林 5 天预报”

  • “巴黎的空气质量如何?”

Cursor 将调用 MCP 工具(get_current_weatherget_weather_forecastget_air_quality)来获取实时数据!


🛠️ 暴露的 MCP 工具

工具名称

参数

描述

get_current_weather

city: strunits: str = "metric"

实时温度、天气状况、湿度、风速、气压

get_weather_forecast

city: strdays: int = 5units: str = "metric"

多日预报,包含每日最高/最低气温和降雨概率

get_air_quality

city: str

空气质量指数(美国与欧盟 AQI)、PM2.5、PM10、臭氧水平

F
license - not found
Not graded
quality - not tested
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

View all related MCP servers

Related MCP Connectors

  • Air Quality MCP — wraps air-quality-api.open-meteo.com (free, no auth)

  • OpenWeather MCP — wraps the OpenWeatherMap API (openweathermap.org)

  • Global weather via Open-Meteo: forecast, ERA5 archive, marine, air quality, geocoding, elevation.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/nateksharma4698-oss/weather-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server