Skip to main content
Glama

control_device

Control SwitchBot smart devices by sending commands like turnOn or turnOff to manage home automation through the MCP server.

Instructions

デバイスを制御します

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
deviceIdYesデバイスID
commandYesコマンド(turnOn, turnOff)

Implementation Reference

  • Handler for the 'control_device' tool. Validates deviceId and command arguments, issues a POST request to the SwitchBot API endpoint `/devices/${deviceId}/commands` with the specified command, and returns the JSON response.
    case 'control_device': { const args = request.params.arguments; if (!args || typeof args.deviceId !== 'string' || typeof args.command !== 'string') { throw new McpError( ErrorCode.InvalidParams, 'デバイスIDとコマンドが必要です' ); } const response = await this.axiosInstance.post( `/devices/${args.deviceId}/commands`, { command: args.command, parameter: 'default', commandType: 'command', } ); return { content: [ { type: 'text', text: JSON.stringify(response.data, null, 2), }, ], }; }
  • src/index.ts:110-128 (registration)
    Registration of the 'control_device' tool in the server's tools list, including name, description, and input schema definition.
    { name: 'control_device', description: 'デバイスを制御します', inputSchema: { type: 'object', properties: { deviceId: { type: 'string', description: 'デバイスID', }, command: { type: 'string', description: 'コマンド(turnOn, turnOff)', enum: ['turnOn', 'turnOff'], }, }, required: ['deviceId', 'command'], }, },
  • Input schema for the 'control_device' tool, defining required deviceId (string) and command (string enum: turnOn/turnOff).
    inputSchema: { type: 'object', properties: { deviceId: { type: 'string', description: 'デバイスID', }, command: { type: 'string', description: 'コマンド(turnOn, turnOff)', enum: ['turnOn', 'turnOff'], }, }, required: ['deviceId', 'command'], },

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/genm/switchbot-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server