Skip to main content
Glama

call_service_tool

Control smart home devices and automations by calling Home Assistant services with domain, service, and optional data parameters.

Instructions

Call any Home Assistant service (low-level API access)

Args: domain: The domain of the service (e.g., 'light', 'switch', 'automation') service: The service to call (e.g., 'turn_on', 'turn_off', 'toggle') data: Optional data to pass to the service (e.g., {'entity_id': 'light.living_room'})

Returns: The response from Home Assistant (usually empty for successful calls)

Examples: domain='light', service='turn_on', data={'entity_id': 'light.x', 'brightness': 255} domain='automation', service='reload' domain='fan', service='set_percentage', data={'entity_id': 'fan.x', 'percentage': 50}

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
domainYes
serviceYes
dataNo

Implementation Reference

  • The primary MCP tool handler function 'call_service_tool' that provides the interface for calling arbitrary Home Assistant services. Registered via @mcp.tool() decorator.
    @mcp.tool()
    @async_handler("call_service")
    async def call_service_tool(domain: str, service: str, data: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
        """
        Call any Home Assistant service (low-level API access)
        
        Args:
            domain: The domain of the service (e.g., 'light', 'switch', 'automation')
            service: The service to call (e.g., 'turn_on', 'turn_off', 'toggle')
            data: Optional data to pass to the service (e.g., {'entity_id': 'light.living_room'})
        
        Returns:
            The response from Home Assistant (usually empty for successful calls)
        
        Examples:
            domain='light', service='turn_on', data={'entity_id': 'light.x', 'brightness': 255}
            domain='automation', service='reload'
            domain='fan', service='set_percentage', data={'entity_id': 'fan.x', 'percentage': 50}
        
        """
        logger.info(f"Calling Home Assistant service: {domain}.{service} with data: {data}")
        return await call_service(domain, service, data or {})
  • Supporting helper function that performs the actual HTTP API call to Home Assistant's services endpoint. Imported and used by the main tool handler.
    async def call_service(domain: str, service: str, data: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
        """Call a Home Assistant service"""
        if data is None:
            data = {}
        
        client = await get_client()
        response = await client.post(
            f"{HA_URL}/api/services/{domain}/{service}", 
            headers=get_ha_headers(),
            json=data
        )
        response.raise_for_status()
        
        # Invalidate cache after service calls as they might change entity states
        global _entities_timestamp
        _entities_timestamp = 0
        
        return response.json()
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden. It discloses that this is a call/action tool (not read-only) and mentions the return behavior ('usually empty for successful calls'). However, it doesn't address important behavioral aspects like authentication requirements, error handling, rate limits, or whether calls are destructive/reversible.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with clear sections (purpose, args, returns, examples). Every sentence earns its place: the opening statement establishes purpose, parameter explanations are essential given 0% schema coverage, return behavior is important context, and examples demonstrate practical usage.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 3-parameter tool with no annotations and no output schema, the description does an excellent job covering parameters and basic behavior. However, it could provide more context about error conditions, side effects, or relationship to sibling tools. The examples help significantly, but some operational details remain unspecified.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage, the description fully compensates by explaining all three parameters in detail. It defines 'domain' and 'service' with examples, explains that 'data' is optional, and provides concrete examples showing how parameters work together. This adds significant value beyond the bare schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Call any Home Assistant service (low-level API access)'. It specifies the verb ('call') and resource ('Home Assistant service'), and distinguishes it from siblings by emphasizing it's for low-level API access rather than higher-level operations like entity actions or summaries.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for when to use this tool ('low-level API access'), but doesn't explicitly state when not to use it or name specific alternatives. Given the sibling tools include entity_action and other higher-level operations, the low-level distinction is helpful but could be more explicit about alternatives.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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/voska/hass-mcp'

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