Skip to main content
Glama
README.md
# MCP-x64dbg

x64dbg MCP Server with Domain-Driven Design (DDD) architecture for LLM-assisted debugging and reverse engineering.

Based on [wasdubya/x64dbgmcp](https://github.com/wasdubya/x64dbgmcp), restructured with DDD architecture for better maintainability, testability, and extensibility.

## Architecture

This project follows Domain-Driven Design principles with a layered architecture:

```
src/x64dbg_mcp/
  domain/           # Business logic: entities, value objects
  application/      # Services, DTOs
  infrastructure/   # HTTP client, debugger adapter
  interface/        # MCP tools (6 modules)
  zeromcp/          # Custom MCP protocol implementation
```

**27 MCP tools** across 6 interface modules:
- Debug Control: IsDebugging, Run, Pause, Stop, StepIn, StepOver, StepOut
- Breakpoints: SetBreakpoint, DeleteBreakpoint
- Registers: RegisterGet, RegisterSet, FlagGet, FlagSet
- Memory: MemoryRead, MemoryWrite, MemoryCheck, PatternFind
- Disassembly: Disassemble, GetCurrentInstruction, Assemble, AssembleToMemory
- Stack: StackPop, StackPush, StackPeek
- Modules: GetModuleList, ParseExpression, ExecCommand

## Prerequisites

- [Python](https://www.python.org/downloads/) (3.11 or higher)
- [x64dbg](https://x64dbg.com/) (latest release)
- Supported MCP Client:
  - [Claude Code](https://www.anthropic.com/code)
  - [Claude Desktop](https://claude.ai/download)
  - [Cursor](https://cursor.com)
  - [VS Code](https://code.visualstudio.com/)
  - [Windsurf](https://windsurf.com)
  - [Other MCP Clients](https://modelcontextprotocol.io/clients)

## Installation

### 1. Install the Plugin

Copy the plugin files to your x64dbg installation:

```
build/MCPx64dbg.dp32 -> x64dbg/release/x32/plugins/
build/MCPx64dbg.dp64 -> x64dbg/release/x64/plugins/
```

Or build from source:

```bash
mkdir build && cd build
cmake .. -G "Visual Studio 17 2022"
cmake --build . --config Release --target all_plugins
```

### 2. Install the Python Package

```bash
pip install https://github.com/JordanRO2/MCP-x64dbg/archive/refs/heads/main.zip
```

Or for development:

```bash
git clone https://github.com/JordanRO2/MCP-x64dbg.git
cd MCP-x64dbg
pip install -e .
```

### 3. Configure MCP Client

For Claude Code (`~/.claude.json`):

```json
{
  "mcpServers": {
    "x64dbg-mcp": {
      "type": "http",
      "url": "http://127.0.0.1:13339/mcp"
    }
  }
}
```

For Claude Desktop (`claude_desktop_config.json`):

```json
{
  "mcpServers": {
    "x64dbg-mcp": {
      "command": "python",
      "args": ["-m", "x64dbg_mcp", "--stdio"]
    }
  }
}
```

## Usage

### Auto-Start (Recommended)

1. Create `start_mcp.bat` in the project root:
```batch
@echo off
cd /d "C:\path\to\MCP-x64dbg\src"
set PYTHONPATH=C:\path\to\MCP-x64dbg\src
python -m x64dbg_mcp --host 0.0.0.0
```

2. Start x64dbg - the plugin automatically starts:
   - HTTP server on port 8888 (x64dbg API)
   - MCP server on port 13339 (AI interface)

### Manual Start

```bash
# Start x64dbg first, then:
cd src
python -m x64dbg_mcp --host 0.0.0.0 --port 13339
```

### Plugin Commands

In x64dbg command bar:
- `httpserver` - Toggle HTTP server on/off
- `httpport <port>` - Change HTTP server port
- `mcpserver` - Toggle MCP server on/off

## Usage Examples

**Set a breakpoint and analyze:**
```
"Set a breakpoint at the main function and step through the first few instructions"
```

**Memory analysis:**
```
"Read 100 bytes from address 0x401000 and show me what's there"
```

**Register inspection:**
```
"What's the current value of RAX and RIP registers?"
```

**Pattern searching:**
```
"Find the pattern '48 8B 05' in the current module"
```

## WSL2 Configuration

For WSL2 access to Windows-hosted x64dbg:

1. Find Windows host IP:
```bash
cat /etc/resolv.conf | grep nameserver | awk '{print $2}'
```

2. Add firewall rule (PowerShell as Admin):
```powershell
New-NetFirewallRule -DisplayName "MCP x64dbg" -Direction Inbound -LocalPort 13339 -Protocol TCP -Action Allow
```

3. Configure Claude (`~/.claude.json`):
```json
{
  "mcpServers": {
    "x64dbg-mcp": {
      "type": "http",
      "url": "http://<WINDOWS_HOST_IP>:13339/mcp"
    }
  }
}
```

## Project Structure

```
MCP-x64dbg/
  src/
    x64dbg_mcp/           # Python MCP server
      domain/             # Entities: Register, Memory, Breakpoint, Module, Instruction
      application/        # DebuggerService
      infrastructure/     # HTTP client, DebuggerAdapter
      interface/tools/    # MCP tool implementations
      zeromcp/            # MCP protocol
    MCPx64dbg.cpp         # C++ plugin source
  deps/
    x64dbg_sdk/           # x64dbg plugin SDK
  build/                  # Compiled plugins (.dp32, .dp64)
  start_mcp.bat           # Auto-start batch file
```

## Credits

- Original implementation: [wasdubya/x64dbgmcp](https://github.com/wasdubya/x64dbgmcp)
- DDD restructure: [JordanRO2](https://github.com/JordanRO2)
- x64dbg: [x64dbg/x64dbg](https://github.com/x64dbg/x64dbg)

## License

MIT License - see [LICENSE](LICENSE) for details.