Skip to main content
Glama
agent-mcu MCP server
by linxi27667

agent-mcu-flow

CI License: MIT Python 3.11+

AI-native end-to-end MCU development & Hardware-in-the-Loop (HIL) workflow engine for STM32 & ESP32 — zero runtime pip dependencies, unified CLI + stdio MCP server, declarative STM32CubeMX CLI automation, CMSIS-SVD register/clock/HardFault verification, and a 3-layer C architecture gate.

Part of the agent-* cross-surface automation suite:


Why agent-mcu-flow?

  1. Human-readable GUI drawings + AI-driven CLI execution: Complex STM32 PLL clock trees live in verified golden .ioc bases (templates/base-ioc/), while AI drives peripheral/pin assignment declaratively via hardware_spec.json -> ST UM1718 CubeMX CLI script -> ioc-audit verification. Humans can always double-click .ioc in CubeMX GUI at any time.

  2. Dual-Track Bottom-Up Entry:

    • Track A (stm32-cubemx-cmake / esp32-idf): Production-grade HAL/LL/IDF with strict zero-conflict isolation (cmake/user_app.cmake + minimal App_Init()/App_Poll() facade in Core/Src/main.c).

    • Track B (stm32-baremetal-reg): Clean RM0090 register-level C11 bare-metal projects backed by offline SVD bitfield lookup and live J-Link register readback.

  3. Hardware Truth Over Guesswork (Zero-Dependency SVD Engine):

    • agent-mcu svd-query: Look up exact peripheral/register/bitfield offsets from official .svd before writing register code.

    • agent-mcu clock-check: Read real RCC & FLASH_ACR over J-Link to verify SYSCLK / HCLK / PCLK1 / PCLK2 MHz and Flash wait-state safety (STM32 F4/F1/G4/L4/H7/F0).

    • agent-mcu svd-read --expect: Assert real hardware register bitfields as automated pass/fail gates.

    • agent-mcu fault-decode: Automatically decode ARM Cortex-M CFSR/HFSR/MMFAR/BFAR, detect MSP/PSP stacked exception frames, and resolve faulting PC/LR via arm-none-eabi-addr2line.

  4. Native CLI + Zero-Dependency Stdio MCP Server: Works seamlessly with Claude Code, Cursor, Codex, and Antigravity (agent-mcu mcp, 9 tools).


Related MCP server: mcu-debug-mcp

Quick Start

# Install with uv (zero runtime dependencies)
uv sync --extra dev

# 1. Detect local toolchains (CubeMX, CubeCLT, ARM-GCC/GDB, Keil, J-Link, ESP-IDF, SVD)
uv run agent-mcu detect .

# 2. Scaffold a new standardized project (3 tracks)
uv run agent-mcu scaffold --track stm32-cubemx-cmake --out ./my_fw --name lift_ctrl --mcu STM32F407ZET6 --hse-mhz 8 --sysclk-mhz 168

# 3. Compile declarative CubeMX UM1718 CLI script from hardware_spec.json (add --execute with CubeMX installed)
uv run agent-mcu cubemx-apply examples/stm32f407-dual-track/hardware_spec.json \
  --out-dir examples/stm32f407-dual-track/track_a_cubemx_cmake

# 4. Audit .ioc against schematic hardware_spec.json & export read-only Markdown snapshot
uv run agent-mcu ioc-audit examples/stm32f407-dual-track/track_a_cubemx_cmake/stm32f407_pilot.ioc \
  --hardware-spec examples/stm32f407-dual-track/hardware_spec.json --require-cmake

# 5. Enforce 3-layer C architecture gate (config -> driver -> application -> task)
uv run agent-mcu arch-check examples/stm32f407-dual-track/track_b_baremetal_reg --strict

# 6. On hardware with J-Link: verify real 168 MHz SYSCLK + Flash Wait States
uv run agent-mcu clock-check --device STM32F407ZE --usb-serial <SERIAL> --hse-mhz 8 --expect-sysclk-mhz 168 --strict-warnings

# 7. Start stdio MCP server for AI coding agents
uv run agent-mcu mcp

STM32F407ZET6 Dual-Track Pilot

See examples/stm32f407-dual-track/:

  • track_a_cubemx_cmake/: Declarative CubeMX + CMake + isolated 3-layer app (App_Init/App_Poll top facade + domain-named Heartbeat_Step).

  • track_b_baremetal_reg/: Self-contained RM0090 pure-register firmware (HSE 8MHz -> PLL 168MHz, PG2 LED_RUN, USART1 115200 8N1), continuously cross-compiled by real arm-none-eabi-gcc in GitHub Actions CI.

MCP Server Tools (agent-mcu mcp)

Tool

Purpose

mcu_detect_env

Probe installed CubeMX, CubeCLT, CMake, ARM-GCC/GDB, Keil, J-Link, ESP-IDF, SVD files

mcu_svd_query

Offline CMSIS-SVD peripheral/register/bitfield lookup

mcu_svd_read

Live J-Link/GDB/mock register readback + bitfield assertions

mcu_clock_check

Real STM32 RCC + FLASH_ACR frequency & wait-state audit

mcu_fault_decode

Cortex-M HardFault/BusFault/UsageFault + PSP/MSP stack frame + ELF line resolution

mcu_ioc_audit

Parse .ioc and cross-verify against hardware_spec.json

mcu_cubemx_apply

Compile/execute UM1718 CubeMX CLI script from golden .ioc base + hardware_spec.json

mcu_arch_check

3-layer C architecture boundary linter

mcu_scaffold

Generate 3-track MCU project skeletons

Available Tools

9 tools
mcu_arch_checkC

Verify 3-layer embedded C architecture boundaries (config/driver/application/task).

Inputs: root.

mcu_clock_checkC

Read STM32 RCC & FLASH_ACR registers to verify real SYSCLK/HCLK/PCLK1/PCLK2 MHz and Flash wait states.

Inputs: family (required), device, backend, hse_mhz, +3 more.

mcu_cubemx_applyB

Compile declarative hardware_spec.json + golden base .ioc into an ST UM1718 CubeMX CLI script and optionally execute headlessly.

Inputs: out_dir (required), spec_path (required), execute, base_ioc, +1 more.

mcu_detect_envB

Detect installed MCU toolchains (STM32CubeMX, CubeCLT, CMake, ARM-GCC/GDB, Keil, J-Link, ESP-IDF, probe-rs) and project files.

Inputs: project_path.

mcu_fault_decodeC

Decode ARM Cortex-M HardFault/BusFault/MemManage/UsageFault registers, PSP/MSP stacked frame, and optional ELF line symbols.

Inputs: elf, device, backend, mock_json, +1 more.

mcu_ioc_auditC

Parse STM32CubeMX .ioc into a read-only hardware snapshot and cross-check against hardware_spec.json.

Inputs: ioc_path (required), out_md, hardware_spec, require_cmake.

mcu_scaffoldC

Scaffold a standardized STM32 CubeMX+CMake, STM32 Bare-Metal Register, or ESP-IDF project.

Inputs: track (required), out_dir (required), mcu, name, +3 more.

mcu_svd_queryB

Query official CMSIS-SVD peripheral/register/bitfield definitions offline before writing register code.

Inputs: svd, device, register, peripheral.

mcu_svd_readC

Read peripheral registers from target hardware (J-Link/GDB) or mock snapshot, decode SVD bitfields, and evaluate assertions.

Inputs: registers (required), svd, halt, device, +4 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.3/5.0

    Scored across 9 tools

    Disambiguation4/5

    Each tool targets a distinct action (read registers, check clocks, decode faults, audit .ioc, apply CubeMX config, check arch, scaffold, detect env, query SVD). The closest pair is mcu_svd_read vs mcu_svd_query and mcu_ioc_audit vs mcu_cubemx_apply, but descriptions clearly distinguish hardware-read vs offline-query and read-only-audit vs generate/apply.

    Naming Consistency5/5

    All tools use a uniform mcu_<verb>_<noun> snake_case pattern (svd_read, clock_check, fault_decode, ioc_audit, cubemx_apply, arch_check, detect_env, svd_query). No mixing of conventions or casing.

    Tool Count5/5

    Nine tools is well within the ideal 3-15 range and each maps to a concrete stage of an embedded workflow (detect, scaffold, configure, verify, decode). No obviously redundant or filler tools.

    Completeness4/5

    Coverage spans environment detection, scaffolding, SVD introspection, clock/fault verification, config audit and CubeMX application, which is a coherent lifecycle. The main gap is the absence of an explicit build/flash/serial-monitor tool, which agents would have to handle via shell.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      B
      maintenance
      Enables AI coding assistants to perform complete headless STM32 embedded firmware development, including project creation, pin configuration, code generation, building, and flashing, by driving the official STM32 command-line toolchain.
      4
      9
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables AI agents to directly inspect and debug embedded hardware: reading/writing serial ports and bus devices, auto-detecting baud rates, parsing Modbus/NMEA/custom binary frames, plus diagnosing failures through a 45-rule fault-pattern library, error-code tables, and compile/flash error translation. Also provides pin-conflict checking, register and Cortex-M fault decoding, pre-validated driver and component selection libraries, board knowledge, and guarded flashing with post-flash byte-level verification.
      59
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables AI agents to debug STM32 firmware on real hardware by driving GDB with OpenOCD/ST-Link/J-Link to flash, set breakpoints, inspect memory, registers and RTOS state, triage HardFaults, and profile. Returns decoded, structured evidence and suggested next actions instead of raw GDB text, with composite tools that collapse multi-step debug loops into single calls.
      86
      4
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables AI coding agents to build, flash, debug, and communicate with STM32 microcontrollers over ST-Link entirely within the conversation. Provides headless CubeIDE builds, OpenOCD flashing, hardware breakpoints, live SWD variable monitoring resolved by C symbol names, fault triage, and pooled serial VCP I/O with deterministic sequencing for hardware-in-the-loop tests.
      35
      MIT