Skip to content

Latest commit

 

History

History
139 lines (100 loc) · 3.64 KB

File metadata and controls

139 lines (100 loc) · 3.64 KB
Weather MCP Tool

Weather MCP Tool

一句话查询全球天气,完美集成 Cursor 编辑器的极简天气查询工具

smithery badge License: MIT Python Version

English | 中文

Weather MCP Tool 演示

看看如何用自然语言轻松查询天气

✨ 特性

  • 💡 极简: 一句话查询天气
  • 🤖 智能: 支持中英文自然语言交互
  • 🌏 全球: 支持所有主要城市
  • 🔌 即插即用: 完美集成 Cursor
  • 🚀 高性能: 异步处理,响应迅速
  • 🎨 美观: 清晰直观的天气展示

🚀 快速开始

1. 获取 API Key

🔑 在开始之前,请先 获取 OpenWeather API Key

2. 一键安装(推荐)

使用 Smithery 一键安装和配置:

npx -y @smithery/cli@latest install @MrCare/mcp_tool --client cursor --config "{\"openweathermapApiKey\":\"your_api_key_here\",\"port\":8000}"

如需安装 WindSurf 和 Cine 版本,请访问我们的 Smithery 仓库

3. 手动安装

3.1 克隆并安装

git clone https://github.com/yourusername/weather-server.git && cd weather-server && pip install -e .

3.2 配置 API Key

方法一:使用配置文件(推荐)

复制示例配置文件并修改:

cp env.example .env

然后编辑 .env 文件,将 your_api_key_here 替换为你的 API Key。

方法二:使用环境变量

macOS/Linux:

export OPENWEATHERMAP_API_KEY="your_api_key"

Windows:

set OPENWEATHERMAP_API_KEY=your_api_key

3.3 启用工具

编辑 ~/.cursor/mcp.json (Windows: %USERPROFILE%\.cursor\mcp.json):

{
    "weather_fastmcp": {
        "command": "python",
        "args": ["-m", "weather_server.server"]
    }
}

重启 Cursor 即可使用!

📝 使用示例

在 Cursor 中直接输入:

东京天气怎么样?
伦敦明天会下雨吗?
纽约的天气预报
巴黎今天温度多少?

就这么简单!

⚙️ 参数说明

如需更精确的查询,可以指定以下参数:

参数 说明 默认值
city 城市名称(支持中英文) 必填
days 预报天数(1-5天) 5
units 温度单位 (metric: 摄氏度, imperial: 华氏度) metric
lang 返回语言 (zh_cn: 中文, en: 英文) zh_cn

❓ 常见问题

  1. 工具不工作?

    • 确保 API Key 设置正确
    • 重启 Cursor
    • 检查 Python 环境
  2. 找不到城市?

    • 尝试使用英文名称
    • 检查拼写
    • 使用完整城市名

👨‍💻 作者

🙏 致谢

📄 许可证

本项目采用 MIT 许可证 - 详见 LICENSE 文件