em-debug MCP Server
by RoadToSea
README.md
# EM-Debug
<div align="center">
**Next-Generation Embedded Debugger Suite Built on probe-rs**
*A unified, zero-toolchain debugging solution: Full-featured VS Code extension for humans + 37 MCP tools for AI agents.*
[](https://github.com/RoadToSea/em-probe/actions/workflows/ci.yml)
[](LICENSE)
[](https://nodejs.org/)
[](https://pnpm.io/)
[](https://probe-rs.com/)
[](https://modelcontextprotocol.io/)
</div>
---
## π Highlights
* **Zero-Toolchain Setup**: Powered by an automatic cross-platform `probe-rs` binary resolver (`ProbeRsBinaryManager`). No external GDB, OpenOCD, Python, or proprietary vendor drivers required.
* **Single-Connection Session Hub**: Eliminates the classic USB probe exclusivity conflict (`Device is busy`). Human developers in VS Code and AI Agents over MCP share the exact same hardware session.
* **37 Production-Grade MCP Tools**: Full suite inherited and upgraded from [cortex-debug-mcp](https://github.com/your-username/cortex-debug-mcp), providing execution control, memory inspection, live CoreSight AP access, and firmware-free peripheral bringup.
* **Intelligent Crash Diagnostics**: Native ARMv7-M `capture_fault` tool decodes `EXC_RETURN`, stacked exception frames, and SCB fault status registers (CFSR, HFSR, MMFAR, BFAR) to pinpoint the exact crash source line in milliseconds.
* **Dual-Mode Operation**:
- **Collaborative Mode**: Embedded within the VS Code extension host; F5 debug sessions are instantly queryable by connected AI agents.
- **Headless Mode**: Standalone CLI runtime (`npx @em-debug/mcp-server`) for automated CI/CD and terminal agents.
* **Broad Hardware Support**: First-class support for ARM Cortex-M (M0 through M55) and RISC-V (RV32/RV64) via J-Link, CMSIS-DAP/DAPLink, ST-Link (v2/v3), FTDI, and ESP32 USB-JTAG.
---
## ποΈ Architecture
```
+-----------------------------------+
| Target Board (MCU) |
| (ARM Cortex-M / RISC-V) |
+-----------------+-----------------+
| SWD / JTAG
+-----------------+-----------------+
| Hardware Probe (J-Link / DAP) |
+-----------------+-----------------+
| USB (Exclusive Owner)
+-----------------+-----------------+
| probe-rs dap-server |
+-----------------+-----------------+
| DAP JSON-RPC
+-----------------+-----------------+
| Session Hub (Single State Hub) |
+--------+-----------------+--------+
| |
Internal DAP | | MCP JSON-RPC
v v
+-------------------+ +-------------------+
| VS Code Extension| | MCP Server |
| - SVD Tree View | | - Streamable HTTP|
| - RTT Terminal | | - stdio proxy |
| - Debug Adapter | | - 37 AI Tools |
+-------------------+ +-------------------+
```
---
## π Quick Start
### 1. Prerequisites
* Node.js `>= 20.0.0`
* pnpm `>= 9.0.0`
### 2. Build from Source
```bash
git clone https://github.com/RoadToSea/em-probe.git
cd em-debug
pnpm install
pnpm build
pnpm test
```
### 3. Launching the Headless MCP Server
#### Streamable HTTP (Default: `http://127.0.0.1:7580/mcp`)
```bash
node packages/mcp-server/bin/em-debug-mcp.js --port=7580
```
#### Stdio Mode (for Claude Code, Cursor, etc.)
```bash
node packages/mcp-server/bin/em-debug-mcp.js --stdio
```
---
## π Connecting AI Agents
### Claude Code CLI
Add to your `~/.claude.json` or project configuration:
```json
{
"mcpServers": {
"em-debug": {
"command": "node",
"args": ["D:/Vscode/code/em-debug/packages/mcp-server/bin/em-debug-mcp.js", "--stdio"]
}
}
}
```
### Cursor / Windsurf / Antigravity (Streamable HTTP)
Connect to the loopback HTTP endpoint when the VS Code extension or headless server is running:
```json
{
"mcpServers": {
"em-debug": {
"url": "http://127.0.0.1:7580/mcp"
}
}
}
```
---
## π¦ Package Workspace Structure
| Package | Directory | Description |
| :--- | :--- | :--- |
| **`@em-debug/probe-rs-core`** | [`packages/probe-rs-core`](packages/probe-rs-core) | Core probe-rs binary resolution, DAP protocol client, and session management hub. |
| **`@em-debug/svd-parser`** | [`packages/svd-parser`](packages/svd-parser) | CMSIS-SVD XML model parser with peripheral inheritance and bitfield decoder. |
| **`@em-debug/mcp-server`** | [`packages/mcp-server`](packages/mcp-server) | Standalone and embedded MCP server exposing 37 embedded debugging tools. |
| **`em-debug`** | [`packages/vscode-extension`](packages/vscode-extension) | VS Code frontend extension hosting the DAP proxy, SVD TreeView, and RTT terminal. |
---
## π Documentation
* π **[DESIGN.md](DESIGN.md)** β Comprehensive architecture design specification and protocol contracts.
* πΊοΈ **[docs/ARCHITECTURE.md](docs/ARCHITECTURE.md)** β Architectural component mapping and sequence flows.
* π¬ **[docs/PROBE_RS_ANALYSIS.md](docs/PROBE_RS_ANALYSIS.md)** β In-depth comparison with official probe-rs ecosystem and design pattern adoption.
* π οΈ **[docs/TOOLS.md](docs/TOOLS.md)** β Complete reference manual for all 37 MCP tools with schemas and examples.
* π» **[docs/DEVELOPMENT.md](docs/DEVELOPMENT.md)** β Local development environment setup and extension packaging.
* π€ **[CONTRIBUTING.md](CONTRIBUTING.md)** β Contribution guidelines and pull request process.
* π **[CHANGELOG.md](CHANGELOG.md)** β Project release history and upgrade notices.
---
## π License
This project is licensed under the [MIT License](LICENSE).
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo issues