Skip to main content
Glama

domain_summary_tool

Summarize entities in a Home Assistant domain, providing total count, state distribution, examples, and common attributes to understand what is available before retrieving all entities.

Instructions

Get a summary of entities in a specific domain

Args: domain: The domain to summarize (e.g., 'light', 'switch', 'sensor') example_limit: Maximum number of examples to include for each state

Returns: A dictionary containing: - total_count: Number of entities in the domain - state_distribution: Count of entities in each state - examples: Sample entities for each state - common_attributes: Most frequently occurring attributes

Examples: domain="light" - get light summary domain="climate", example_limit=5 - climate summary with more examples Best Practices: - Use this before retrieving all entities in a domain to understand what's available

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
domainYes
example_limitNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The MCP tool handler registered as 'domain_summary'. It takes a domain (e.g., 'light') and an optional example_limit (default 3), logs the call, and delegates to the summarize_domain helper function.
    @mcp.tool()
    @async_handler("domain_summary")
    async def domain_summary_tool(domain: str, example_limit: int = 3) -> Dict[str, Any]:
        """
        Get a summary of entities in a specific domain
        
        Args:
            domain: The domain to summarize (e.g., 'light', 'switch', 'sensor')
            example_limit: Maximum number of examples to include for each state
        
        Returns:
            A dictionary containing:
            - total_count: Number of entities in the domain
            - state_distribution: Count of entities in each state
            - examples: Sample entities for each state
            - common_attributes: Most frequently occurring attributes
            
        Examples:
            domain="light" - get light summary
            domain="climate", example_limit=5 - climate summary with more examples
        Best Practices:
            - Use this before retrieving all entities in a domain to understand what's available    """
        logger.info(f"Getting domain summary for: {domain}")
        return await summarize_domain(domain, example_limit)
  • Core business logic for the tool. Fetches all entities for the given domain, counts state distribution, collects example entities per state (up to example_limit), and identifies the top 10 most common attributes. Returns the summarized dictionary.
    @handle_api_errors
    async def summarize_domain(domain: str, example_limit: int = 3) -> Dict[str, Any]:
        """
        Generate a summary of entities in a domain
        
        Args:
            domain: The domain to summarize (e.g., 'light', 'switch')
            example_limit: Maximum number of examples to include for each state
            
        Returns:
            Dictionary with summary information
        """
        entities = await get_entities(domain=domain)
        
        # Check if we got an error response
        if isinstance(entities, dict) and "error" in entities:
            return entities  # Just pass through the error
        
        try:
            # Initialize summary data
            total_count = len(entities)
            state_counts = {}
            state_examples = {}
            attributes_summary = {}
            
            # Process entities to build the summary
            for entity in entities:
                state = entity.get("state", "unknown")
                
                # Count states
                if state not in state_counts:
                    state_counts[state] = 0
                    state_examples[state] = []
                state_counts[state] += 1
                
                # Add examples (up to the limit)
                if len(state_examples[state]) < example_limit:
                    example = {
                        "entity_id": entity["entity_id"],
                        "friendly_name": entity.get("attributes", {}).get("friendly_name", entity["entity_id"])
                    }
                    state_examples[state].append(example)
                
                # Collect attribute keys for summary
                for attr_key in entity.get("attributes", {}):
                    if attr_key not in attributes_summary:
                        attributes_summary[attr_key] = 0
                    attributes_summary[attr_key] += 1
            
            # Create the summary
            summary = {
                "domain": domain,
                "total_count": total_count,
                "state_distribution": state_counts,
                "examples": state_examples,
                "common_attributes": sorted(
                    [(k, v) for k, v in attributes_summary.items()], 
                    key=lambda x: x[1], 
                    reverse=True
                )[:10]  # Top 10 most common attributes
            }
            
            return summary
        except Exception as e:
            return {"error": f"Error generating domain summary: {str(e)}"}
  • app/server.py:671-672 (registration)
    The @mcp.tool() decorator registers this function as an MCP tool. The @async_handler('domain_summary') decorator provides logging.
    @mcp.tool()
    @async_handler("domain_summary")
  • Input schema: domain (required string), example_limit (optional int, default 3). Output schema: dict with total_count, state_distribution, examples, and common_attributes.
    async def domain_summary_tool(domain: str, example_limit: int = 3) -> Dict[str, Any]:
        """
        Get a summary of entities in a specific domain
        
        Args:
            domain: The domain to summarize (e.g., 'light', 'switch', 'sensor')
            example_limit: Maximum number of examples to include for each state
        
        Returns:
            A dictionary containing:
            - total_count: Number of entities in the domain
            - state_distribution: Count of entities in each state
            - examples: Sample entities for each state
            - common_attributes: Most frequently occurring attributes
            
        Examples:
            domain="light" - get light summary
            domain="climate", example_limit=5 - climate summary with more examples
        Best Practices:
            - Use this before retrieving all entities in a domain to understand what's available    """
        logger.info(f"Getting domain summary for: {domain}")
        return await summarize_domain(domain, example_limit)
Behavior4/5

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

With no annotations, description carries full burden. It describes the tool as a read-summary operation with no side effects, and specifies the exact return structure (total_count, state_distribution, examples, common_attributes). No contradictions or missing critical behavioral details.

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?

Description is well-structured with a main sentence, Args, Returns, Examples, and Best Practices sections. Every section is informative and concise, no wasted words.

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

Completeness5/5

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

Given the simple tool with 2 parameters and an output schema, the description fully covers input semantics, output structure, and usage guidance. No missing elements.

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?

Schema has 0% description coverage, so description compensates by explaining 'domain' with examples and 'example_limit' with purpose and default context. The Args section adds meaning beyond type and default.

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?

Description clearly states the tool gets a summary of entities in a specific domain, using a specific verb and resource. It distinguishes from sibling tools like list_entities and get_entity by focusing on summary statistics.

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?

Includes a Best Practices section advising to use this before retrieving all entities, which provides clear context for when to use it. Does not explicitly contrast with sibling tools but implies an alternative.

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