天气MCP工具(作者:@MrCare)
MCP 服务配置
复制以下 JSON 到 OPClaw 或其他 MCP 客户端的配置文件中即可使用
{
"mcpServers": {
"weather_fastmcp": {
"args": [
"-m",
"weather_server.server"
],
"command": "python"
}
}
}
该服务需要配置环境变量:OPENWEATHERMAP_API_KEY
可用工具 (2 个)
该服务在 MCP 协议中暴露的工具,AI 可按需调用
get_weather 3 个参数 需填 1 项
获取指定城市的天气信息 Args: city: 城市名称(支持中文或英文,如:苏州、suzhou) units: 温度单位 (metric: 摄氏度, imperial: 华氏度) lang: 返回语言 (zh_cn: 中文, en: 英文) Returns: WeatherData: 包含天气信息的对象
必填参数:city
get_weather_forecast 4 个参数 需填 1 项
获取指定城市的天气预报信息 Args: city: 城市名称(支持中文或英文,如:苏州、suzhou) days: 预报天数(最多5天) units: 温度单位 (metric: 摄氏度, imperial: 华氏度) lang: 返回语言 (zh_cn: 中文, en: 英文) Returns: dict: 包含天气预报信息的字典
必填参数:city
服务介绍
✨ Features
- 💡 Minimalist: One-line weather query
- 🤖 Smart: Natural language support in Chinese/English
- 🌏 Global: Support for all major cities
- 🔌 Plug & Play: Perfect Cursor integration
- 🚀 High Performance: Async processing, quick response
- 🎨 Beautiful: Clear and intuitive weather display
🚀 Quick Start
1. Get API Key
🔑 Before starting, please Get OpenWeather API Key
2. One-Click Installation (Recommended)
Install and configure with Smithery in one command:
npx -y @smithery/cli@latest install @MrCare/mcp_tool --client cursor --config "{\"openweathermapApiKey\":\"your_api_key_here\",\"port\":8000}"
For WindSurf and Cine installation, please visit our Smithery repository.
3. Manual Installation
3.1 Clone and Install
git clone https://github.com/yourusername/weather-server.git && cd weather-server && pip install -e .
3.2 Configure API Key
Method 1: Using Configuration File (Recommended)
Copy the example configuration file and modify it:
cp env.example .env
Then edit the .env file, replace your_api_key_here with your API Key.
Method 2: Using Environment Variables
macOS/Linux:
export OPENWEATHERMAP_API_KEY="your_api_key"
Windows:
set OPENWEATHERMAP_API_KEY=your_api_key
3.3 Enable Tool
Edit ~/.cursor/mcp.json (Windows: %USERPROFILE%\.cursor\mcp.json):
{
"weather_fastmcp": {
"command": "python",
"args": ["-m", "weather_server.server"]
}
}
Restart Cursor and you're ready to go!
📝 Usage Examples
Simply type in Cursor:
Show me the weather in Tokyo
What's the forecast for London?
How's the weather in New York?
Will it rain tomorrow in Paris?
That's it!
⚙️ Parameters
For more precise queries, you can specify these parameters:
| Parameter | Description | Default |
|---|---|---|
| city | City name (Chinese/English) | Required |
| days | Forecast days (1-5) | 5 |
| units | Temperature unit (metric: Celsius, imperial: Fahrenheit) | metric |
| lang | Response language (zh_cn: Chinese, en: English) | zh_cn |
❓ FAQ
-
Not Working?
- Ensure API Key is set correctly
- Restart Cursor
- Check Python environment
-
City Not Found?
- Try using English name
- Check spelling
- Use complete city name
👨💻 Author
- Mr.Car
- Email: 534192336car@gmail.com
🙏 Acknowledgments
📄 License
This project is licensed under the MIT License - see the LICENSE file for details