agentleFS
homeassistant-aihomeassistant-ai/ha-mcp/AGENTS.md

ha-mcp

AGENTS.md4.9k starsChanged 2 months agoMITView on GitHub

Canonical agent guidance for the Home Assistant MCP Server repository. This repository uses worktree/ for isolated branches and local/ for scratch data; both are gitignored. Source is under src/ha_mcp/, component code under custom_components/ha_mcp_tools/, tests under tests/, the website under site/, and Home Assistant app flavors under homeassistant-addon*/. Read the development reference for commands and architecture. Workflow helpers live in .claude/skills/; inspect a helper's own instructions when it is explicitly invoked rather than duplicating its inventory here. Create feature worktrees under…

Trending

More talk lately.about the whole repository

Dec 2025: 2 mentionsJan 2026: 0 mentionsFeb 2026: 0 mentionsMar 2026: 2 mentionsApr 2026: 0 mentionsMay 2026: 2 mentionsJun 2026: 1 mentionJul 2026: 0 mentionsAug 2026: 9 mentionsSep 2026: 26 mentionsOct 2026: 4 mentionsNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the homeassistant-ai/ha-mcp repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about homeassistant-ai/ha-mcp

The biggest 5 of 46 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 46

Talked about on GitHub, Bluesky and Hacker News (46 times).

On GitHub · 40

35 more on GitHub

On Hacker News · 1

The file

Show its rules and text

We split this AGENTS.md into the rules it gives an agent

37 rules. About 0 are common, 25 are distinctive, and 12 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈25

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 12

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Distinctive:

    Before working, read every applicable AGENTS.md from the repository root through the target directory.

    line 9
  2. Very specific:

    Follow ordinary Markdown links when the task enters their scope.

    line 10
  3. Distinctive:

    If linked guidance conflicts with this file's behavioral rules, this file controls.

    line 11
  4. Very specific:

    Read the development reference for commands and architecture.

    line 17
  5. Very specific:

    Create feature worktrees under worktree/ from an up-to-date origin/master.

    line 21
  6. Distinctive:

    Before committing, verify that the working directory is the intended checkout.

    line 30
  7. Very specific:

    Read SECURITY.md before changing authentication, OAuth, webhooks, network exposure, proxies, filesystem access, or trust boundaries.

    line 44
  8. Distinctive:

    Use current primary sources.

    line 50
  9. Distinctive:

    Keep this file short enough to load on every task:

    line 54
  10. Distinctive:

    Keep only broadly applicable, high-value behavior in the root.

    line 57
  11. Distinctive:

    Use ordinary Markdown links, not imports.

    line 59
  12. Distinctive:

    Keep volatile counts, file inventories, workflow catalogs, historical incidents, and tutorials out of startup context.

    line 61
  13. Distinctive:

    Prefer short directives with concrete triggers.

    line 62
  14. Distinctive:

    Use descriptive headings, fenced code blocks, and CommonMark blank lines around headings and lists.

    line 63
  15. Distinctive:

    When guidance changes, check AGENTS.md, scoped AGENTS.md files, the style guide, contributing docs, tests, and inline references for drift.

    line 64
  16. Distinctive:

    Do not create, edit, label, close, or comment on an issue or pull request without user authorization for that write.

    line 68
  17. Distinctive:

    Before changing automated issue documentation, read the issue-intake policy and controls for source handling, maintainer overrides, …

    line 74
  18. Distinctive:

    After every push, inspect human and automated feedback.

    line 78
  19. Distinctive:

    Never commit directly to master or main except for a documentation-only adjustment.

    line 86
  20. Distinctive:

    Never push or open a pull request without explicit user permission.

    line 87
  21. Distinctive:

    Never merge, close, delete branches, publish, release, or otherwise finalize work without explicit approval for that exact action.

    line 89
  22. Very specific:

    Run the smallest relevant tests after changes.

    line 102
  23. Distinctive:

    Run relevant E2E tests without waiting to be asked.

    line 103
  24. Distinctive:

    Run the full E2E suite only before claiming the full suite passes.

    line 104
  25. Distinctive:

    Never state that tests, lint, builds, CI, or review are clean without fresh evidence from the relevant command or current pull-request head.

    line 107
  26. Distinctive:

    Leave touched code better than you found it.

    line 111
  27. Distinctive:

    Never create a follow-up issue or pull request without explicit approval.

    line 123
  28. Distinctive:

    Before proposing one, the work must not be achievable by mirroring a nearby pattern.

    line 124
  29. Distinctive:

    Do not use “out of scope,” “non-blocking,” “post-merge follow-up,” “nice to have,” “pre-existing,” or similar phrasing to hide a legitimate …

    line 132
  30. Very specific:

    Read the workflow inventory and invariants before editing .github/workflows/.

    line 142
  31. Very specific:

    Import an existing helper instead of copying it.

    line 157
  32. Very specific:

    Never hand-edit the root CHANGELOG.md or its homeassistant-addon/CHANGELOG.md copy.

    line 158
  33. Very specific:

    Before adding or modifying a tool, read .gemini/styleguide.md.

    line 166
  34. Very specific:

    Before changing custom_components/ha_mcp_tools/ or a server dependency on it, read the custom-component guide.

    line 174
  35. Distinctive:

    Before any translation or translatable-English change, read the canonical locale guide.

    line 182
  36. Very specific:

    Before changing homeassistant-addon*/, read the Home Assistant app guide.

    line 186
  37. Very specific:

    Use gh search code and gh api against Home Assistant Core rather than cloning it only for a lookup.

    line 190

≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

AGENTS.md

Canonical agent guidance for the Home Assistant MCP Server repository.

Instruction structure

  • AGENTS.md is the canonical source. CLAUDE.md is a symlink to it; edit AGENTS.md only.
  • This root file owns repository-wide behavior, permissions, scope, and testing policy. Linked documents own topic-specific detail.
  • Before working, read every applicable AGENTS.md from the repository root through the target directory; narrower files supplement every broader ancestor.
  • Follow ordinary Markdown links when the task enters their scope. Do not replace them with @imports: imports load every linked byte at startup and defeat progressive disclosure.
  • If linked guidance conflicts with this file's behavioral rules, this file controls. Repair the conflicting duplicate rather than choosing silently.

Repository Structure

This repository uses worktree/ for isolated branches and local/ for scratch data; both are gitignored. Source is under src/ha_mcp/, component code under custom_components/ha_mcp_tools/, tests under tests/, the website under site/, and Home Assistant app flavors under homeassistant-addon*/.

Read the development reference for commands and architecture. Workflow helpers live in .claude/skills/; inspect a helper's own instructions when it is explicitly invoked rather than duplicating its inventory here.

Worktree Workflow

Create feature worktrees under worktree/ from an up-to-date origin/master. A documentation-only adjustment is the sole exception that may be committed directly on master or main:

git fetch origin master
git worktree add worktree/<name> -b <branch> origin/master

Before committing, verify that the working directory is the intended checkout. For a non-documentation change, also verify that the branch is not master/main. Preserve unrelated dirty changes in every checkout. Remove a worktree only when its branch is no longer needed and the user has authorized any associated destructive cleanup. The repository-root checkout is where master is kept; git worktree prune removes stale worktree references.

Project Overview

Home Assistant MCP Server is a Python 3.13 FastMCP server that lets AI assistants control and configure Home Assistant through MCP. The repository is homeassistant-ai/ha-mcp; the package is ha-mcp on PyPI.

Security

Read SECURITY.md before changing authentication, OAuth, webhooks, network exposure, proxies, filesystem access, or trust boundaries. Its threat model defines the trusted MCP-client assumption, local-network boundary, Bearer-token posture, tenant model, and Home Assistant permission scope.

A security advisory's API body does not include its discussion thread. Confirm maintainer disposition and fix scope from the private thread or a maintainer before implementing an advisory fix.

External Documentation

Use current primary sources. The development reference links the Home Assistant REST/WebSocket APIs, Home Assistant Core, FastMCP, MCP specification, and app-development documentation.

Agent-document formatting

Keep this file short enough to load on every task:

  • Hard limit: 16,000 Unicode characters and 200 lines.
  • Keep only broadly applicable, high-value behavior in the root. Put coding conventions and subsystem procedures in their closest durable owner.
  • Retain a short section here for each major topic and state when and why to read its linked document.
  • Use ordinary Markdown links, not imports. A link must name the document's scope; avoid blind “see also” references.
  • Give each rule one canonical owner. Link instead of copying exact lists, commands, examples, or policy prose into multiple files.
  • Keep volatile counts, file inventories, workflow catalogs, historical incidents, and tutorials out of startup context; place them beside the code or process they describe.
  • Prefer short directives with concrete triggers. Explain rationale where a future editor might otherwise “simplify” a load-bearing rule.
  • Use descriptive headings, fenced code blocks, and CommonMark blank lines around headings and lists. Do not use decorative formatting as structure.
  • When guidance changes, check AGENTS.md, scoped AGENTS.md files, the style guide, contributing docs, tests, and inline references for drift.

Issue & PR Management

Do not create, edit, label, close, or comment on an issue or pull request without user authorization for that write. Draft the exact proposed text first when approval has not already been given.

Every bug or agent-behavior issue filed here must contain the report ha_report_issue generates (its issue_body, unchanged), or a ### Why there is no ha_report_issue report section saying why there is none (even "N/A"); feature requests should too. issue-intake.yml labels a new one that has neither missing bug report output, and report-gate.yml closes it after 24 hours unless one is added or a maintainer removes the label.

The detailed label taxonomy, issue-analysis query, bot behavior, review commands, CI loop, and release automation live in the GitHub workflow reference.

Before changing automated issue documentation, read the issue-intake policy and controls for source handling, maintainer overrides, permissions, and bench validation.

Automated Code Review

After every push, inspect human and automated feedback. Codex and CodeRabbit findings are hypotheses: verify them against current source, tests, and contracts. Human feedback has priority. Read every CodeRabbit review body in full because collapsed outside-diff and nitpick findings may create no unresolved thread.

CodeRabbit intentionally reviews drafts with reviews.auto_review.drafts: true and auto_pause_after_reviewed_commits: 0. Bot-authored dependency and promotion pull requests are excluded from automatic review but retain manual review commands. Exact configuration and rationale are in the GitHub workflow reference.

For an accepted inline finding, implement the fix, reply with evidence, resolve the thread, and include one pull-request-level summary when the review had inline comments. Leave a thread open only while requesting clarification.

Git & PR Policies

  • Never commit directly to master or main except for a documentation-only adjustment.
  • Never push or open a pull request without explicit user permission.
  • Open every pull request as a draft. Mark it ready only when explicitly asked, after refreshing its description and verifying required CI and reviews.
  • Never merge, close, delete branches, publish, release, or otherwise finalize work without explicit approval for that exact action.
  • Preserve the pull-request template headings and generated review sections.
  • Make routine, reversible implementation decisions autonomously. Ask before a choice materially changes scope, public behavior, architecture, or review surface; do not create competing pull requests without approval.
  • Choose for long-term codebase health, not implementation speed; maintainability-improving refactors are valid when they fit the user's scope.
  • Draft descriptions may remain provisional. Refresh the description before marking ready and after later scope changes while ready. Do not claim readiness from stale checks or a different head SHA.

Testing and verification

Testing behavior belongs in this root because it applies to every code change:

  • Bug fixes require a failing regression test first, then the minimal fix, unless the only possible test would restate a freely chosen configuration value (rule 4 in tests/AGENTS.md).
  • New MCP tools need E2E coverage. Any existing tool without tests gains E2E coverage even when it is not otherwise part of the current pull request. Core changes in client/, server.py, or errors.py need focused coverage.
  • Refactors with strong existing coverage, documentation-only changes, minor parameters on well-tested tools, and utilities whose behaviour an existing test already asserts may not need a new test.
  • Run the smallest relevant tests after changes. Read tests/AGENTS.md for test design rules, lanes, markers, polling, and test patterns, and the development reference for exact commands.
  • Run relevant E2E tests without waiting to be asked. Let pytest report unavailable prerequisites or skips rather than assuming them.
  • Run the full E2E suite only before claiming the full suite passes; a focused file is partial evidence and must be described that way.
  • Fix unrelated test failures encountered during CI, even when time-consuming, subject to the Boy Scout scope rules below.
  • Match verification to risk. Documentation-only work needs structural checks such as links, generated-file drift, size, and workflow syntax, not unrelated application E2E.
  • Never state that tests, lint, builds, CI, or review are clean without fresh evidence from the relevant command or current pull-request head.

Boy Scout Rule — Handling Discovered Improvements

Leave touched code better than you found it. Fix-in-place is the default, but the user's scope controls meaningful expansion. “Improve incrementally” means commit-by-commit within this pull request, not across follow-up pull requests.

FindingAction
Small and clearly related—including missing or weak tests in the touched area and straightforward test-quality fixesFix in this pull request, preferably as a distinct commit.
Mid-sized or meaningfully expands the diffPause before pushing and ask whether to bundle it.
Large, unrelated, or a different subsystemExplain the scope change and ask; do not silently defer or expand.

About 200 changed lines is a should-I-ask heuristic, not a bundling cap. Work of any size may stay in the pull request when it is not grossly out of scope; estimate honestly and do not inflate the estimate to justify deferral.

Never create a follow-up issue or pull request without explicit approval. Before proposing one, the work must not be achievable by mirroring a nearby pattern; it must either present a real design choice with named alternatives or be a genuinely large mechanical migration; it must change the review surface, have a concrete benefit, and remain actionable. If any of those conditions fails, fix it now or let it go—do not file an issue merely to “track” it. Bot nits are fixed or dismissed in the current review, not converted into backlog noise.

Do not use “out of scope,” “non-blocking,” “post-merge follow-up,” “nice to have,” “pre-existing,” or similar phrasing to hide a legitimate current finding. This list is non-exhaustive: match the intent, and remember that pre-existing problems are the point of the Boy Scout rule. Scope is the user's call: state the finding and ask explicitly, with the specific reason, before deferring or dropping it: “I think this is out of scope because [X]. Fix here or defer?”

CI/CD Workflows

Read the workflow inventory and invariants before editing .github/workflows/. In pr.yml, HACS and Hassfest must run before any pull-request-controlled code. The AGENTS size check may run first because it only reads this file.

Development Commands

The minimal setup is uv sync --group dev; run stdio with uv run ha-mcp and HTTP/settings UI with uv run ha-mcp-web. Exact test, lint, Docker, and research commands are in the development reference. Contributor setup is in CONTRIBUTING.md.

Architecture

Tools are lazy-discovered from tools_*.py; shared business logic belongs in service modules; WebSocket-backed operations verify state changes; and tools wait for logical completion when possible. Read the architecture map and the code review style guide before structural code changes.

Code Conventions

  • Comment only non-obvious logic. Code should be self-documenting; too many comments is an anti-pattern.
  • In Python, type-hint every function signature and use async/await consistently for I/O.
  • Keep modules focused. A source file over 1,000 lines (Pylint's max-module-lines default) spans several concerns, and test_module_size_ratchet.py fails when a new file crosses that limit or a listed one grows; split along responsibilities and update internal imports and test patch targets together, since internal module paths are not a public MCP tool contract.
  • Import an existing helper instead of copying it. test_duplicate_code_ratchet.py fails when a new Python function or class has the same code as another; the development reference explains the baseline.
  • Never hand-edit the root CHANGELOG.md or its homeassistant-addon/CHANGELOG.md copy; semantic-release generates both. The webhook-proxy app changelogs are maintained by hand per their scoped AGENTS.md.

Terminology: apps, not add-ons

In user- and agent-facing text, write app (add-on) on first mention and app afterwards. Identifiers require case-by-case verification; established slugs, paths, labels, API routes, and compatibility text may retain the old spelling. The exact exceptions live in the development reference.

Writing MCP Tools

Before adding or modifying a tool, read .gemini/styleguide.md. It owns tool naming, decorator order, tags, safety annotations, ToolError handling, return shapes, docstrings, consolidation, and progressive disclosure.

Tool Waiting Behavior

Tools wait for completion when a reliable signal exists; query and fire-and-forget operations return immediately. The canonical categories and shared helpers are in .gemini/styleguide.md → Tool Waiting Behavior.

Custom Component

Before changing custom_components/ha_mcp_tools/ or a server dependency on it, read the custom-component guide. It owns the pending-version cycle, minimum-version gate, backward compatibility, two-entry command surface, and post-merge live-test requirement. Functionality used by the embedded server must be registered on the shared command surface available from the server entry; never leave it on the tools entry alone. Only the privileged filesystem and YAML services remain intentionally tools-entry-only.

Translations

Before any translation or translatable-English change, read the canonical locale guide. It owns the current language set, four-surface parity, generated projections, best-effort Klingon exception, completeness thresholds, English-source baseline, post-merge translation, and recovery. Never hand-edit generated app catalogs.

Home Assistant App

Before changing homeassistant-addon*/, read the Home Assistant app guide. Webhook Proxy work additionally requires its scoped AGENTS.md and always follows the dev-first, promote-only flow.

API Research

Use gh search code and gh api against Home Assistant Core rather than cloning it only for a lookup. Commands and source-verification guidance are in the development reference.

Release Process

Semantic-release prefixes, channels, urgent releases, workflow ownership, and manual dispatch guidance are in the GitHub workflow reference. Component and Home Assistant app changes also follow their linked subsystem release rules.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.