Smolmux Gdb Mcp

io.github.magnusmalm由 GitHub 帳號 magnusmalm 發布v0.5.2更新於 Oct 24, 2026

GDB/SWD MCP server over a smolmux broker: breakpoints, memory, Cortex-M fault decode, board probing.

已驗證STDIO僅桌面開發者工具安全與監控

概覽

AI 產生的概覽

本機 MCP 伺服器,透過執行中的 smolmux broker 對嵌入式板卡進行 GDB/SWD 除錯:中斷點、記憶體、暫存器與 Cortex-M 故障解碼。

可以做什麼
  • 設定、列出與管理中斷點,單步、繼續執行並讀取呼叫堆疊
  • 讀寫目標記憶體、求值運算式並檢視帶名稱標籤的暫存器
  • 解碼故障暫存器,並在核心支援時讀取周邊暫存器
  • 中斷執行中的目標,探測未知的 ARM Cortex-M 板卡,辨識晶片並產生初始裝置設定檔
適用情境
適合讓助理透過 SWD/GDB 除錯真實板卡上的韌體,例如單步執行程式碼、檢視記憶體與暫存器,或對不熟悉的 Cortex-M 板卡進行開機除錯並產生裝置設定檔。
執行需求
需要一台本機 Linux 機器,並有一個持有 GDB 連線(以 GDB 選項啟動)的執行中 smolmux broker,以及 GDB 程式與除錯探針連線。伺服器需從原始碼以 CMake、C11 編譯器與含 kconfiglib 的 Python 3 建置,且建置時須啟用 GDB 功能。未宣告帳號或 API 金鑰。
安裝前請注意
此伺服器會操作真實硬體:可暫停、重置、寫入記憶體與暫存器並改變裝置狀態。broker 的線路協定為明文,任何完成握手的用戶端都能取得裝置的完整控制權,因此應將綁定位址保持在回環位址並使用驗證權杖,而不要關閉驗證。broker 的 I/O 記錄檔會記錄與裝置之間收發的所有內容,包括在登入提示輸入的任何內容。除非明確允許,GDB 的 shell、python 與 eval 預設關閉。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Smolmux Gdb Mcp,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

smolmux

[Smolmux Gdb MCP on mcprush]

A portable C11 device multiplexer. Holds a device connection open (serial UART, GDB stub) and multiplexes access to multiple clients over Unix sockets using newline-delimited JSON.

Single static binary, low latency, small footprint - built for daily serial and GDB bring-up on Linux.

New here? docs/START-HERE.md is a one-screen router - find your intent (run it, bring up a new board with an AI agent, understand the architecture, hack on the code) and it points you to the right doc.

One port, three clients

[smolmux on an ESP32-S3: smolmux-monitor in the top pane; in the bottom pane a script sends a command and waits for the reboot, then esptool borrows the port through with-port]

One broker holds an ESP32-S3's UART. The monitor (top) watches it live. In the bottom pane a script sends temp and gets the reply on the same wire, resets the board and waits for its prompt, then esptool reads the flash ID through with-port: the broker suspends, esptool runs, the broker resumes, and the monitor never loses the port.

Example: probe an unknown board

One broker holds SWD; smolmux-gdb-mcp runs probe_unknown_board. On a SAM C21 Xplained Pro that path decoded Cortex-M0+ from CPUID, named the part via SAM DSU DID, rejected a false STM32 match, and wrote a starter *.gdb-profile.json. Tools, register values, and profile shape: docs/demo-samc21-probe-transcript.md.

Day-to-day serial (multi-client, U-Boot break-in, flasher handoff): docs/daily-driver.md.

Features

  • Serial UART, GDB MI, and serial-over-TCP (telnet + RFC2217) device links via vtable polymorphism
  • Multiple concurrent clients over Unix sockets with role-based access (observer/controller/takeover)
  • Expect engine - concurrent regex matching on the device byte stream with timeouts
  • Anomaly detection - pattern-based crash/error detection with cooldown and incident tracking
  • Output history - timestamped ring buffer for replay by late-joining clients
  • Structured logging - JSONL I/O log + human-readable text log with rotation (the I/O log records everything sent to and from the device, including anything typed at a login prompt — it is created 0600 under your private state directory, and smolmux refuses to write it through a symlink or to a file owned by another user)
  • Network sinks - TCP and WebSocket for remote access (loopback by default). The wire protocol is cleartext, and any client that completes the handshake gets full control of the device — console writes, pins, BREAK, SysRq, GDB. On loopback without --auth-token, the broker generates a token into a 0600 file in $XDG_RUNTIME_DIR (or /tmp), so other local users and processes cannot connect; your own smolmux-monitor / smolmux-mcp read it automatically, and smolmux-cli token prints it. For remote use, keep the bind on loopback and reach it over an SSH tunnel or WireGuard rather than exposing the port; smolmux refuses to serve a non-loopback TCP bind with no --auth-token. --insecure-no-auth turns both protections off.
  • MCP servers - standalone smolmux-mcp / smolmux-gdb-mcp attach to a running broker; optional in-process --mcp sink for single-process stdio
  • Boot tracking & autoresponder - ordered boot stages, stall events, standing expect->send rules
  • Autoboot interrupt - broker-side key flood (and optional DTR/RTS reset) for bootdelay=0 U-Boot
  • Device profiles / board manifests - JSON configs for prompts, anomalies, multi-wire boards
  • Auto-reconnect - exponential backoff recovery on USB-serial disconnect
  • Build-time feature selection - Kconfig-based; UART-only builds carry no GDB/TCP/WebSocket code

Quick start

Prerequisites: Linux, a C11 compiler, CMake 3.21+, Python 3 with kconfiglib (the configure step generates the feature header with it). libpcre2-8 is optional; without it regex matching falls back to POSIX.

bash
# Debian/Ubuntusudo apt install build-essential cmake python3 python3-pip libpcre2-devpip install kconfiglib   # or in a venv; Debian's system Python may need                         # --break-system-packages
bash
cmake -B build && cmake --build build -j$(nproc)./build/smolmux /dev/ttyUSB0

Connect a client:

bash
# Needs a running broker (above). Auto-discovers the socket from the port name../build/smolmux-monitor /dev/ttyUSB0

Day-to-day workflows (profiles, logs, U-Boot break-in, multi-wire boards): docs/daily-driver.md. Intent router: docs/START-HERE.md.

Build

bash
cmake -B build && cmake --build build -j$(nproc)   # Default (all features)ctest --test-dir build                               # Run tests

Feature profiles

bash
cp configs/defconfig.minimal .config && cmake -B build    # UART only, no sinks/watchercp configs/defconfig.uart .config && cmake -B build       # UART + MCP sink + watchercp configs/defconfig.embedded .config && cmake -B build   # Embedded target profilecp configs/defconfig.full .config && cmake -B build       # Everything (GDB, TCP, WS, MCP, watcher)

Or toggle features directly:

bash
cmake -B build -DSM_ENABLE_GDB=OFF -DSM_ENABLE_SINK_WS=OFF

Developer benchmarks (e.g. the output coalescer harness) are off by default:

bash
cmake -B build -DSM_BUILD_BENCH=ON && cmake --build build --target bench_coalesce

Interactive configuration:

bash
cmake --build build --target menuconfig

Static builds

bash
cmake -B build -DSM_MUSL_STATIC=ON    # Fully static musl binary (zero runtime deps)cmake -B build -DSM_STATIC=ON         # Static linking (except glibc)

Usage

smolmux <port> [options]
Options:  -b, --baud <rate>           Baud rate (default: 115200)  -s, --socket <path>         Unix socket path  -l, --log-dir <dir>         I/O log directory                              (default: $XDG_STATE_HOME/smolmux or                               ~/.local/state/smolmux)  -t, --text-log-dir <dir>    Text log directory  -p, --profile <path>        Device profile JSON file  --board <name>              Group this wire under a board (for discovery)  --role <label>              This wire's role on the board (console, swd, ...)  --gdb                       Use GDB MI link instead of UART  --gdb-path <path>           Path to gdb binary (default: gdb)  --gdb-target <spec>         GDB target (e.g., localhost:3333)  --serial-tcp <host:port>    Connect to a serial-over-TCP device server                              (ser2net, socat, terminal server; telnet +                              RFC2217 baud/DTR/RTS/break control)  --mcp                       Enable in-process MCP stdio sink (prefer standalone                              smolmux-mcp against a daemon broker for daily use)  --tcp-port <port>           Enable TCP sink (default: 5555)  --tcp-bind <addr>           TCP bind address (default: 127.0.0.1)  --auth-token <token>        Require token in hello from TCP clients                              (prefer env SMOLMUX_AUTH_TOKEN - hidden from ps)  --auth-token-file <path>    Read the token from a file  --insecure-no-auth          Serve TCP/WS with no token. Without it, a                              loopback listener gets a generated token                              (0600 file; smolmux-cli token prints it) and                              a non-loopback --tcp-bind is refused.  --ws-port <port>            Enable WebSocket sink (default: 5556)  --no-text-log               Disable text log  --no-io-log                 Disable JSONL I/O log  --no-reconnect              Don't auto-reconnect on disconnect  --wait-device <seconds>     Wait for the device path before open  --gdb-allow-shell           Permit GDB shell/python/eval (off by default)  --list-ports                List available serial ports and exit  --list-profiles             List available device profiles and exit  --help-protocol             Show wire protocol documentation  -v, --verbose               Enable debug logging  -V, --version               Show version  -h, --help                  Show this help

Wire protocol

Newline-delimited JSON over Unix sockets (also TCP/WS sinks). Binary data is base64-encoded. Message set covers session control, expect, history, anomaly, boot stages, autoboot flood, and autoresponder.

Full reference: ./build/smolmux --help-protocol (always matches this binary).

Client -> Broker: hello, send, send_expect, takeover, release, status, pin_control, set_baud, suspend, resume, history_request, incidents_request, configure_anomaly, interrupt_autoboot, configure_autoresponder, autoresponders_request

Broker -> Client: welcome, output, input_echo, expect_result, status_response, error, history_response, incidents_response, anomaly, autoboot_result, boot_stage, boot_stall, autoresponders_response, autoresponder_fired, suspended, resumed, link_down, link_up

Example session:

json
-> {"type":"hello","name":"my-tool","role":"controller","protocol_version":1}<- {"type":"welcome","broker_version":"x.y.z","protocol_version":1,"port":"/dev/ttyUSB0","baud":115200,"your_role":"controller"}-> {"type":"send","id":"1","data":"dW5hbWUgLWEK"}<- {"type":"output","data":"TGludXggNC4xOS4w...","timestamp":1709654321.123}

Architecture

┌───────────┐  ┌───────────┐│ uart link │  │  gdb link │   <- device-facing, compiled in/out via Kconfig└─────┬─────┘  └─────┬─────┘      │              │      ▼              ▼┌──────────────────────────────┐│         smolmux core         │  <- epoll event loop, message bus,│  history · logging · anomaly │    role enforcement, expect engine└──┬───────┬───────┬───────┬───┘   │       │       │       │   ▼       ▼       ▼       ▼┌──────┐┌─────┐┌─────┐┌──────┐│ unix ││ tcp ││ ws  ││ mcp  │  <- sinks, also compiled in/out│socket││sink ││sink ││ sink │└──────┘└─────┘└─────┘└──────┘

See DESIGN.md for full architecture documentation.

Dependencies

Required: cJSON (vendored, single file)

Auto-detected: PCRE2 (libpcre2-8). Used as the regex engine when present, because it bounds backtracking internally; the build falls back to POSIX ERE automatically when it is absent, so it is never required. Force either way with -DSM_ENABLE_PCRE2=ON (error if missing) or -DSM_ENABLE_PCRE2=OFF.

Core has zero required external dependencies beyond POSIX + cJSON.

Companion tools

  • smolmux-cli - command-line client (send commands, read output; with-port <cmd> suspends the port, runs an external tool like a flasher, then always resumes)
  • smolmux-monitor - interactive terminal client with escape sequences (prefix key then a command; prefix defaults to Ctrl-], change with -e, e.g. -e esc or -e ^A)
  • smolmux-mcp - standalone MCP server: connects to a running broker and exposes serial tools (serial_send_command, serial_read, serial_boot_status, serial_add_autoresponder, ...). Alternative: broker --mcp sink embeds MCP in-process.
  • smolmux-gdb-mcp - standalone MCP server for GDB debugging: 21 tools over a broker holding a --gdb link - breakpoints, stepping, backtrace, name-labeled registers, memory, expression eval, fault-register decode (where the core has them), peripheral reads, gdb_interrupt, and unknown-board probing on ARM Cortex-M today (gdb_identify_target / gdb_generate_profile; other architectures are planned). Resources and prompts include smolmux-gdb://board-probing and probe_unknown_board. Built when SM_ENABLE_GDB is on; chip-ID validated on a SAM C21 Xplained Pro.
  • smolmux-watcher - daemon that monitors for anomalies and saves incident reports to disk

Related Documentation

Free vs Pro

Everything in this repository is MIT-licensed - full source, wire protocol, generic device profiles, build system. Build it yourself and you have the complete product.

smolmux Pro is convenience, not a feature gate: prebuilt static binaries (x86_64 + aarch64, musl, zero runtime dependencies), the curated profile pack with per-profile notes, and 6 months of email support. One-time purchase ($79). MCP setup for zip paths is docs/MCP-SETUP-FULL.md (also in this public tree).

Buy smolmux Pro - $79 one-time - download includes current static binaries and the profile pack.

License

MIT. cJSON is vendored under its own MIT license (deps/cJSON/LICENSE).

來源:README.md,提交 b846879

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

3
  1. v0.5.2最新Oct 4, 2026
  2. v0.5.1Oct 3, 2026
  3. v0.4.0Sep 30, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分