Skip to main content
Glama

toggle_device_power

Control power for Bond Bridge smart home devices by toggling them on or off using their device identifier.

Instructions

Toggle power state of a Bond device (on/off).

Args: device_id: The Bond device identifier

Returns: Result of the toggle operation.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
device_idYes

Implementation Reference

  • The @mcp.tool()-decorated async function that implements the toggle_device_power tool logic: retrieves current device state, toggles power by calling turn_on or turn_off on the BondClient, and returns the result or error.
    @mcp.tool() async def toggle_device_power(device_id: str) -> Dict[str, Any]: """Toggle power state of a Bond device (on/off). Args: device_id: The Bond device identifier Returns: Result of the toggle operation. """ try: async with await get_bond_client() as client: # Get current state to determine action current_state = await client.get_device_state(device_id) power = current_state.get("power", 0) if power == 1: result = await client.turn_off(device_id) action = "turned off" else: result = await client.turn_on(device_id) action = "turned on" return { "device_id": device_id, "action": action, "result": result } except BondAPIError as e: return {"error": f"Failed to toggle device power: {str(e)}"} except Exception as e: logger.error(f"Unexpected error toggling device power: {e}") return {"error": f"Unexpected error: {str(e)}"}
  • The @mcp.tool() decorator registers the toggle_device_power function as an MCP tool.
    @mcp.tool()

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/madorn/bond-mcp-server'

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