Skip to main content
Glama

homeassistant_api

Check the status of the Home Assistant API to ensure it is online and available for managing smart home devices and services.

Instructions

Verify if the Home Assistant API is online

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Registers the 'homeassistant_api' MCP tool with no input parameters. The inline handler calls getHomeAssistantApi to check API status and returns a formatted text response.
    server.tool(
      "homeassistant_api",  
      "Verify if the Home Assistant API is online",
      async () => {
        console.error(`Verificando Home Assistant`);
        
        const result = await getHomeAssistantApi('/api/');
        
        if (!result.success) {
          return formatErrorResponse(`Erro ao pesquisar time: ${result.message}`);
        }
        
        // Formata os dados da resposta
        const response = result.data;
        
        if (!response.results || response.results === 0) {
          return {
            content: [{ 
              type: "text" as const, 
              text: response.message 
            }]
          };
        }
        
        const responseMessage = response.message;
        
        return {
          content: [{ 
            type: "text" as const, 
            text: responseMessage
          }]
        };
      }
    );
  • Core helper function that performs authenticated GET requests to the Home Assistant API using axios and environment variables for URL and token.
    async function getHomeAssistantApi(endpoint: string) {
      try {
        const url = `${process.env.HOME_ASSISTANT_URL}${endpoint}`;
        console.error(`Making request to: ${url}`);
        
        // O API key deve ser configurado como variável de ambiente
        const bearerToken = process.env.HOME_ASSISTANT_TOKEN;
    
        if (!bearerToken) {
          console.error('HOME_ASSISTANT_TOKEN environment variable is not set')
          process.exit(1)
        }
        
        console.log(bearerToken);
        console.log(url);
        
        const response = await axios.get(url, { 
          headers: {
            'Authorization': `Bearer ${bearerToken}`
          }
        });
        
        return { 
          data: response.data,
          success: true
        };
      } catch (error: any) {
        console.error(`Failed to get Home Assistant API: ${error.message}`);
        
        // Tratamento de erros da API de forma estruturada
        if (error.response) {
          return {
            success: false,
            statusCode: error.response.status,
            message: error.response.data?.message || error.message,
            error: error.response.data
          };
        }
        
        return {
          success: false,
          message: error.message,
          error
        };
      }
    } 
  • src/index.ts:23-23 (registration)
    Top-level registration call that invokes the module to register the homeassistant_api tool (and others) on the MCP server instance.
    registerHomeAssistantApiTools(server);
  • Helper function used by the tool handler to format error responses in MCP format.
    export function formatErrorResponse(message: string) {
        return {
          content: [{ 
            type: "text" as const, 
            text: message 
          }],
          isError: true
        };
      }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool verifies if the API is online, implying a read-only check, but doesn't specify what 'online' means (e.g., connectivity, authentication status), potential side effects, or response format. This is a significant gap for a tool with zero annotation coverage.

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's front-loaded with the core purpose, making it easy to parse and understand quickly. Every part of the sentence earns its place by directly contributing to the tool's intent.

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?

Given the tool's simplicity (zero parameters, no output schema), the description is minimal but adequate for basic understanding. However, without annotations or an output schema, it lacks details on behavioral traits (e.g., what 'verify' entails, error handling) and return values, making it incomplete for reliable agent use in more complex scenarios.

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

Parameters4/5

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

The tool has zero parameters, and schema description coverage is 100%, so the schema fully documents the lack of inputs. The description doesn't need to add parameter information, and it appropriately doesn't mention any. A baseline of 4 is applied for zero-parameter tools with high schema coverage.

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

Purpose4/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 with a specific verb ('verify') and resource ('Home Assistant API'), making it immediately understandable. However, it doesn't explicitly differentiate from sibling tools like homeassistant_get_state, which might also check system status, so it doesn't reach the highest score.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives like homeassistant_get_state or homeassistant_call_service. There's no mention of prerequisites, context, or exclusions, leaving the agent to infer usage based solely on the tool name and description.

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

Related 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/guilhermelirio/homeassistant-mpc'

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