ha-exception-debug
Provides post-mortem exception debugging for Home Assistant, allowing AI agents to list captured exceptions, inspect traceback frames and local variables, and optionally evaluate Python in the context of a captured frame for true post-mortem debugging.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@ha-exception-debugshow me the last exceptions and their tracebacks"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Exception Debug for Home Assistant
A live post-mortem debugger for Home Assistant exceptions — think
pyramid_debugtoolbar or the
Werkzeug interactive debugger, but for Home Assistant and queryable by an AI
agent over MCP.
Home Assistant's built-in system_log keeps only the formatted text of an
error. This integration keeps the live exception object and its traceback
frames in memory for a short window, so you (or an AI coding agent) can:
list recently captured exceptions,
walk each traceback's frames and read their local variables, and
optionally evaluate Python in the context of a captured frame for true post-mortem debugging.
⚠️ This is a developer/debugging tool. Retaining tracebacks pins the objects that were in scope when the error happened, and the
eval_in_framecapability is arbitrary code execution by design. Keepenable_evaloff unless you understand the implications, and never expose your Home Assistant instance unauthenticated.
How it works
A logging.Handler is attached directly to the root logger during setup.
Because Home Assistant migrates its console/file handlers behind a
QueueHandler (whose prepare() strips exc_info) before any integration
loads, a sibling root handler added afterwards still sees records with their
live exc_info intact — the same mechanism the core system_log
integration relies on. When a record arrives with no exc_info (e.g. Home
Assistant's catch_log_exception logs pre-formatted text), the handler falls
back to sys.exc_info(), which is still valid because it runs synchronously
inside the originating except block.
Captured exceptions are held in a bounded, TTL-aware store. Once an entry's
live window (ttl) elapses — or it is evicted past max_entries — its frames
are cleared with traceback.clear_frames() to release locals, while a text
snapshot of the traceback is retained so the entry stays listable. A timer
applies the TTL once a minute, so frames are released on a quiet system too and
not only when the next exception happens to arrive.
Related MCP server: debugpy-mcp
Requirements
Home Assistant 2025.8.0 or newer.
For the AI/agent path, the core Model Context Protocol Server integration. See Using it with an AI agent (MCP) — if you already have it configured, it has to be deleted and re-added, because it has no options flow. The REST and WebSocket APIs work without it.
Installation (HACS)
In HACS, add this repository as a custom repository (category: Integration):
https://github.com/bbangert/ha-exception-debug.Install Exception Debug and restart Home Assistant.
Go to Settings → Devices & services → Add integration and pick Exception Debug.
Only if you want the AI/agent path: set up (or re-add) the Model Context Protocol Server integration — see Using it with an AI agent (MCP). Do this after step 3, so Exception Debug is available to select.
Manual install: copy custom_components/exception_debug/ into your Home
Assistant config/custom_components/ directory, restart, then add the
integration from the UI as above.
Configuration
Everything is configured from the UI — on first setup, and afterwards via Settings → Devices & services → Exception Debug → Configure. Changing an option reloads the integration immediately; no restart needed.
Option | Default | Meaning |
Capture level |
| Minimum log level to capture ( |
Maximum retained exceptions |
| Oldest are evicted past this count. |
Live frame retention |
| How long an entry keeps inspectable frames. |
Maximum repr length |
| Cap on the characters returned for any single value. |
Enable eval | off | Allows |
Only one instance can be configured, since the capture hook is global.
Migrating from YAML
Earlier versions were configured in configuration.yaml. That still works for
one more startup: the block is imported into a config entry automatically and a
repair issue tells you to delete it. Remove the exception_debug: block from
configuration.yaml once you have restarted — after the import, the YAML is
ignored and the UI options are authoritative.
Using it with an AI agent (MCP)
This integration does not speak MCP itself. It registers a Home Assistant LLM API named "Home Assistant Exception Debugger", which the core Model Context Protocol Server integration exposes to agents. You need that integration set up as well — without it there is no MCP endpoint and the tools below are unreachable.
⚠️ If you already have the MCP Server integration configured, you must delete its config entry and add it again. It has no options flow, so the set of exposed APIs is fixed when the entry is created and cannot be edited afterwards. It also allows only one entry, so you cannot add a second alongside the existing one.
If you do not have MCP Server yet
Set up Exception Debug first (above). The MCP Server flow lists the APIs that are registered at the moment you run it, so this one has to be loaded already or it will not appear as a choice.
Add the Model Context Protocol Server integration.
In the setup dialog, the API field is a multi-select. Tick both Assist and Home Assistant Exception Debugger (it defaults to Assist alone).
Point your MCP client at
https://<your-ha>/api/mcpwith a long-lived access token.
If you already have MCP Server configured
Set up Exception Debug first (above), so it is available to select.
Go to Settings → Devices & services → Model Context Protocol Server and delete the existing entry. Nothing else is lost — the entry stores only which APIs to expose.
Add the integration again. The API field is a multi-select, so tick both Assist and Home Assistant Exception Debugger to keep your existing Assist behaviour alongside the new tools.
Your existing MCP client configuration and token continue to work — the endpoint is unchanged.
Tools exposed to the agent:
Tool | Purpose |
| Recent captured exceptions, newest first. |
| Full formatted traceback text for an id. |
| Frames of an exception (file, line, function, local names). |
|
|
| Evaluate Python in a frame's context (only if |
REST API
All endpoints require an admin user's token
(Authorization: Bearer <long-lived token>). Frame locals routinely contain
credentials that were in scope when the error happened, so authentication alone
is not a sufficient boundary — this matches the admin gate on the WebSocket
commands.
GET /api/exception_debug/exceptions?limit=20
GET /api/exception_debug/exceptions/{id}
GET /api/exception_debug/exceptions/{id}/frames/{frame_index}/localsWebSocket API (admin only)
exception_debug/list {limit?}
exception_debug/frames {exc_id}
exception_debug/frame_locals {exc_id, frame}Services
exception_debug.clear— drop all captured exceptions and release frames.
Notes & limitations
Root-logger handlers do not see loggers with
propagate = False(rare in HA).Captured exceptions are held per config entry, so changing an option (which reloads the integration) starts a fresh buffer and discards what was captured.
eval_in_frameruns on the event loop; a blocking snippet will block Home Assistant. Use it deliberately.The icon ships in-repo under
custom_components/exception_debug/brand/, which satisfies the HACS brands check. Addingexception_debugto home-assistant/brands is only needed to appear in the default HACS store.
Development
python -m venv .venv && .venv/bin/pip install -r requirements_test.txt
.venv/bin/pytest --cov=custom_components.exception_debug --cov-branch --cov-report=term-missing
.venv/bin/ruff format --check custom_components tests
.venv/bin/ruff check custom_components tests
.venv/bin/mypy custom_components/exception_debug --ignore-missing-importsCI runs hassfest, HACS validation, ruff, mypy, and the test suite on every push
and pull request. Tests are gated at 100% branch coverage and run against
both the minimum supported Home Assistant (2025.8.1) and a current release, so
the version floor advertised in hacs.json is actually exercised rather than
assumed.
License
MIT — see LICENSE.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables AI assistants to perform interactive Python debugging with breakpoints, step execution, and variable inspection using the Debug Adapter Protocol (DAP) through an MCP server interface.Last updated81MIT
- FlicenseDqualityDmaintenanceAn MCP server that enables agents to attach debugpy to running Python processes inside Docker containers for enhanced debugging and inspection. It provides tools for container autodiscovery, process injection, and generating breakpoint plans based on logs and metadata.Last updated8
- AlicenseAqualityDmaintenanceAn MCP server that enables AI assistants to control GDB debugging sessions, including breakpoint management, thread analysis, and variable inspection, using the GDB/MI protocol.Last updated221MIT
- FlicenseAqualityDmaintenanceMCP server that connects AI coding agents to Pernosco debugging sessions for querying execution traces, inspecting variables, navigating call stacks, and tracing value histories through natural language.Last updated2014
Related MCP Connectors
Live browser debugging for AI assistants — DOM, console, network via MCP.
Personal assistant MCP server with search, execute, packages, jobs, secrets, and integrations.
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/bbangert/ha-exception-debug'
If you have feedback or need assistance with the MCP directory API, please join our Discord server