Skip to main content
Glama
diverdown1964

Home Assistant MCP Server

list_entities

Retrieve all smart home devices and sensors from Home Assistant, with optional filtering by device type like lights or switches.

Instructions

List all Home Assistant entities (lights, switches, sensors, etc.)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
domainNoFilter by domain (e.g., 'light', 'switch', 'sensor'). Optional.

Implementation Reference

  • Handler for the 'list_entities' tool. Fetches all Home Assistant entities using haClient.getStates(), optionally filters by domain from input arguments, maps to a simplified object (entity_id, state, friendly_name), stringifies as JSON, and returns in the tool response content.
    case "list_entities": { const entities = await haClient.getStates(); const filtered = args?.domain ? entities.filter((e) => e.entity_id.startsWith(`${args.domain}.`)) : entities; return { content: [ { type: "text", text: JSON.stringify( filtered.map((e) => ({ entity_id: e.entity_id, state: e.state, friendly_name: e.attributes.friendly_name, })), null, 2 ), }, ], }; }
  • src/index.ts:101-112 (registration)
    Registration of the 'list_entities' tool in the ListToolsRequestHandler response. Includes the tool name, description, and input schema for optional domain filter.
    name: "list_entities", description: "List all Home Assistant entities (lights, switches, sensors, etc.)", inputSchema: { type: "object", properties: { domain: { type: "string", description: "Filter by domain (e.g., 'light', 'switch', 'sensor'). Optional.", }, }, }, },
  • Helper method in HomeAssistantClient class that fetches the list of all entity states from the Home Assistant API endpoint '/api/states'.
    async getStates(): Promise<HAEntity[]> { return this.fetch("states"); }

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/diverdown1964/HomeAssistant-MCP'

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