Skip to main content
Glama
homeassistant-ai

Home Assistant MCP Server

Official

Set Dashboard Resource

ha_config_set_dashboard_resource
Destructive

Create or update Home Assistant dashboard resources from inline JavaScript/CSS or external URLs, supporting module, js, and css types.

Instructions

Create or update a dashboard resource (inline code or external URL).

Provide exactly one of:

  • content: Inline JavaScript or CSS code (embedded in the resource URL as a data: URI — no file storage or external hosting involved). Supports 'module' and 'css' types only (not 'js'); URLs are deterministic (same content = same URL); up to ~128KB. Content must be self-contained: a data: URI has no base URL, so relative imports inside a module and relative url() references inside CSS cannot resolve (use fully-qualified URLs instead). If Home Assistant is behind a reverse proxy that injects a Content-Security-Policy without 'data:' in script-src/style-src, the browser blocks these resources: this call still succeeds and the card simply never renders. Register the code as a file and use url='/local/...' on such a deployment. (HA itself ships no CSP.)

  • url: External resource URL — /local/... (files in /config/www/), /hacsfiles/... (HACS-installed cards) or https://... (CDN). Supports all types: 'module', 'js', 'css'.

EXAMPLES:

  • Inline: ha_config_set_dashboard_resource(content="class MyCard extends HTMLElement { ... } customElements.define('my-card', MyCard);", resource_type="module")

  • HACS card (after ha_manage_hacs(action='download')): ha_config_set_dashboard_resource(url="/hacsfiles/lovelace-mushroom/mushroom.js", resource_type="module")

  • Update: ha_config_set_dashboard_resource(url="/local/my-card-v2.js", resource_type="module", resource_id="abc123")

After adding a resource, a browser cache clear or hard refresh (Ctrl+Shift+R) is needed to load it.

If a Claude Desktop user gets a 4-minute timeout with no result on this call, read the target back before repeating it, and tell them to wait a few seconds before clicking the manual-approve button, as clicking it too quickly is known to cause hangs in Claude Desktop. This workaround is specific to Claude Desktop.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlNoURL of the resource.
contentNoJavaScript or CSS code to host inline.
resource_idNoResource ID to update. If omitted, creates a new resource. Get IDs from ha_config_list_dashboard_resources()
resource_typeNoResource type: 'module' for ES6 modules (modern cards), 'js' for legacy JavaScript (older custom cards), 'css' for stylesheets (themes, global styles)module

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changedv8.6.0
    • changedInput schema / properties / content / description
      Previous value: -"JavaScript or CSS code to host inline (max ~128KB). The code is embedded directly in the resource URL as a data: URI - no file storage or external hosting involved. Mutually exclusive with url. Supports 'module' and 'css' types only."New value: +"JavaScript or CSS code to host inline."
    • changedInput schema / properties / resource_type / description
      Previous value: -"Resource type: 'module' for ES6 modules (modern cards, default), 'js' for legacy JavaScript (url mode only), 'css' for stylesheets"New value: +"Resource type: 'module' for ES6 modules (modern cards), 'js' for legacy JavaScript (older custom cards), 'css' for stylesheets (themes, global styles)"
    • changedInput schema / properties / url / description
      Previous value: -"URL of the resource. Can be: /local/file.js (www/ directory), /hacsfiles/component/file.js (HACS), https://cdn.example.com/card.js (external). Mutually exclusive with content."New value: +"URL of the resource."
  2. First observedv7.14.2

TDQS

A4.7/5.0
Behavior5/5

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

Annotations only flag destructive=true/idempotent=false; the description adds substantial context beyond them: data: URI embedding with no file storage, deterministic URLs, ~128KB cap, self-containment requirements, the silent-failure mode under a CSP proxy ('this call still succeeds and the card simply never renders'), the required browser cache clear, and the Claude Desktop timeout workaround.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with purpose, then the content/url branches, examples, and caveats. Most sentences carry real constraint information, but the trailing Claude Desktop timeout workaround and the long CSP digression make it heavier than it needs to be for tool selection.

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?

For a mutation tool with subtle semantics, the description covers the create-vs-update path, both input modes, type restrictions, failure modes, and post-call refresh needs; an output schema exists so return values need no explanation. Nothing an agent needs to invoke this correctly is missing.

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 coverage is 100%, but the description adds constraints the schema cannot express: the exactly-one-of relationship between content and url (the schema permits all-null), the fact that content supports only 'module' and 'css' and not 'js', and the size limit on inline content.

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?

States a specific verb and resource: 'Create or update a dashboard resource (inline code or external URL)', immediately scoping it to dashboard resources rather than the dashboard itself (ha_config_set_dashboard) or the resource list/delete siblings. The inline-vs-URL distinction further pins down what the tool operates on.

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?

Gives a strong when-to-use rule ('Provide exactly one of: content or url'), explains the choice between them, and gives a when-not with a concrete alternative (on CSP-injecting reverse proxies, register the code as a file and use url='/local/...'). It does not route to sibling tools (e.g., listing resources for IDs or deleting), which keeps it short of a 5.

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

Deploy Server

Other Tools