Skip to main content
Glama

control_lights

Manage robot lighting by turning lights on or off using the robot's IP address. Integrates with the Opentrons MCP Server for direct control of Opentrons Flex and OT-2 robots.

Instructions

Turn robot lights on or off

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
onYesTrue to turn lights on, false to turn off
robot_ipYesRobot IP address

Implementation Reference

  • The handler function that implements the 'control_lights' tool logic. It makes a POST request to the Opentrons robot's /robot/lights API endpoint with the 'on' boolean parameter to turn the robot lights on or off.
    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:199-209 (registration)
    Tool registration in the ListToolsRequestSchema handler. Defines the tool name, description, and input schema for discovery by MCP clients.
    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)
    Handler dispatch in the CallToolRequestSchema switch statement that routes 'control_lights' calls to the controlLights method.
    case "control_lights": return this.controlLights(args);
  • Generic helper method for making authenticated HTTP requests to the Opentrons robot API, used by the control_lights handler.
    async makeApiRequest(method, url, headers = {}, body = null) { try { const options = { method, headers: { 'Opentrons-Version': '*', ...headers } }; if (body) { options.body = body; } const response = await fetch(url, options); const data = await response.json(); if (!response.ok) { throw new Error(`API Error ${response.status}: ${data.message || JSON.stringify(data)}`); } return data; } catch (error) { if (error.code === 'ECONNREFUSED') { throw new Error(`Cannot connect to robot. Please check the IP address and ensure the robot is powered on.`); } throw error; } }
  • Schema definition of the underlying Opentrons API endpoint POST /robot/lights that the tool calls, stored in the endpoints data structure.
    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" } } }

Other Tools

Related Tools

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/yerbymatey/opentrons-mcp'

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