dbgeng-mcp

An MCP server that drives the Windows debugger engine (dbgeng) for dynamic analysis.
git clone https://dittus.dev/git/dbgeng-mcp.git
Log | Files | Refs | README

README.md | Raw


dbgeng-mcp

An MCP server for dynamic analysis on Windows. It drives dbgeng, the engine behind WinDbg and cdb, so an MCP client can launch a program, attach to a process, or open a crash dump, then step, read memory and registers, set breakpoints, and run any WinDbg command.

How it is built

Three layers:

MCP client  <--stdio-->  server.py  <--JSON over a pipe-->  worker.py  --ctypes-->  dbgeng.dll
            (MCP)        (WSL or Win)                        (Windows Python)

Why a direct ctypes binding and not pykd

pykd is the usual way to script dbgeng from Python, but its newest published build targets Python 3.7. On a current Python it is not an option. A direct binding has no such constraint: it runs on whatever Python is installed and needs nothing beyond the Debugging Tools.

The cost is that the COM vtable layout is written out by hand. To keep that honest, _abi.py is generated from the Windows SDK's DbgEng.h by tools/gen_abi.py, so the method order and interface IDs match the dll that ships with that SDK. Regenerate it against your own header if the SDK moves:

python3 tools/gen_abi.py "/mnt/c/Program Files (x86)/Windows Kits/10/Include/<ver>/um/DbgEng.h"

Requirements

The Debugging Tools binaries are not redistributed here. Install them separately.

Install

python3 -m venv .venv && . .venv/bin/activate
pip install -e .

Run

As a standalone MCP stdio server:

python -m dbgeng_mcp.server

From WSL the server spawns the worker with python.exe (Windows Python) and translates the worker path to its \\wsl.localhost form on its own. Override the interpreter or the worker path if needed:

Wire it into an MCP client

Point the client at the server command. Most clients take a command and its arguments, for example:

{
  "command": "/home/you/dev/dbgeng-mcp/.venv/bin/python",
  "args": ["-m", "dbgeng_mcp.server"]
}

Tools

Tool What it does
open_target Launch a command line, attach to a pid, or open a dump. Stops at the first instruction
execute Run any WinDbg command and return its text (lm, k, bp, dx, !peb, ...)
go Continue until the next breakpoint, exception, or exit
step Single step one instruction, into or over
read_memory Read bytes at an address, returned as hex
registers The target's register values
close End the session

execute is the escape hatch. Anything the structured tools do not cover, a raw command does.

Checking the binding

tools/smoke.py launches a throwaway target and exercises the engine directly. tools/test_worker.py drives the worker over the same JSON protocol the server uses. Both run against the live engine:

python.exe tools/smoke.py          # engine, Windows Python
python3 tools/test_worker.py       # worker over its pipe

Limits