wttr天气mcp
MCP(模型上下文协议)服务器,通过以下方式提供天气数据 wttr.in --支持多种输出格式的面向控制台的天气预报服务。
wttr.in从WorldWeatherOnline API获取数据,并将其呈现为纯文本、ANSI艺术或结构化JSON。此MCP服务器将wttr.in HTTP API封装到通过MCP stdio协议可访问的三个工具中。
工具
- get_current天气 --当前状况的单行摘要(温度、感觉、湿度、风)
- 获取预测 --使用ASCII艺术进行1-3天的文本预测
- get_weather_detailed --结构化JSON天气数据(温度、湿度、风、紫外线指数等)
所有工具都需要 location 参数(城市名称,例如“伦敦”、“纽约”、“东京”)。
安装
go install github.com/cherya/wttr-weather-mcp@latest二进制文件将被放置在 $GOPATH/bin/ (通常 ~/go/bin/).
从源代码构建
git clone https://github.com/cherya/wttr-weather-mcp.git
cd wttr-weather-mcp
go build -o wttr-weather-mcp .运行测试
go test -v ./...使用Claude代码
添加到MCP设置中:
{
"mcpServers": {
"wttr-weather": {
"command": "wttr-weather-mcp"
}
}
}确保 $GOPATH/bin 在你的 PATH,或使用二进制文件的完整路径。
依赖项
除了Go标准库之外没有。
