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
    }

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.7

TDQS

B3.3/5.0
Behavior2/5

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

No annotations are provided, and the description does not disclose any behavioral traits beyond the basic action. It lacks context about return format, error handling, or safety, which matters when no annotations are present.

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 a single, clear sentence with no wasted words. It is front-loaded with the action and parameter, making it appropriately concise for a simple get operation.

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?

While the tool is simple (one parameter, no output schema), the description is too sparse to fully equip an agent. It does not explain what the returned state looks like, what happens if the entity is not found, or how this tool relates to similar state-list tools.

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

Parameters2/5

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

The schema has 0% description coverage, and the description only restates that the tool uses 'entity_id' without explaining the expected format (e.g., 'light.living_room') or providing any additional meaning beyond the parameter name.

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 specific action ('Get') and resource ('Home Assistant entity state') with a parameter ('by entity_id'). It distinguishes from siblings like ha_list_states (which lists all states) and ha_get_history (which retrieves historical states), so the purpose is unambiguous.

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?

Usage is implied through the description: use this tool when you need the current state for a specific entity_id. However, it does not explicitly state when to prefer this over alternatives or provide any exclusions or conditions.

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