🔑 在开始之前,请获取OpenWeather API密钥
通过Smithery在一条命令中完成安装和配置:
npx -y @smithery/cli@latest install @MrCare/mcp_tool --client cursor --config "{\"openweathermapApiKey\":\"your_api_key_here\",\"port\":8000}"
对于WindSurf和Cine的安装,请访问我们的Smithery仓库。
git clone https://github.com/yourusername/weather-server.git && cd weather-server && pip install -e .
方法1:使用配置文件(推荐)
复制示例配置文件并修改它:
cp env.example .env
然后编辑.env文件,将your_api_key_here替换为您的API密钥。
方法2:使用环境变量
macOS/Linux:
export OPENWEATHERMAP_API_KEY="your_api_key"
Windows:
set OPENWEATHERMAP_API_KEY=your_api_key
编辑~/.cursor/mcp.json(Windows:%USERPROFILE%.cursor\mcp.json):
{
"weather_fastmcp": {
"command": "python",
"args": ["-m", "weather_server.server"]
}
}
重启Cursor,现在可以使用了!
只需在Cursor中键入:
显示东京的天气
伦敦的预报是什么?
纽约的天气怎么样?
巴黎明天会下雨吗?
就是这样!
为了更精确的查询,您可以指定这些参数:
| 参数 | 描述 | 默认值 |
|---|---|---|
| 城市 | 城市名称(中文/英文) | 必填 |
| 天数 | 预报天数(1-5) | 5 |
| 单位 | 温度单位(metric:摄氏度,imperial:华氏度) | metric |
| 语言 | 返回语言(zh_cn:中文,en:英文) | zh_cn |
无法工作?
找不到城市?
本项目采用MIT许可证 - 查看LICENSE文件以获取详细信息