MCP Hub
Back to servers

MCPEmulate

An MCP server that provides CPU emulation, disassembly, and assembly tools for LLM agents across multiple architectures including x86, ARM, and RISC-V. It enables agents to manage isolated emulation sessions, perform memory analysis, hook syscalls, and trace execution through a standard tool interface.

glama
Stars
2
Updated
Mar 23, 2026
Validated
Mar 25, 2026

MCPEmulate

This project was vibecoded.

An MCP server that exposes CPU emulation, disassembly, and assembly as tools for LLM agents. Built on Unicorn (emulation), Capstone (disassembly), Keystone (assembly), and LIEF (binary parsing).

Agents can create isolated emulation sessions, load code or full executables, set breakpoints, hook syscalls, step through instructions, inspect memory and registers, and diff execution traces -- all through the standard MCP tool interface.

Supported Architectures

ArchitectureEmulationDisassemblyAssemblySyscall Hooking
x86 (32-bit)YesYesYesint 0x80
x86-64YesYesYessyscall
ARM (32-bit)YesYesYessvc 0
AArch64YesYesYessvc 0
MIPS32 (LE)YesYesYessyscall
MIPS32 (BE)YesYesYessyscall
RISC-V 32YesYesNoecall
RISC-V 64YesYesNoecall

RISC-V architectures lack a Keystone backend, so the assemble tool returns an error for them. Disassembly and emulation work normally.

Install

Requires Python 3.10+.

# Run directly (no install needed)
uvx mcp-emulate

# Or install globally
uv pip install mcp-emulate

Usage

Claude Desktop / MCP Client

Add to your MCP client configuration:

{
  "mcpServers": {
    "mcp-emulate": {
      "command": "uvx",
      "args": ["mcp-emulate"]
    }
  }
}

CLI

# Default: stdio transport (for MCP clients)
mcp-emulate

# SSE transport (network, for web-based clients)
mcp-emulate --transport sse

# Streamable HTTP transport (newer MCP protocol)
mcp-emulate --transport streamable-http

Tools (41)

Session Management

ToolDescription
create_emulatorCreate a new emulation session for a given architecture
destroy_emulatorDestroy a session and free resources
export_sessionExport full session state (memory, registers, breakpoints, symbols) to JSON
import_sessionCreate a new session and restore state from a previous export

Memory

ToolDescription
map_memoryMap a memory region with specified permissions (r/w/x)
write_memoryWrite hex or base64 data to memory
read_memoryRead memory as hex or base64
list_regionsList all mapped regions
hexdumpFormatted hex dump (up to 4KB) with ASCII sidebar
search_memorySearch for byte patterns across mapped memory
snapshot_memoryCapture all memory content under a named label
diff_memoryCompare two snapshots and return changed byte ranges
memory_map/proc/self/maps-style layout with gaps and symbol annotations

Registers

ToolDescription
set_registersWrite one or more registers
get_registersRead registers (specific or all)
get_stackRead stack entries from SP, resolving values against symbols

Execution

ToolDescription
emulateRun emulation with stop address, instruction count, or timeout
stepExecute a single instruction with full disassembly
add_breakpointSet a breakpoint, optionally with a register condition
remove_breakpointRemove a breakpoint
list_breakpointsList all breakpoints with their conditions
save_contextSave a register snapshot under a label
restore_contextRestore registers from a saved snapshot

Breakpoint Conditions

Conditional breakpoints accept expressions like:

eax == 42
rax > 0x1000 and rcx != 0
r0 == 0 or r1 & 0xff

Supported operators: ==, !=, >, <, >=, <=, &. Connectives: and, or.

Syscall Hooking

ToolDescription
hook_syscallInstall a syscall hook (skip to log and continue, stop to halt)
unhook_syscallRemove the syscall hook
get_syscall_logRetrieve logged syscall invocations with pagination

Each logged entry includes the syscall number, argument register values, and PC. The hook is architecture-aware -- it intercepts int 0x80 on x86_32, syscall on x86_64, svc 0 on ARM/AArch64, syscall on MIPS, and ecall on RISC-V.

Watchpoints

ToolDescription
add_watchpointWatch a memory address for read, write, or both
remove_watchpointRemove a watchpoint
list_watchpointsList all active watchpoints

Tracing

ToolDescription
enable_traceStart recording executed instructions
disable_traceStop recording (log is preserved)
get_traceRetrieve trace entries with disassembly and pagination
save_traceSave the current trace log under a named label
diff_traceCompare two saved traces instruction-by-instruction

Trace diff reports the common prefix length, the divergence point, and up to 50 differing entries with full disassembly.

Symbols

ToolDescription
add_symbolAssociate a name with an address
remove_symbolRemove a symbol
list_symbolsList all symbols

Symbols are used to annotate stack entries, trace output, memory maps, and step results.

Loading

ToolDescription
load_binaryLoad raw machine code at an address, auto-mapping memory
load_executableLoad an ELF, PE, or Mach-O binary with correct segment permissions, entry point, and symbols
assembleAssemble instructions to machine code (standalone, no session)
disassembleDisassemble machine code to instructions (standalone, no session)

load_executable uses LIEF for format detection. It maps each loadable segment with the correct permissions, sets PC to the entry point, and registers exported symbols automatically.

Example Workflow

A typical agent interaction:

  1. create_emulator(arch="x86_64") -- start a session
  2. assemble(arch="x86_64", code="mov rax, 60; syscall") -- assemble exit syscall
  3. load_binary(session_id=..., data=..., address=0x1000, entry_point=0x1000) -- load code
  4. hook_syscall(session_id=..., mode="stop") -- intercept syscalls
  5. enable_trace(session_id=...) -- start recording
  6. emulate(session_id=..., address=0x1000, count=100) -- run
  7. get_trace(session_id=...) -- inspect what executed
  8. get_syscall_log(session_id=...) -- see what syscalls were attempted
  9. export_session(session_id=...) -- save state for later

Architecture

src/mcp_emulate/
  architectures.py   Architecture configs, register maps, syscall conventions
  session.py         EmulationSession (Unicorn wrapper), SessionManager
  server.py          41 MCP tool handlers via FastMCP

tests/
  test_emulate.py              132 pytest unit tests
  test_server_integration.py   112 checks over JSON-RPC (23 phases)

Key Design Decisions

  • EmulationSession uses __slots__ for memory efficiency and to catch typos. Every new attribute must be declared.
  • Breakpoints are dict[int, str | None] (address to optional condition), not a set. This supports conditional breakpoints while keeping the same lookup semantics.
  • Syscall conventions are data, not code. A frozen dataclass per architecture describes the hook type, interrupt number filter, register names for nr/args/return. The hooking logic is generic.
  • ks_arch/ks_mode are Optional on ArchConfig so architectures without Keystone (RISC-V) can exist without a dummy value. The assemble tool checks this and returns a clear error.
  • load_executable writes via uc.mem_write() directly, bypassing the permission check on write_memory. This is intentional -- binary loaders need to populate read-only segments.
  • Session serialization is versioned ("version": 1) for forward compatibility.

Development

git clone https://github.com/LabGuy94/MCPEmulate.git
cd MCPEmulate
uv venv .venv
uv pip install -e ".[dev]"

Tests

# Unit tests (132 tests, ~1s)
uv run pytest tests/test_emulate.py -v

# Integration tests (112 checks over JSON-RPC subprocess, ~30s)
uv run python tests/test_server_integration.py

# Both
uv run pytest tests/ -v && uv run python tests/test_server_integration.py

Dependencies

PackagePurpose
mcp >= 1.18.0MCP protocol / FastMCP server framework
unicorn >= 2.0.0CPU emulation engine
capstone >= 5.0.0Disassembly engine
keystone-engine >= 0.9.2Assembly engine
lief >= 0.14.0ELF/PE/Mach-O binary parsing

License

GPL-2.0-only

Reviews

No reviews yet

Sign in to write a review