SwitchBot is an MCP server that connects large language model interfaces to the official SwitchBot Open API. It is used by developers, home automation enthusiasts, and smart home operators who want to query and control IoT hardware directly from AI assistants. The server provides a standard Model Context Protocol interface supporting both stdio and Streamable HTTP transports. Through this connection, assistants can enumerate discovered devices, read current sensor and device states, toggle power, send low-level hardware commands, and execute preset scenes configured in the SwitchBot mobile app. To protect user privacy and network integrity, the integration implements native fetch validation, in-memory caching for device listings, redacted operational logs on standard error, and strict Host and Origin validation for HTTP deployments. It does not persist credentials or device telemetry, communicating directly with official SwitchBot API endpoints to automate smart home workflows.
Category: Cloud & Infrastructure
Tags: automation, iot, smart-home, switchbot
Follow these steps to set up and configure the server for your MCP client. 1. Clone the repository and build the project from source: bash git clone https://github.com/genm/switchbot-mcp.git cd switchbot-mcp npm ci --ignore-scripts npm run build 2. Open your client configuration file, such as Claude Desktop's claude_desktop_config.json. 3. Add the server entry pointing to the local build path, replacing the placeholders with your credentials: json { "mcpServers": { "switchbot": { "command": "node", "args": ["/absolute/path/to/build/index.js"], "env": { "SWITCHBOT_TOKEN": "YOUR_SWITCHBOT_TOKEN", "SWITCHBOT_SECRET": "YOUR_SWITCHBOT_SECRET", "MCP_TRANSPORT": "stdio" } } } } 4. Alternatively, use VS Code by running: bash code --add-mcp '{"name":"switchbot","command":"npx","args":["-y","@genm-dev/switchbot-mcp"],"env":{"SWITCHBOT_TOKEN":"YOUR_SWITCHBOT_TOKEN","SWITCHBOT_SECRET":"YOUR_SWITCHBOT_SECRET","MCP_TRANSPORT":"stdio"}}' 5. Restart your MCP client to load the tools.
Part of MCP Servers
You can install it by cloning the repository from GitHub and running npm ci --ignore-scripts followed by npm run build. After building from source, configure your MCP client such as Claude Desktop or VS Code to run node pointing to the compiled build/index.js file with your SwitchBot token and secret environment variables.
The server exposes seven tools to list discovered devices, check individual device statuses, toggle power states, dispatch raw control commands, view configured scenes, and execute scenes through the official SwitchBot Open API.
SwitchBot works with any client supporting the Model Context Protocol, including Claude Desktop, VS Code with the MCP extension, Cursor, and the MCP Inspector for manual local debugging.
Yes, SwitchBot is open source software published under the ISC license. The source code, issue tracker, and documentation are publicly available on GitHub.