sbl-debugger

sbl-debugger

Enables AI assistants to debug ARM Cortex-M targets via GDB and OpenOCD, supporting attach, breakpoints, stepping, register/memory inspection, and SVD peripheral decoding.

Category
访问服务器

README

<!-- mcp-name: io.github.soundbytelabs/debugger -->

sbl-debugger

Embedded debug MCP server for ARM Cortex-M targets. Gives AI coding assistants direct control of GDB and OpenOCD — attach to hardware, set breakpoints, step through code, inspect registers and memory, all within a conversation.

Part of the Sound Byte Labs embedded tooling suite, alongside sbl-probe for serial I/O.

Installation

Create a virtual environment and install the package:

python3 -m venv .venv
source .venv/bin/activate

# Install
pip install -e .

# Or with test dependencies
pip install -e ".[dev]"

System Requirements

  • gdb-multiarch (GDB with ARM target support)
  • openocd (0.12.0+ recommended)
  • SWD debug probe (ST-LINK, CMSIS-DAP, etc.)

On Debian/Ubuntu/Raspberry Pi OS:

sudo apt install gdb-multiarch openocd

MCP Configuration

Register the server in your MCP client's config. For most clients, add to .mcp.json in your project root:

{
  "mcpServers": {
    "sbl-debugger": {
      "type": "stdio",
      "command": "/absolute/path/to/.venv/bin/python",
      "args": ["-m", "sbl_debugger"]
    }
  }
}

Important: Use the absolute path to the Python binary inside your virtual environment. For example: /home/you/sbl-debugger-mcp/.venv/bin/python

Restart your MCP client and the tools are available immediately.

Tools

Session Management

Tool Description
debug_attach Attach to a target — launches OpenOCD + GDB, connects via SWD
debug_detach Cleanly shut down a debug session
debug_sessions List all active debug sessions
debug_status Get current target state (halted/running, stop reason, current frame)
debug_targets List available predefined target profiles

Execution Control

Tool Description
halt Halt a running target
continue_execution Resume execution
wait_for_halt Block until target stops (breakpoint hit, etc.)
step Step source lines (into functions)
step_over Step source lines (over function calls)
step_out Step out of current function
step_instruction Step machine instructions
run_to Run to a location (sets temporary breakpoint + continues)
reset Reset the target (halt or run after reset)

Inspection

Tool Description
read_registers Read CPU registers (all core regs or specific subset)
write_register Write a CPU register
read_memory Read memory (hex, u8, u16, u32 formats)
write_memory Write to memory
backtrace Get the call stack
read_locals List local variables in current frame
print_expr Evaluate a C/C++ expression in target context
disassemble Disassemble at an address or current PC

Breakpoints

Tool Description
breakpoint_set Set breakpoint by function name, file:line, or address
breakpoint_delete Delete a breakpoint
breakpoint_list List all breakpoints and watchpoints
watchpoint_set Set a hardware data watchpoint (write/read/access)

Peripheral Registers (SVD)

Tool Description
list_peripherals List SVD peripherals with base addresses and register counts
list_registers Show all registers and bitfield definitions for a peripheral
read_peripheral_register Read a register from hardware and decode all bitfields
read_peripheral Read all registers of a peripheral with decoded bitfields

Requires cecrops (optional dependency) and SBL_HW_PATH environment variable pointing to sbl-hardware. Install with: pip install -e ".[svd]"

Snapshot & Advanced

Tool Description
debug_snapshot Full target state in one call (frame, registers, backtrace, locals, source)
load Flash firmware to the target
monitor Send raw OpenOCD monitor commands

Target Profiles

Predefined profiles eliminate the need to remember OpenOCD configs:

Profile Hardware Debug Probe
daisy Electrosmith Daisy Seed (STM32H750, Cortex-M7) ST-LINK
pico Raspberry Pi Pico (RP2040, Cortex-M0+) CMSIS-DAP Debug Probe
pico2 Raspberry Pi Pico 2 (RP2350, Cortex-M33) CMSIS-DAP Debug Probe
custom Any target Provide interface and target_cfg explicitly

Custom targets work with any OpenOCD-supported hardware:

debug_attach(target="custom", interface="jlink.cfg", target_cfg="stm32f4x.cfg", elf="firmware.elf")

Architecture

sbl_debugger/
├── server.py          # FastMCP server, tool wiring
├── targets.py         # Target profiles (daisy, pico, pico2)
├── session/
│   ├── manager.py     # Thread-safe session registry
│   └── session.py     # DebugSession (owns OpenOCD + GDB)
├── process/
│   ├── openocd.py     # OpenOCD subprocess lifecycle
│   └── ports.py       # GDB server port allocation
├── bridge/
│   ├── mi.py          # GDB/MI wrapper (pygdbmi + lock)
│   └── types.py       # FrameInfo, StopEvent, MiResult
├── svd/
│   ├── peripheral_db.py  # SVD lookup/decode (wraps cecrops Device)
│   └── loader.py         # SBL_HW_PATH resolution, cecrops import guard
└── tools/
    ├── session.py     # attach, detach, sessions, status, targets
    ├── execution.py   # halt, continue, step, reset
    ├── inspection.py  # registers, memory, backtrace, locals
    ├── breakpoints.py # breakpoint/watchpoint management
    ├── snapshot.py    # combined state dump
    ├── advanced.py    # load (flash), monitor (raw OpenOCD)
    └── peripheral.py  # SVD peripheral register decoding

Key design decisions:

  • Managed subprocesses — OpenOCD and GDB are launched, monitored, and cleaned up by the server. One debug_attach call does everything.
  • GDB/MI via pygdbmi — structured command/response interface, no string parsing of GDB CLI output
  • Single command lock — one MI command at a time prevents response interleaving
  • Explicit pollingwait_for_halt and debug_status check target state on demand, matching MCP's request/response model
  • Error dicts, not exceptions — tools return {"error": "..."} instead of crashing the server

Running Tests

pytest                    # 275 tests (all mocked, no hardware needed)
pytest -v                 # verbose
pytest tests/test_tools.py  # just tool tests

Dependencies

  • mcp — Official Python MCP SDK (FastMCP)
  • pygdbmi — GDB Machine Interface protocol
  • cecrops — SVD register definitions (optional, for peripheral tools)
  • Python >= 3.11

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选