mcp wttr
一个简单的mcp服务器,用于从wttr.in返回天气数据。
通过以下方式制作 本指南.
该指南的原始实施方式是 天气.py.
wttr的实现是 wttr.py.
安装
uv venv
source .venv/bin/activate
uv sync
# or for all tooling
uv sync --all-groups添加MCP服务器-Gemini
mkdir -p ~/.gemini/extensions/wttr-extension
cat ~/.gemini/extensions/wttr-extension/gemini-extension.json
{
"name": "mcp-wttr",
"version": "1.0.0",
"mcpServers": {
"wttr": {
"command": "uv",
"args": [
"--directory",
"$(pwd)",
"run",
"wttr.py"
]
}
}
}
EOF调试
用以下命令运行mcp检查器
uv run mcp dev wttr.py示例-双子座
> Get weather in Bristol
╭───────────────────────────────────────────────────────────╮
│ ✔ get_city_weather (wttr MCP Server) {"city":"Bristol"} │
│ │
│ Temperature=+20°C │
│ Wind=↓15km/h │
│ Humidity=46% │
│ Pressure=1017hPa │
│ Precipitation=0.0mm │
│ Weather=Overcast │
│ UV Index=1 │
╰───────────────────────────────────────────────────────────╯
✦ The weather in Bristol is: Temperature=+20°C, Wind=↓15km/h,
Humidity=46%, Pressure=1017hPa, Precipitation=0.0mm,
Weather=Overcast, UV Index=1.╭──────────────────────────╮
│ > /ron_weather Bristol │
╰──────────────────────────╯
╭──────────────────────────────────────────────────────────╮
│ ✔ get_city_weather (wttr MCP Server) {"city":"Bristol"} │
│ │
│ Temperature=+20°C │
│ Wind=↓15km/h │
│ Humidity=46% │
│ Pressure=1017hPa │
│ Precipitation=0.0mm │
│ Weather=Overcast │
│ UV Index=1 │
╰──────────────────────────────────────────────────────────╯
✦ Great Odin's raven! Bristol, listen up! It's a balmy 20 degrees
out there, but don't let that overcast sky fool you. There's a
gentle breeze at 15km/h, just enough to keep things fresh
without messing up my magnificent hair. And the best part?
Not a single drop of rain! It's a great day for news, and a
great day for Bristol. I'm Ron Burgundy. Stay classy.工具
此项目使用ruff进行linting和格式化。
