在开始之前,请确保您已获得API访问权限。您可以在https://docs.caiyunapp.com/weather-api/申请。
首先安装uv。
MacOS/Linux:
curl -LsSf https://astral.sh/uv/install.sh | sh
Windows:
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
# claude_desktop_config.json
# 可以通过以下路径找到位置:
# 汉堡菜单 -> 文件 -> 设置 -> 开发者 -> 编辑配置
{
"mcpServers": {
"caiyun-weather": {
"command": "uvx",
"args": ["mcp-caiyun-weather"],
"env": {
"CAIYUN_WEATHER_API_TOKEN": "YOUR_API_KEY_HERE"
}
}
}
}
例如:"北京现在的天气怎么样?"
# claude_desktop_config.json
# 可以通过以下路径找到位置:
# 汉堡菜单 -> 文件 -> 设置 -> 开发者 -> 编辑配置
{
"mcpServers": {
"caiyun-weather": {
"command": "uv",
"args": [
"--directory",
"/ABSOLUTE/PATH/TO/PARENT/FOLDER/mcp-caiyun-weather",
"run",
"mcp-caiyun-weather"
],
"env": {
"CAIYUN_WEATHER_API_TOKEN": "YOUR_API_TOKEN_HERE"
}
}
}
}
运行:
npx @modelcontextprotocol/inspector \
uv \
--directory /ABSOLUTE/PATH/TO/PARENT/FOLDER/mcp-caiyun-weather \
run \
mcp-caiyun-weather
get_realtime_weather:获取特定地点的实时天气数据
lng:地点的经度lat:地点的纬度get_hourly_forecast:获取未来72小时每小时的天气预报
lng:地点的经度lat:地点的纬度get_weekly_forecast:获取未来7天每天的天气预报
lng:地点的经度lat:地点的纬度get_historical_weather:获取过去24小时的历史天气数据
lng:地点的经度lat:地点的纬度get_weather_alerts:获取特定地点的天气警报
lng:地点的经度lat:地点的纬度注意:所有工具都需要在环境变量CAIYUN_WEATHER_API_TOKEN中设置有效的彩云天气API令牌。