Skip to main content
Glama

pyocd-debug-mcp

让 AI 全自动进行嵌入式单片机仿真调试的 MCP Server

通过 pyOCD + CMSIS-DAP 探针,为 Claude / GitHub Copilot 等 AI 工具提供 58 个调试工具,涵盖从连接探针、烧录固件、打断点、读寄存器到 HardFault 故障分析的完整调试流程。

✨ 核心能力

能力

说明

🔌 探针管理

自动发现 CMSIS-DAP 探针,连接/断开

⚡ 烧录

支持 .hex / .bin / .elf / .axf 固件烧录,烧录 ELF 自动附加符号

✅ Flash 校验

烧录后逐段对比验证,检测 Flash 损坏或烧录异常

🎯 断点 & 监视点

硬件断点 / 软件断点 / 自动选择(地址或符号名),数据监视点(读/写/读写)

🔄 断点恢复

Reset 后自动恢复所有断点(软件断点 Reset 后丢失,自动重设)

⏳ 等待机制

wait_halt — AI 打断点 → 运行 → 等待命中 → 分析

📊 变量采样

周期性采样全局变量,返回统计数据

💥 故障分析

HardFault/BusFault/UsageFault 全自动解析

📏 栈溢出检测

支持 RT-Thread / FreeRTOS TCB 栈边界检查

🔍 栈回溯

DWARF CFI / EHABI / 启发式三级容错,覆盖 AC5/AC6/GCC

🔧 寄存器 & 内存

读/写 CPU 寄存器、内存、外设寄存器(SVD),支持批量位域更新和枚举值

📋 符号解析

通过 ELF 文件将地址映射到函数名/变量名

📡 RTT 实时传输

SEGGER RTT 通道读写,免 UART 打印调试

🆕 地址格式

所有地址参数同时接受整数和十六进制字符串(如 "0x1FFE000E")

🆕 组合工具

read_symbol 一步读取变量值、step_out 执行到函数返回

Related MCP server: jlink-mcp

📦 安装

前置条件

  • Python ≥ 3.10

  • uv 包管理器(推荐)

  • CMSIS-DAP 兼容调试探针(DAPLink / STLINK 等)

方式一:从 GitHub 安装(推荐)

# 使用 uv
uv pip install git+https://github.com/konbakuyomu/pyocd-debug-mcp.git

# 使用 pip
pip install git+https://github.com/konbakuyomu/pyocd-debug-mcp.git

# 如需 SVD 字段级解析(可选)
uv pip install "pyocd-debug-mcp[svd] @ git+https://github.com/konbakuyomu/pyocd-debug-mcp.git"

方式二:本地开发安装

git clone https://github.com/konbakuyomu/pyocd-debug-mcp.git
cd pyocd-debug-mcp
uv sync          # 创建虚拟环境并安装依赖

HC32 系列芯片支持

HC32 芯片需要安装 CMSIS-Pack:

uv run pyocd pack install hc32f460
uv run pyocd pack install hc32f4a0

🔧 注册到 AI 工具

Claude Desktop

在 claude_desktop_config.json 中添加:

{
  "mcpServers": {
    "pyocd-debug": {
      "command": "uv",
      "args": [
        "--directory", "/path/to/pyocd-debug-mcp",
        "run", "pyocd-debug-mcp"
      ]
    }
  }
}

Claude Code (CLI)

claude mcp add pyocd-debug -- uv --directory /path/to/pyocd-debug-mcp run pyocd-debug-mcp

GitHub Copilot (VS Code)

在 .vscode/mcp.json 中添加:

{
  "servers": {
    "pyocd-debug": {
      "command": "uv",
      "args": [
        "--directory", "/path/to/pyocd-debug-mcp",
        "run", "pyocd-debug-mcp"
      ]
    }
  }
}

💡 将 /path/to/pyocd-debug-mcp 替换为你的实际路径。Windows 下使用 \\ 或 / 均可。

🛠️ 工具列表(58 个)

项目配置

工具名

说明

pyocd_project_load

🆕 加载项目配置(.pyocd-debug.json),或自动发现固件/ELF/SVD 文件

pyocd_project_init

🆕 创建 .pyocd-debug.json 配置文件(路径自动转相对路径)

pyocd_svd_attach_builtin

🆕 ⚠️ 从 pyocd 内置 SVD 临时回退(强烈建议改用厂商提供的完整 SVD)

探针 & 会话

工具名

说明

pyocd_probe_list

列出所有已连接的 CMSIS-DAP 调试探针

pyocd_probe_info

获取指定探针详细信息

pyocd_session_connect

连接探针并打开调试会话

pyocd_session_disconnect

断开调试会话,释放探针

pyocd_session_status

查看当前会话状态

烧录

工具名

说明

pyocd_flash_program

烧录固件(.hex / .bin / .elf / .axf),烧录 ELF/AXF 自动附加符号

pyocd_flash_erase

擦除 Flash

pyocd_flash_verify

🆕 校验 Flash 内容是否与固件文件一致(逐段对比)

目标控制

工具名

说明

pyocd_target_halt

暂停 CPU

pyocd_target_resume

恢复运行

pyocd_target_step

单步执行

pyocd_target_reset

复位 MCU(自动恢复所有断点)

pyocd_target_status

获取目标状态(运行/停止)及关键寄存器

pyocd_target_wait_halt

⏳ 等待目标停止(断点命中/监视点触发),支持 user_hint 提示

pyocd_target_step_out

🆕 执行到当前函数返回(自动设临时断点在 LR)

pyocd_target_list_supported

列出 pyOCD 支持的所有 MCU(206+)

寄存器 & 内存

工具名

说明

pyocd_register_read

读取 CPU 寄存器

pyocd_register_write

写入 CPU 寄存器

pyocd_register_read_all

读取全部寄存器(含 FPU)

pyocd_memory_read

读内存

pyocd_memory_write

写内存(带 readback 验证)

pyocd_memory_write_block

块写入

pyocd_memory_dump

Hex dump 格式输出

断点 & 监视点

工具名

说明

pyocd_breakpoint_set

设置断点(地址或符号名),支持 hw/sw/auto 三种类型

pyocd_breakpoint_clear

清除断点

pyocd_breakpoint_clear_all

清除所有断点

pyocd_breakpoint_list

列出当前断点

pyocd_watchpoint_set

设置数据监视点(读/写/读写触发)

pyocd_watchpoint_clear

清除监视点

pyocd_watchpoint_clear_all

清除所有监视点

pyocd_watchpoint_list

列出当前监视点

ELF 符号

工具名

说明

pyocd_elf_attach

加载 ELF 文件用于符号解析

pyocd_elf_lookup

按名称查找符号地址

pyocd_read_symbol

🆕 一步读取变量:符号查找 + 内存读取组合工具

pyocd_elf_symbols

列出 ELF 中的符号(函数/变量)

pyocd_elf_info

获取 ELF 文件信息

pyocd_elf_address_to_symbol

地址→符号反查(PC/LR→函数名+偏移)

SVD 外设寄存器

工具名

说明

pyocd_svd_attach

加载 SVD 文件

pyocd_svd_list_peripherals

列出所有外设

pyocd_svd_list_registers

列出外设的寄存器

pyocd_svd_read

按名称读外设寄存器(含位域解析)

pyocd_svd_write

按名称写外设寄存器

pyocd_svd_list_fields

列出寄存器的所有位域(名称、位范围、宽度)

pyocd_svd_set_field

设置单个位域值(RMW,支持枚举名或整数)

pyocd_svd_update_fields

🆕 批量设置多个位域(单次 RMW,原子操作)

pyocd_svd_describe

🆕 查看外设/寄存器详细描述(含枚举值定义)

高级调试

工具名

说明

pyocd_debug_fault_analyze

💥 分析 HardFault 崩溃(SCB 寄存器 + 异常栈帧 + EXC_RETURN + backtrace)

pyocd_debug_stack_overflow_check

📏 检查线程栈溢出(RT-Thread / FreeRTOS)

pyocd_debug_sample_variable

📊 周期性采样变量(如每 0.5s 采样 200 次)

pyocd_debug_backtrace

🔍 精确栈回溯 — DWARF CFI / EHABI / 启发式三级容错,覆盖 AC5/AC6/GCC

RTT 实时传输

工具名

说明

pyocd_rtt_start

🆕 启动 RTT 并发现通道(自动搜索 SEGGER RTT 控制块)

pyocd_rtt_stop

🆕 停止 RTT 并释放资源

pyocd_rtt_read

🆕 从 RTT 上行通道读取数据(非阻塞)

pyocd_rtt_write

🆕 向 RTT 下行通道写入数据

pyocd_rtt_status

🆕 查看 RTT 状态和通道信息

📋 项目配置(推荐)

在项目根目录创建 .pyocd-debug.json,AI 即可自动获取所有调试文件路径:

{
  "target": "hc32f4a0xi",
  "firmware": "build/usart_uart_dma_Debug/usart_uart_dma.hex",
  "elf": "build/usart_uart_dma_Debug/usart_uart_dma.axf",
  "svd": "HC32F4A0PIHB.svd"
}

也可让 AI 自动创建:

AI: pyocd_project_load("/path/to/project")    → 自动扫描发现文件
AI: pyocd_project_init("/path/to/project",    → 创建配置
      target="hc32f4a0xi",
      firmware="build/xxx.hex",
      elf="build/xxx.axf",
      svd="HC32F4A0PIHB.svd")

💡 配置中的路径会自动转为项目根目录的相对路径,方便版本控制。

SVD 文件查找策略

SVD 文件(外设寄存器描述)的查找遵循三级优先级:

  1. 配置文件指定(最佳):.pyocd-debug.json 中的 svd 字段 — 厂商提供的完整 SVD

  2. 项目目录扫描:自动在项目目录中递归查找 .svd / .xml 文件

  3. pyocd 内置回退(最后手段):pyocd_svd_attach_builtin — 从 pyocd 内置的 105 个通用 SVD 中匹配

⚠️ 强烈建议 从芯片厂商 SDK 获取与具体芯片型号匹配的 SVD 文件。内置 SVD 是通用简化版,可能缺少部分外设或引脚定义。

🚀 典型调试流程

以下是 AI 使用此 MCP Server 进行调试的典型对话流程:

1. 连接 → 烧录 → 运行到 main

AI: pyocd_probe_list                           → 发现探针
AI: pyocd_session_connect("hc32f460xe")        → 连接
AI: pyocd_flash_program("firmware.hex")        → 烧录
AI: pyocd_elf_attach("firmware.elf")           → 加载符号
AI: pyocd_breakpoint_set(symbol="main")        → 在 main 打断点
AI: pyocd_target_reset(halt=true)              → 复位并停止
AI: pyocd_target_wait_halt(timeout=10)         → 等待命中 main

2. 串口数据调试(等待断点)

AI: pyocd_breakpoint_set(symbol="UART_RxCallback")
AI: pyocd_target_wait_halt(timeout=60)         ← 等待数据到来
    ... 60s 内数据到达,断点命中 ...
AI: pyocd_memory_dump(rx_buffer_addr, 64)      → 查看接收缓冲区
AI: pyocd_register_read_all()                  → 查看寄存器现场

3. 周期性变量监控

AI: pyocd_debug_sample_variable(
      address=0x20001000,   # 全局变量地址
      interval=0.5,          # 每 0.5s
      count=200              # 共 200 次 = 100s
    )
→ 返回所有采样值 + min/max/变化统计

4. HardFault 崩溃分析

AI: pyocd_debug_fault_analyze()
→ 返回:
  - fault_type: "BusFault"
  - fault_address: "0x40012400"
  - active_faults: [PRECISERR, BFARVALID]
  - exception_frame: {PC_fault, LR_saved, R0-R3, ...}
  - exc_return: {stack_used: "PSP", fpu_context: ...}

5. 野指针/数组越界追踪

AI: pyocd_watchpoint_set(
      address=0x20002000,    # 数组末尾地址
      size=4,
      access_type="write"    # 监控越界写入
    )
AI: pyocd_target_wait_halt(timeout=30)
    ... 越界写入发生,DWT 触发停止 ...
AI: pyocd_target_status()                      → 查看 PC 定位到写入指令
AI: pyocd_debug_backtrace()                    → 查看完整调用链

6. 精确栈回溯(三级容错,全工具链覆盖)

AI: pyocd_debug_backtrace(max_frames=16)
→ 返回:
  frames:
    [0] USART_RxCallback+0x1A          (pc=0x0800135C)
    [1] DMA_IrqHandler+0x18            (unwound via DWARF CFI)
    [2] main+0x42                      (unwound via DWARF CFI)
  method: "dwarf_cfi"                   ← AC6/GCC: .debug_frame 精确展开
  method: "ehabi"                       ← AC5: .ARM.exidx 精确展开
  method: "heuristic"                   ← 无调试信息时: 栈扫描 + BL 验证

# wait_halt 断点命中时自动附带简短 backtrace:
AI: pyocd_target_wait_halt(timeout=30)
→ { ..., "backtrace": ["UART_RxCallback", "DMA_IrqHandler+0x18", "main+0x1A"] }

# fault_analyze 崩溃时自动附带 backtrace:
AI: pyocd_debug_fault_analyze()
→ { ..., "backtrace": ["HardFault_Handler", "memcpy+0x12", "cJSON_Parse+0x8A", ...] }

🆕 地址格式灵活性

所有接受地址参数的工具(共 11 个)同时支持整数和十六进制字符串:

# 两种格式等价
AI: pyocd_memory_read(address=0x20000000, size=16)
AI: pyocd_memory_read(address="0x20000000", size=16)

# 断点也支持
AI: pyocd_breakpoint_set(address="0x0800135C")

# 监视点同理
AI: pyocd_watchpoint_set(address="0x20001000", access_type="write")

🆕 组合工具

# read_symbol: 一步读取变量(自动查找地址 + 读取内存 + 类型推断)
AI: pyocd_read_symbol(name="g_rxBuffer")
→ { "name": "g_rxBuffer", "address": "0x20000100", "size": 64,
     "hex_dump": "48 65 6C 6C 6F ...", "as_string": "Hello..." }

# step_out: 执行到当前函数返回
AI: pyocd_target_step_out(timeout=5.0)
→ { "status": "returned", "from_function": "UART_RxCallback",
     "returned_to": "DMA_IrqHandler+0x18" }

🏗️ 项目结构

pyocd-debug-mcp/
├── pyproject.toml              # 项目配置和依赖
├── src/pyocd_debug_mcp/
│   ├── server.py               # MCP Server 入口,58 个工具注册
│   ├── session_manager.py      # 会话生命周期管理(单例)
│   └── tools/
│       ├── probe.py            # 探针发现
│       ├── target.py           # 目标控制
│       ├── flash.py            # Flash 烧录 + 校验
│       ├── register.py         # 寄存器读写
│       ├── memory.py           # 内存读写
│       ├── breakpoint.py       # 断点管理(HW/SW/AUTO + Reset 恢复)
│       ├── watchpoint.py       # 监视点管理
│       ├── elf.py              # ELF 符号解析
│       ├── svd.py              # SVD 外设寄存器(含批量更新、枚举、描述)
│       ├── rtt.py              # RTT 实时传输(SEGGER RTT 通道读写)
│       ├── debug.py            # 高级调试(故障分析、栈回溯、栈检查、采样)
│       └── project.py          # 项目配置(.pyocd-debug.json 管理)
└── tests/

⚙️ 支持的硬件

  • 调试探针: 所有 CMSIS-DAP 兼容探针(DAPLink、STLINK via pyOCD、J-Link via pyOCD)

  • MCU: pyOCD 支持的 206+ 种芯片,包括:

    • HDSC/XHSC: HC32F460、HC32F4A0 等

    • STMicroelectronics: STM32F0/F1/F2/F3/F4/F7/H7/L0/L4/G0/G4 等

    • Nordic: nRF52832、nRF52840、nRF9160 等

    • NXP: LPC、Kinetis、i.MX RT 等

    • 更多: pyocd_target_list_supported 查看完整列表

📄 License

MIT

Available Tools

58 tools
pyocd_breakpoint_clearB

Remove a breakpoint at an address or symbol.

Inputs: symbol, address. Returns: result

pyocd_breakpoint_clear_allA

Remove all active breakpoints.

Inputs: no named parameters. Returns: result

pyocd_breakpoint_listA

List all active breakpoints.

Inputs: no named parameters. Returns: result

pyocd_breakpoint_setA

Set a hardware breakpoint at an address or symbol name (requires ELF). Supports hw (hardware), sw (software), or auto breakpoint types. Software breakpoints survive across more addresses but are lost on reset; hardware breakpoints are limited in number but don't modify flash.

Inputs: symbol, address, bp_type. Returns: result

pyocd_debug_backtraceA

Perform precise stack backtrace to show the full call chain. Uses DWARF CFI (.debug_frame) or EHABI (.ARM.exidx) for frame-accurate unwinding across all ARM toolchains (AC5/AC6/GCC). Falls back to heuristic stack scanning with BL validation if precise unwinding fails. Returns ordered frames: depth 0 = current PC, deeper = callers. Essential for understanding HOW code reached the current point.

Inputs: max_frames, scan_depth. Returns: result

pyocd_debug_fault_analyzeA

Analyze a HardFault/BusFault/MemManage/UsageFault/SecureFault crash. Reads all SCB fault registers, decodes fault bits, reads the exception stack frame to find the fault PC (crash address) and caller LR. Also decodes EXC_RETURN for FPU/MSP/PSP context. Call this when target is halted in a fault handler.

Inputs: no named parameters. Returns: result

pyocd_debug_sample_variableA

Periodically sample a memory location (global variable). Reads a variable every N seconds for M samples while target is running. Returns all samples with timestamps and statistics. Sends progress notifications to prevent AI client timeouts during long sampling sessions.

Inputs: address (required), size, count, interval, +1 more. Returns: result

pyocd_debug_stack_overflow_checkA

Check if a thread's stack has overflowed by comparing SP against the TCB's stack bounds. For RT-Thread: provide TCB address, offsets default to 0x24 (stack_addr) and 0x28 (stack_size). Reports usage percentage and watermark integrity.

Inputs: tcb_address, stack_addr_offset, stack_size_offset. Returns: result

pyocd_elf_address_to_symbolA

Resolve a memory address to its symbol name (function or variable). Essential for interpreting PC, LR, and stack return addresses during debugging. Returns function name + offset (e.g. 'main+0x1A').

Inputs: address (required). Returns: result

pyocd_elf_attachA

Attach an ELF file for symbol resolution. Enables using function names for breakpoints and provides richer debug info. Note: For flashing, prefer .hex format over .elf for armclang compatibility.

Inputs: elf_path (required). Returns: result

pyocd_elf_infoA

Get information about the attached ELF file (arch, entry point, sections).

Inputs: no named parameters. Returns: result

pyocd_elf_lookupB

Look up a symbol's address by name.

Inputs: name (required). Returns: result

pyocd_elf_symbolsB

List symbols (functions/variables) from the attached ELF file.

Inputs: limit, filter_text. Returns: result

pyocd_flash_eraseA

Erase the target flash memory (chip erase or sector erase). Sends progress notifications to prevent AI client timeouts.

Inputs: chip_erase. Returns: result

pyocd_flash_programA

Program a firmware file (.hex/.bin/.elf) to the target flash. For armclang-compiled firmware, prefer .hex format to avoid ELF compatibility issues. When programming a .elf or .axf file, automatically attaches it for symbol resolution. Sends progress notifications to prevent AI client timeouts during programming.

Inputs: file_path (required), erase. Returns: result

pyocd_flash_verifyA

Verify the target's Flash content matches a firmware file. Reads Flash and compares segment by segment. Supports .hex, .bin, .elf, and .axf formats. Returns verified:true if match, or first mismatch address if different. Sends progress notifications to prevent AI client timeouts during verification.

Inputs: file_path (required), base_address. Returns: result

pyocd_memory_dumpA

Dump memory in hex dump format (address, hex bytes, ASCII). Useful for inspecting data structures.

Inputs: address (required), length. Returns: result

pyocd_memory_readC

Read memory at a given address. Returns hex value.

Inputs: address (required), size. Returns: result

pyocd_memory_writeB

Write a value to memory at a given address.

Inputs: value (required), address (required), size. Returns: result

pyocd_memory_write_blockC

Write a block of bytes to memory.

Inputs: data (required), address (required). Returns: result

pyocd_probe_infoB

Get detailed information about a specific debug probe.

Inputs: unique_id (required). Returns: result

pyocd_probe_listA

List all connected CMSIS-DAP debug probes. Call this first to discover available probes.

Inputs: no named parameters. Returns: result

pyocd_project_initA

Create .pyocd-debug.json config file in a project directory. Stores target type, firmware, ELF, SVD, and probe paths so that debug sessions can be started reliably without manual file discovery. Paths under the project directory are automatically converted to relative paths.

Inputs: target (required), project_dir (required), elf, svd, +2 more. Returns: result

pyocd_project_loadA

Load project debug configuration from .pyocd-debug.json, or auto-discover firmware/ELF/SVD files if no config exists. Call this FIRST before any debug session to get file paths. Returns target type, firmware path, ELF path, SVD path, and probe ID.

Inputs: project_dir (required). Returns: result

pyocd_read_symbolA

Read a global variable's value by symbol name. Combines ELF symbol lookup and memory read in one call. Returns address, raw bytes, and interpreted value. For structs/arrays, returns a hex dump.

Inputs: name (required), size. Returns: result

pyocd_register_readA

Read a CPU core register by name (e.g. 'pc', 'sp', 'r0', 'xpsr').

Inputs: name (required). Returns: result

pyocd_register_read_allA

Read all CPU core registers at once. Useful for getting full CPU state.

Inputs: include_fpu. Returns: result

pyocd_register_writeB

Write a value to a CPU core register.

Inputs: name (required), value (required). Returns: result

pyocd_rtt_readA

Read data from an RTT up channel. Returns text (decoded) and hex. Non-blocking: returns empty if no data available.

Inputs: channel, encoding, max_bytes. Returns: result

pyocd_rtt_startA

Start RTT (Real-Time Transfer) and discover channels. Searches target RAM for the SEGGER RTT control block. Returns up/down channel names and sizes. Target must be halted or have RTT initialized.

Inputs: size, address, control_block_id. Returns: result

pyocd_rtt_statusA

Get RTT status: running/stopped, channel info, bytes available.

Inputs: no named parameters. Returns: result

pyocd_rtt_stopA

Stop RTT and release resources.

Inputs: no named parameters. Returns: result

pyocd_rtt_writeA

Write data to an RTT down channel. The data string is encoded before sending. Returns bytes written.

Inputs: data (required), channel, encoding. Returns: result

pyocd_session_connectA

Connect to a debug probe and open a debug session. Must be called before any target/register/memory operations. Only one session can be active at a time.

Inputs: target_type (required), probe_id, frequency. Returns: result

pyocd_session_disconnectA

Close the current debug session and release the probe.

Inputs: resume_on_disconnect. Returns: result

pyocd_session_statusA

Check if a debug session is active and get connection info.

Inputs: no named parameters. Returns: result

pyocd_svd_attachA

Attach an SVD file for peripheral register access. SVD files describe the register layout of MCU peripherals (GPIO, UART, SPI, etc).

Inputs: svd_path (required). Returns: result

pyocd_svd_attach_builtinA

Attach a built-in SVD from pyocd's bundled svd_data.zip as a TEMPORARY fallback. ⚠️ Built-in SVDs are generic/simplified versions that may lack peripheral definitions specific to your exact chip variant/package. STRONGLY RECOMMENDED: use a vendor-provided SVD file via pyocd_svd_attach() instead. Only use this as a last resort when no vendor SVD is available. Extracts the SVD to a temp directory and attaches it.

Inputs: svd_name (required), target_type. Returns: result

pyocd_svd_describeA

Return full description of a peripheral or specific register. Without register_name, lists all registers with descriptions. With register_name, shows all fields with bit ranges, descriptions, and enumerated values.

Inputs: peripheral (required), register. Returns: result

pyocd_svd_list_fieldsA

List all bit fields of a peripheral register, showing name, bit range, width, and description.

Inputs: register (required), peripheral (required). Returns: result

pyocd_svd_list_peripheralsA

List all peripherals defined in the attached SVD file.

Inputs: no named parameters. Returns: result

pyocd_svd_list_registersA

List all registers of a specific peripheral.

Inputs: peripheral (required). Returns: result

pyocd_svd_readA

Read a peripheral register by name. Returns value with bit-field decoding. Example: pyocd.svd.read('GPIOA', 'IDR') to read GPIO input data register.

Inputs: register (required), peripheral (required). Returns: result

pyocd_svd_set_fieldA

Set a single bit field of a peripheral register using read-modify-write. Only the specified field is changed; other fields are preserved. Example: set_field('GPIOA', 'MODER', 'MODER0', 1) sets pin 0 to output mode.

Inputs: field (required), value (required), register (required), peripheral (required). Returns: result

pyocd_svd_update_fieldsA

Set multiple bit fields of a register in a single read-modify-write. Accepts a dict mapping field names to integer values or enum name strings. All fields are updated atomically. Example: update_fields('GPIOA', 'MODER', {'MODER0': 1, 'MODER1': 2})

Inputs: fields (required), register (required), peripheral (required). Returns: result

pyocd_svd_writeB

Write a value to a peripheral register by name.

Inputs: value (required), register (required), peripheral (required). Returns: result

pyocd_target_haltA

Halt (pause) the target CPU immediately. Returns current PC.

Inputs: no named parameters. Returns: result

pyocd_target_list_supportedA

List all MCU targets supported by pyocd (206+ built-in targets). Includes HC32, STM32, NXP, Nordic, Cypress and more. Use filter_text to search (e.g. 'hc32', 'stm32f4').

Inputs: filter_text. Returns: result

pyocd_target_resetA

Reset the target MCU. By default resets and halts at the entry point.

Inputs: halt_after. Returns: result

pyocd_target_resumeA

Resume target execution (run until next breakpoint or halt).

Inputs: no named parameters. Returns: result

pyocd_target_statusA

Get current target state (halted/running) and key registers if halted.

Inputs: no named parameters. Returns: result

pyocd_target_stepA

Single-step the target CPU. Target must be halted first.

Inputs: count. Returns: result

pyocd_target_step_outA

Execute until the current function returns (step out). Sets a temporary breakpoint at the LR (return address), resumes, waits for the breakpoint hit, then cleans up. Returns the new position after returning from the function.

Inputs: timeout. Returns: result

pyocd_target_wait_haltA

Resume target execution and wait for it to halt (breakpoint hit, watchpoint triggered, or manual halt). This is the KEY tool for 'set breakpoint → run → wait for hit → inspect' debugging workflow. Returns halt reason, PC, and registers when the target stops. Sends progress notifications to prevent AI client timeouts during long waits. Automatically includes a compact backtrace (top 4 frames) showing the call chain when halted. Also detects CPU LOCKUP state (double fault) immediately.

Inputs: timeout, user_hint, resume_first. Returns: result

pyocd_watchpoint_clearB

Remove a watchpoint at the given address.

Inputs: address (required). Returns: result

pyocd_watchpoint_clear_allA

Remove all active watchpoints.

Inputs: no named parameters. Returns: result

pyocd_watchpoint_listA

List all active watchpoints.

Inputs: no named parameters. Returns: result

pyocd_watchpoint_setA

Set a hardware watchpoint (data breakpoint). Triggers a halt when the target reads/writes a specific memory address. Essential for catching wild pointers, buffer overflows, and unexpected memory writes. Cortex-M4 typically has 4 DWT comparators available.

Inputs: address (required), size, access_type. Returns: result

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A3.8/5.0

    Scored across 58 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose within its category (breakpoints, debug analysis, ELF, flash, memory, probes, project, RTT, session, SVD, target, watchpoints). Descriptions are detailed and unique, preventing confusion.

    Naming Consistency5/5

    All tool names follow a consistent pyocd_<category>_<action> pattern in snake_case, e.g., pyocd_breakpoint_set, pyocd_debug_backtrace. The convention is uniform across all 58 tools.

    Tool Count3/5

    The server has 58 tools, which is high for an MCP server. While the domain (embedded debugging) is broad and each tool serves a specific function, this count is on the heavy side and may be overwhelming, slightly exceeding the ideal range.

    Completeness5/5

    The tool surface covers the complete debugging workflow: breakpoints, watchpoints, flash programming, memory/register access, SVD peripherals, RTT, project config, and target control. No obvious gaps for typical debug operations.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Enables AI to directly control SEGGER J-Link embedded debug probes via the Model Context Protocol for debugging and firmware management. Users can perform tasks like reading registers, analyzing memory, flashing firmware, and tracking RTT logs using natural language commands.
      21
      1
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      Enables AI assistants like Claude to directly debug microcontrollers via JLink, supporting breakpoints, single-step, memory/register access, variable inspection, RTT logging, and firmware flashing.
      25
      7
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI assistants to debug ARM Cortex-M targets via GDB and OpenOCD, supporting attach, breakpoints, stepping, register/memory inspection, and SVD peripheral decoding.
      MIT
    • A
      license
      B
      quality
      B
      maintenance
      Enables AI assistants to debug embedded devices via SEGGER J-Link probes, including reading memory, flashing firmware, streaming RTT logs, and diagnosing crashes.
      48
      118 npm
      43
      MIT