Skip to content

About

MCP servers for WinDbg kernel and user-mode debugging — in-process HTTP MCP in WinDbg plus an optional Python sidecar on the debug VM.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

windbg-inproc-mcp

MCP servers for WinDbg kernel and user-mode debugging — in-process HTTP MCP in WinDbg plus an optional Python sidecar on the debug VM.

Topics: windbg · mcp · cursor · kernel-debugging

The Host runs a C++ WinDbg extension with in-process HTTP MCP; an optional Target Python sidecar runs on the debugged VM for local shell, sc.exe, and driver file operations.

Host (dev machine)                    Target VM (optional)
┌─────────────┐                         ┌──────────────────┐
│   Cursor    │── HTTP :60000+/mcp ──►│ WinDbg + DLL     │  breakpoints, memory, g
│             │                         └────────┬─────────┘
│             │── HTTP :60100/mcp ─────────────►│ target_mcp.py  │  sc, shell, copy .sys
└─────────────┘                         └──────────────────┘
Task Use
Breakpoints, !drvobj, memory, g, break_debugger windbg-inproc-mcp (DLL on Host)
sc stop/start, cmd, PowerShell, copy .sys target (Python on VM)

Table of contents

Prerequisites

Component Requirements
DLL (Host) Windows 10/11 x64; WinDbg (Debugging Tools for Windows); Visual Studio 2017+ with the Desktop development with C++ workload; Windows SDK (installed with VS or standalone) providing dbgeng.lib and headers for linking the extension
Python (Target) Windows 10/11 on the debugged VM, Python 3.10+, Administrator (for sc.exe and System32\drivers)

Building the DLL: The linker must find dbgeng.lib (Debugger Engine). Install Debugging Tools for Windows (WinDbg / SDK debugger components) and ensure the Windows SDK is on your machine—the same SDK that ships with Visual Studio is usually enough. If MSBuild fails with cannot open file 'dbgeng.lib', install or repair the Windows SDK and Debugging Tools, then rebuild.

Both components use HTTP MCP on a lab network only (no TLS). Do not expose to the public internet.

Cursor configuration

The Host MCP port is not fixed at 60000. On load, the extension tries 60000, then 60001 … 60999 until it finds a free port (so multiple WinDbg instances can each host MCP). Always confirm the actual URL before editing Cursor config.

Find the Host port

  1. After .load, read WinDbg output, e.g. HTTP MCP server started at: http://127.0.0.1:60001/mcp
  2. Or in WinDbg: mcphttpstatus
  3. Or call the MCP tool debug_session — the Endpoint: / Port: lines show the live URL

Then set that URL in ~/.cursor/mcp.json. Example with both servers (replace <host-port> with the value from step 1–3):

{
  "mcpServers": {
    "windbg-inproc-mcp": {
      "url": "http://127.0.0.1:<host-port>/mcp",
      "timeout": 30000
    },
    "target": {
      "url": "http://<vm-ip>:60100/mcp",
      "headers": {
        "Authorization": "Bearer <token-from-target-vm>"
      }
    }
  }
}

Add the Host entry manually to ~/.cursor/mcp.json, then restart Cursor. If Cursor cannot connect after opening a second WinDbg, run mcphttpstatus in each session and point each MCP client entry at the matching port.

Install the Target entry from the Host (replace VM IP and Windows username):

python target_mcp\install_target_cursor_config.py --host 192.168.x.x --user <vm-windows-user>

On the Target VM, print the auth token:

python target_mcp.py --show-token

Part 1 — windbgInprocMcp.dll (C++ extension)

In-process HTTP MCP inside WinDbg. MCP clients connect directly to the extension DLL—no Python bridge or named pipe.

Build

Requires Visual Studio 2017 or later with the Desktop development with C++ workload (Community, Professional, Enterprise, or Build Tools), plus a Windows SDK with debugger libraries (dbgeng.lib). Install Debugging Tools for Windows if the link step cannot find dbgeng.lib. The script uses vswhere when available, otherwise scans common install paths.

extension\build_vs2017.bat

Output: extension\build\x64\Release\windbgInprocMcp.dll

Load in WinDbg

.load C:\path\to\windbg-inproc-mcp\extension\build\x64\Release\windbgInprocMcp.dll

HTTP MCP starts automatically. The extension binds the first free port in 60000–60999 (default attempt: 60000). WinDbg prints the URL on load; use mcphttpstatus anytime to see it again. Put that URL in Cursor — not a guessed port.

mcphttpstatus

Example output: HTTP MCP server is running at: http://127.0.0.1:60001/mcp (port 60001)

MCP tools (10)

Category Tools
Session debug_session, troubleshoot
Execution run_command, run_sequence, breakpoint_and_continue, break_debugger
Analysis analyze_process, analyze_thread, analyze_memory, analyze_kernel

WinDbg extension commands

Command Description
help Show extension command help
mcpserve Start HTTP MCP manually
mcphttpstop Stop HTTP MCP
mcphttpstatus Show HTTP MCP status

Troubleshooting (DLL)

Issue Action
Cursor cannot connect to Host MCP Run mcphttpstatus (or check load output); update mcp.json url to the printed port
MCP disconnected after .reboot or unload Reload the DLL; reconnect Cursor MCP (port may change — check mcphttpstatus)
Engine busy / hung command Call break_debugger or .break in WinDbg
Link error LNK1104 on rebuild .unload windbgInprocMcp first
Debug log extension\build\x64\Release\windbgInprocMcp.log (next to the DLL)

Part 2 — target_mcp (Python sidecar)

Runs on the debugged VM. Complements the Host DLL; it does not replace WinDbg debugging.

Install (Target VM)

cd target_mcp
pip install -r requirements.txt

Run

python target_mcp.py

Or:

start_target_mcp.bat
  • Listens on http://0.0.0.0:60100/mcp by default
  • Requests UAC elevation if not already admin
  • Prints windows_user, IPv4 addresses, and a stable Bearer token (derived from the VM username)
  • Log file: target_mcp.log in the target_mcp directory (truncated on each restart)

CLI options

Flag Default Description
--host 0.0.0.0 Bind address
--port 60100 HTTP port (avoids Host MCP range starting at 60000)
--path /mcp HTTP path
--no-elevate off Skip UAC; exit if not admin
--debug off Verbose logging
--show-token — Print token for current Windows user and exit

MCP tools

Tool Description
target_health Hostname, admin status, IPv4 list, allowed file roots
run_shell Run a cmd.exe command
run_powershell_script Run PowerShell (-NoProfile -NonInteractive)
sc_control sc.exe: query / stop / start / delete / create
manage_driver Driver service: status / stop / start / install / reinstall / uninstall
copy_file Copy between allowed directories
read_file Read a file under allowed paths (text or binary preview)
run_sequence Batch steps (cmd / powershell / sc) as a JSON array

manage_driver example:

manage_driver(action="status", name="MyDriver")
manage_driver(action="stop", name="MyDriver")
manage_driver(action="install", name="MyDriver", source_sys_path="C:\path\to\MyDriver.sys")

run_sequence example:

[
  {"type": "sc", "action": "stop", "service_name": "MyDriver"},
  {"type": "cmd", "command": "echo done"}
]

Kernel debugging workflow

When the Target is broken into the kernel debugger, the whole VM is frozen and this HTTP server will not respond. Resume the Target first:

1. windbg-inproc-mcp: break_debugger     (or already broken in)
2. windbg-inproc-mcp: run_command("g")   (Target runs)
3. target: sc_control(action="stop", service_name="MyDriver")
4. windbg-inproc-mcp: break_debugger     (break again to continue debugging)

Authentication

Bearer token is deterministically derived from the Target VM %USERNAME% (HMAC-SHA256). It is stable across restarts; no TARGET_MCP_TOKEN environment variable.

When configuring Cursor on the Host, --user must be the VM Windows username, not the Host username.

Environment variables

Variable Description
TARGET_MCP_ALLOWED_PATHS Extra allowed read/write roots, semicolon-separated (e.g. C:\build;Z:\driver)

File path policy

copy_file / read_file allow only:

  • C:\Windows\System32\drivers
  • C:\Windows\Temp and %TEMP%
  • The target_mcp directory
  • Paths listed in TARGET_MCP_ALLOWED_PATHS

manage_driver can read a source .sys from any existing path; the install target is always System32\drivers.

Firewall (Target VM)

If the Host cannot connect, allow inbound TCP on the Target (run as Administrator):

netsh advfirewall firewall add rule name="Target MCP" dir=in action=allow protocol=TCP localport=60100

Troubleshooting (Python)

Issue Action
Cursor cannot connect Check VM IP, target_health, firewall, and token
Requests time out Target may be kernel-frozen; run g in WinDbg first
sc stop fails Run Target MCP as Administrator; verify service name
copy_file path denied Set TARGET_MCP_ALLOWED_PATHS or use an allowed directory
UAC loop Start from an elevated cmd, or review --no-elevate

Repository layout

windbg-inproc-mcp/
├── extension/                    # C++ WinDbg extension (windbgInprocMcp.dll)
├── target_mcp/                   # Python sidecar for the debugged VM
│   ├── target_mcp.py             # Entry point
│   ├── start_target_mcp.bat
│   ├── install_target_cursor_config.py
│   └── tools.py, executor.py, security.py, ...
├── LICENSE
└── README.md

Security

  • Lab / debug network only. HTTP without TLS; Bearer tokens are not suitable for untrusted networks.
  • Target MCP requires Administrator privileges and can run shell commands and service control.
  • Command blocklists reduce accidental damage (e.g. format, shutdown /p); they are not a sandbox.
  • Never bind Target MCP to a public interface or expose it outside your debug VLAN.

License

See LICENSE.

About

MCP servers for WinDbg kernel and user-mode debugging — in-process HTTP MCP in WinDbg plus an optional Python sidecar on the debug VM.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages