hardware-logging
MCP server for embedded board debugging, providing structured serial capture, crash decoding, and flash-safe port arbitration via bounded CLI and MCP tools.
README
hardware-logging
Structured, crash-aware serial logging for embedded boards — built so AI coding agents can debug firmware recursively.
hwlog runs a small daemon that owns your board's serial port and records everything to structured sessions on disk. Your coding agent (Claude Code, Cursor, anything) never touches the port — it queries the recording through bounded CLI commands or native MCP tools, flashes through a port-safe wrapper, and verifies behavior instead of assuming "it compiled" means "it works."
┌──────────┐ serial ┌──────────────┐ JSONL ┌─────────────────────┐
│ ESP32 / │ ────────► │ hwlog daemon │ ─────────► │ session on disk │
│ any MCU │ ◄────── │ (owns port) │ │ logs · boots · │
└──────────┘ send └──────┬───────┘ │ decoded crashes │
│ pause/resume └──────────┬──────────┘
┌──────┴───────┐ │ bounded queries
│ hwlog flash │ ┌──────────┴──────────┐
│ -- idf.py … │ │ coding agent │
└──────────────┘ │ (CLI or MCP tools) │
└─────────────────────┘
Why
Wiring a coding agent to a dev board fails in predictable ways: blocking monitors hang the agent, flashing fights the monitor for the port (and looks exactly like a bricked board), ESP32-S3 native USB drops all output until DTR is asserted, ports renumber on replug, crashes scroll away before anyone reads them, and a raw log dump blows the agent's context window. hwlog packages the fixes — learned from real hardware incidents — into one tool.
Features
- Persistent capture sessions — logs are recorded to disk continuously; the crash that happened while your agent was thinking is still there
- Structure at ingest — ANSI stripped; ESP-IDF and Arduino log formats parsed into
{level, tag, msg, timestamp}; everything else passes through - Boot-cycle segmentation — "show me logs since the last boot" is one flag (
--boot -1); reboot loops are instantly visible inhwlog boots - Crash reports, assembled and decoded — panics/watchdogs/heap corruption are detected, captured as complete multi-line artifacts, and symbolized with
addr2lineagainst ELFs archived at flash time - Bounded, agent-budget-aware queries — line, byte, scan, regex-runtime, and timeout ceilings plus repeated-line collapse (
heartbeat (×347)) - Flash-safe port arbitration —
hwlog flash -- <cmd>holds an exclusive pause lease, invalidates stale symbols on every attempt, resumes when the tool exits, and conservatively archives one generation-bound ELF candidate - Behavioral verification —
hwlog wait --pattern "setup done" --timeout 20includes output captured since the latest flash boundary and provides CI-friendly exit codes - MCP server + bundled agent skill —
hwlog mcpexposes everything as native agent tools;hwlog initinstalls a debug playbook (crash-signature triage, loop protocol) into your project
Works with anything that talks serial: ESP32 family first-class, plus RP2040, STM32, nRF, Arduino — identified by USB VID.
Installation
uv tool install hardware-logging # or: pip install hardware-logging
Or run without installing: uvx --from hardware-logging hwlog ports
The background daemon and its Unix-socket control channel support macOS and Linux.
Quick Start
hwlog ports # find your board
hwlog start # background capture daemon (auto-detects the board)
hwlog flash -- idf.py flash # flash through the wrapper (exclusive pause + candidate ELF archive)
hwlog wait --pattern "setup done" --timeout 20 # verify it actually booted
hwlog logs --boot -1 --tail 50 # structured logs from the latest boot
hwlog crashes --last # full decoded crash artifact, if it crashed
What a crash looks like
The whole point of the flash-time ELF archive: when the board panics, you get source lines, not addresses. Representative output:
$ hwlog crashes --last
crash 1: Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.
--- raw ---
Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.
Core 1 register dump:
PC : 0x400d1234 PS : 0x00060530 A0 : 0x800d5678 A1 : 0x3ffb1230
Backtrace: 0x400d1234:0x3ffb1234 0x400d5678:0x3ffb5678 0x400dabcd:0x3ffb9abc
Rebooting...
--- decoded backtrace ---
0x400d1234: sensor_read_task at main/sensor.c:87
0x400d5678: read_i2c_register at main/i2c_helpers.c:41
0x400dabcd: vTaskDelay at freertos/tasks.c:1456
The artifact is assembled from the multi-line panic dump (register dump,
backtrace, reboot marker) and symbolized with addr2line against the ELF
archived by the most recent hwlog flash. No archived ELF yet? The raw
addresses are kept and the report says why decoding was skipped.
For coding agents
hwlog init # install the agent skill + CLAUDE.md snippet
Or add the MCP server (Claude Code shown):
claude mcp add hardware-logging -- uvx --from hardware-logging hwlog mcp
Agents get query_logs, list_boots, get_crash, wait_for_pattern, send_to_device, capture_status. Device telemetry is labeled untrusted, and MCP device writes are disabled unless the user sets HWLOG_MCP_ALLOW_SEND=1.
Session data and the local daemon control channel are owner-only. Metadata writes are atomic, selectors cannot escape the session root, and ambiguous multi-board selections require an explicit port.
Storage and query scans are bounded by default (512 MiB per session, 4 GiB
total, 64 MiB query scan window) — see storage limits
and architecture for budgets, drop counters, and the
HWLOG_MAX_* / HWLOG_QUERY_SCAN_BYTES overrides.
The agent debug loop
hwlog start— capture runs continuously, owns the porthwlog flash -- <cmd>— port-safe flashing, with conservative ELF discovery for symbolizationhwlog wait --pattern <expected>— behavioral assertion, not compile-and-hopehwlog logs/hwlog crashes --last— bounded evidence, decoded backtraces- Fix firmware, repeat
Documentation
Full docs in /docs: architecture · CLI reference · MCP server · agent workflow
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。