control_lights
Control lighting on Opentrons Flex and OT-2 robots by turning lights on or off using the robot's IP address.
Instructions
Turn robot lights on or off
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| robot_ip | Yes | Robot IP address | |
| on | Yes | True to turn lights on, false to turn off |
Implementation Reference
- index.js:1982-2013 (handler)The handler function that executes the tool logic by making a POST request to the robot's /robot/lights endpoint with the 'on' parameter.async controlLights(args) { const { robot_ip, on } = args; try { const body = { on }; const data = await this.makeApiRequest( 'POST', `http://${robot_ip}:31950/robot/lights`, { 'Content-Type': 'application/json' }, JSON.stringify(body) ); return { content: [ { type: "text", text: `✅ Lights turned ${on ? 'ON' : 'OFF'} successfully!` } ] }; } catch (error) { return { content: [ { type: "text", text: `❌ Failed to control lights: ${error.message}` } ] }; } }
- index.js:198-209 (schema)The tool schema definition provided in the ListTools response, specifying name, description, and input schema.{ name: "control_lights", description: "Turn robot lights on or off", inputSchema: { type: "object", properties: { robot_ip: { type: "string", description: "Robot IP address" }, on: { type: "boolean", description: "True to turn lights on, false to turn off" } }, required: ["robot_ip", "on"] } },
- index.js:264-265 (registration)Registration of the tool handler in the CallToolRequestSchema switch statement.case "control_lights": return this.controlLights(args);
- index.js:483-495 (helper)API endpoint documentation for POST /robot/lights used by the control_lights tool.{ method: "POST", path: "/robot/lights", summary: "Control lights", description: "Turn rail lights on or off", tags: ["Control"], requestBody: { required: true, properties: { on: { type: "boolean", description: "True to turn lights on, false to turn off" } } } },