Skip to main content
Glama

led_control

Control LED lights on IoT devices through MQTT by setting them to on or off states using natural language commands.

Instructions

控制LED开关

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
stateYesLED状态(on/off)

Implementation Reference

  • Handler logic for the 'led_control' tool: validates the 'state' parameter to be 'on' or 'off', constructs the MQTT message 'LED {state}', and returns error if invalid.
    elif name == "led_control": state = arguments.get("state", "").lower() if state not in ["on", "off"]: return [types.TextContent( type="text", text="Error: State must be 'on' or 'off'" )] message = f"LED {state}"
  • Registers all tools including 'led_control' from config.tools, providing name, description, and dynamically constructed inputSchema based on tool parameters defined in config.yaml.
    for tool_name, tool_config in config.tools.items(): tools.append( types.Tool( name=tool_config.name, description=tool_config.description, inputSchema={ "type": "object", "properties": { param["name"]: { "type": param["type"], "description": param["description"], **({"enum": param["enum"]} if "enum" in param else {}) } for param in tool_config.parameters }, "required": [ param["name"] for param in tool_config.parameters if param.get("required", False) ] } ) ) return tools
  • Dynamically generates the input schema for 'led_control' (and other tools) from the parameters defined in the configuration file.
    inputSchema={ "type": "object", "properties": { param["name"]: { "type": param["type"], "description": param["description"], **({"enum": param["enum"]} if "enum" in param else {}) } for param in tool_config.parameters }, "required": [ param["name"] for param in tool_config.parameters if param.get("required", False) ] } ) ) return tools

Other 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/mcp2everything/mcp2mqtt'

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