内容
-swbot-mcp
SwitchBot API 的 MCP 服务器。设备以名称进行操作,因此 AI 不太可能因 ID 错误而导致操作失败。
## 安装
```bash
npm install -g ruru-swbot-mcp
```
## 环境变量
从 [SwitchBot 应用设置](https://support.switch-bot.com/hc/ja/articles/12822710195351) 获取令牌和密钥,并进行设置。
| 变量名 | 说明 |
| --- | --- |
| `SWITCHBOT_TOKEN` | SwitchBot API 令牌 |
| `SWITCHBOT_SECRET` | SwitchBot API 密钥 |
## MCP 设置
### Claude Code
```bash
claude mcp add switchbot -- npx ruru-swbot-mcp
```
### Claude Desktop
```json
{
"mcpServers": {
"switchbot": {
"command": "npx",
"args": ["ruru-swbot-mcp"],
"env": {
"SWITCHBOT_TOKEN": "<your-token>",
"SWITCHBOT_SECRET": "<your-secret>"
}
}
}
}
```
## 资源
| 资源名 | URI | 说明 |
| --- | --- | --- |
| `device_statuses` | `switchbot://devices/status` | 所有物理设备的当前状态(温度、湿度、电源等) |
## 工具
| 工具名 | 说明 |
| --- | --- |
| `list_devices` | 获取设备列表(名称、类型、可用命令) |
| `get_device_status` | 获取设备的当前状态 |
| `control_device` | 向设备发送命令 |
| `list_scenes` | 获取场景列表 |
| `execute_scene` | 执行场景 |
### 使用示例
```
1. 使用 list_devices 确认设备列表
2. 使用 get_device_status({ deviceName: "客厅照明" }) 获取状态
3. 使用 control_device({ deviceName: "客厅照明", command: "turnOn" }) 进行操作
```