Skip to main content
Glama
TheWhykiki

hass-mcp

by TheWhykiki

ha_get_state

Get the current state of a Home Assistant entity by supplying its entity ID. Enables real-time status retrieval for automation and monitoring.

Instructions

Get Home Assistant entity state by entity_id.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
entity_idYes

Implementation Reference

  • Handler function registered for the 'ha_get_state' tool. Calls ha.getState(input.entity_id) and returns the state as JSON text.
    server.tool(
      'ha_get_state',
      'Get Home Assistant entity state by entity_id.',
      GetStateInput.shape,
      async (input) => {
        const state = await ha.getState(input.entity_id)
        return {
          content: [{ type: 'text', text: JSON.stringify(state, null, 2) }],
        }
      },
    )
  • Input schema for ha_get_state: takes a required entity_id string.
    export const GetStateInput = z.object({
      entity_id: z.string().min(1),
    })
  • src/index.ts:61-71 (registration)
    Tool registration using server.tool() with name 'ha_get_state'.
    server.tool(
      'ha_get_state',
      'Get Home Assistant entity state by entity_id.',
      GetStateInput.shape,
      async (input) => {
        const state = await ha.getState(input.entity_id)
        return {
          content: [{ type: 'text', text: JSON.stringify(state, null, 2) }],
        }
      },
    )
  • HomeAssistantClient.getState() - helper that looks up the entity by entity_id from cached entities.
    async getState(entityId: string): Promise<HassEntity | null> {
      // Ensure we have a state snapshot.
      await this.ensureConnected()
      return this.entities[entityId] ?? null
    }
Behavior3/5

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

Description states a read operation, but with no annotations, it lacks details on behavior like what happens if entity_id does not exist (error vs null), authentication needs, or read-only nature. Minimal but not misleading.

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?

Single sentence, 6 words, no redundancy. Every word earns its place.

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

Completeness2/5

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

Despite no annotations or output schema, the description provides only the minimal purpose. It does not explain return format, possible states, or how the response is structured, leaving significant assumptions for the agent.

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

Parameters3/5

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

The description adds meaning by stating 'by entity_id', clarifying the parameter's role. However, with 0% schema description coverage, it does not explain format, examples, or constraints beyond the schema's minLength.

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 specifies 'Get Home Assistant entity state by entity_id' – a specific verb and resource with identifier, distinguishing it from sibling tools like ha_list_states (listing all states) and ha_get_history (historical data).

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

Usage Guidelines3/5

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

No explicit guidance on when to use vs alternatives. While it's implied for single entity queries, the description does not mention when not to use (e.g., for batch queries use ha_list_states) or contraindications.

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

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