# miscusi-peek/cheatengine-mcp-bridge architecture

> Architecture diagram of the GitHub repository miscusi-peek/cheatengine-mcp-bridge, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/miscusi-peek/cheatengine-mcp-bridge
- Repository: https://github.com/miscusi-peek/cheatengine-mcp-bridge

## Overview

#### Purpose and Entry Points
This repository exposes Cheat Engine’s process-memory, debugging, reverse-engineering, and automation capabilities as an MCP server for AI clients. The primary launch point is `MCP_Server/mcp_cheatengine.py`; it serves MCP JSON-RPC over stdio. Cheat Engine loads `MCP_Server/ce_mcp_bridge.lua`, which executes privileged CE APIs against the attached target process.

#### MCP Tool Server
`MCP_Server/mcp_cheatengine.py` defines the FastMCP server and its large tool surface: process lifecycle, memory reads/writes/scans, pointer resolution, disassembly, debugging, injection, symbols, GUI/input, and DBVM/DBK operations. Tool handlers convert MCP arguments into bridge commands, enforce per-call timeout behavior, and return structured results to the AI client.

Core paths:
- `MCP_Server/mcp_cheatengine.py`
- `MCP_Server/requirements.txt`
- `AI_Context/MCP_Bridge_Command_Reference.md`

#### Cheat Engine Execution Bridge
`MCP_Server/ce_mcp_bridge.lua` is the authoritative execution layer inside Cheat Engine. It hosts the bridge pipe endpoint, receives serialized requests, dispatches command handlers to CE Lua APIs, and returns responses. Its worker/main-thread coordination is architecturally important: blocking transport work stays off CE’s GUI/API execution context, while CE interactions execute in the appropriate main-thread context.

Core paths:
- `MCP_Server/ce_mcp_bridge.lua`
- `AI_Context/CE_LUA_Documentation.md`
- `AI_Context/MCP_Bridge_Command_Reference.md`

#### Native Windows Transport
The default control path is: AI MCP client → stdio → Python MCP server → Windows named pipe → Lua bridge → Cheat Engine → target executable. The named pipe is Windows-specific and requires `pywin32`; Cheat Engine and DBVM are material runtime dependencies for advanced debugging and kernel/hypervisor-backed functionality.

Core paths:
- `MCP_Server/mcp_cheatengine.py`
- `MCP_Server/ce_mcp_bridge.lua`
- `MCP_Server/requirements.txt`

#### TCP Relay Boundary
`MCP_Server/ce_tcp_relay.py` decouples the MCP server from the Windows host that owns Cheat Engine. It bridges TCP connections to the local CE named pipe, allowing the Python MCP process to run under WSL, Linux, containers, VMs, or remote hosts. Transport selection and relay address are controlled through `CE_MCP_TRANSPORT`, `CE_MCP_HOST`, and `CE_MCP_PORT`.

Core paths:
- `MCP_Server/ce_tcp_relay.py`
- `MCP_Server/mcp_cheatengine.py`
- `MCP_Server/requirements-tcp.txt`

#### Request and Trust Boundaries
The MCP client is untrusted relative to the target process: requested operations can inspect or mutate arbitrary process memory, alter protections, inject code/DLLs, control processes, and interact with DBVM/DBK. Shell-related capabilities are separately gated by `CE_MCP_ALLOW_SHELL`. The TCP relay introduces a network control boundary and must be bound only to trusted interfaces because a reachable relay grants control of the CE bridge.

Core paths:
- `MCP_Server/mcp_cheatengine.py`
- `MCP_Server/ce_tcp_relay.py`
- `MCP_Server/ce_mcp_bridge.lua`

#### Engineering Context
The implementation and protocol expectations are documented for agents and maintainers in the repository’s AI context material. The available test harness exercises the MCP-to-bridge integration rather than being a separate runtime component.

Core paths:
- `AI_Context/AI_Guide_MCP_Server_Implementation.md`
- `AI_Context/MCP_Bridge_Command_Reference.md`
- `MCP_Server/test_mcp.py`

Main entry points: [`MCP_Server/mcp_cheatengine.py`](https://github.com/miscusi-peek/cheatengine-mcp-bridge/blob/main/MCP_Server/mcp_cheatengine.py) (FastMCP tool server), [`MCP_Server/ce_tcp_relay.py`](https://github.com/miscusi-peek/cheatengine-mcp-bridge/blob/main/MCP_Server/ce_tcp_relay.py) (TCP relay), [`MCP_Server/ce_mcp_bridge.lua`](https://github.com/miscusi-peek/cheatengine-mcp-bridge/blob/main/MCP_Server/ce_mcp_bridge.lua) (Main-thread dispatcher), [`AI_Context/MCP_Bridge_Command_Reference.md`](https://github.com/miscusi-peek/cheatengine-mcp-bridge/blob/main/AI_Context/MCP_Bridge_Command_Reference.md) (Bridge command reference)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mcp["MCP control plane"]
  node_client(("AI MCP client"))
  node_stdio["stdio JSON-RPC<br/>protocol"]
  node_server["FastMCP tool server<br/>Python server<br/>[mcp_cheatengine.py]"]
  node_tools["Tool surface<br/>MCP handlers<br/>[mcp_cheatengine.py]"]
  node_shell_gate{{"Shell capability gate<br/>trust control<br/>[mcp_cheatengine.py]"}}
end

subgraph group_transport["Transport boundary"]
  node_pipe["Windows named pipe<br/>local transport"]
  node_relay["TCP relay<br/>Python relay<br/>[ce_tcp_relay.py]"]
  node_transport_config["Transport selection<br/>environment settings<br/>[mcp_cheatengine.py]"]
  node_tcp_dependencies["TCP dependencies<br/>dependency manifest"]
end

subgraph group_ce["Cheat Engine runtime"]
  node_bridge_worker["Bridge pipe worker<br/>Lua transport worker<br/>[ce_mcp_bridge.lua]"]
  node_bridge_dispatch["Main-thread dispatcher<br/>Lua command dispatcher<br/>[ce_mcp_bridge.lua]"]
  node_cheat_engine{{"Cheat Engine<br/>Windows runtime"}}
  node_target(("Attached target process"))
  node_dependencies["Runtime dependencies<br/>dependency manifests<br/>[requirements.txt]"]
end

subgraph group_context["Documentation"]
  node_protocol_reference["Bridge command reference<br/>protocol documentation"]
  node_lua_docs["CE Lua documentation<br/>API documentation"]
  node_implementation_guide["Implementation guide<br/>engineering documentation"]
end

node_client -->|"JSON-RPC"| node_stdio
node_stdio -->|"serves"| node_server
node_server -->|"dispatches"| node_tools
node_tools -.->|"shell requests"| node_shell_gate
node_tools -->|"default commands"| node_pipe
node_transport_config -.->|"configures"| node_server
node_transport_config -.->|"selects address"| node_relay
node_server -.->|"remote transport"| node_relay
node_relay -->|"forwards TCP to"| node_pipe
node_pipe -->|"serialized requests"| node_bridge_worker
node_bridge_worker -->|"coordinates"| node_bridge_dispatch
node_bridge_dispatch -->|"CE Lua APIs"| node_cheat_engine
node_cheat_engine -->|"inspect / mutate / debug"| node_target
node_dependencies -.->|"pywin32"| node_server
node_tcp_dependencies -.->|"installs"| node_relay
node_protocol_reference -.->|"documents commands"| node_server
node_protocol_reference -.->|"documents commands"| node_bridge_dispatch
node_lua_docs -.->|"documents APIs"| node_bridge_dispatch
node_implementation_guide -.->|"implementation context"| node_server

click node_server "https://github.com/miscusi-peek/cheatengine-mcp-bridge/blob/main/MCP_Server/mcp_cheatengine.py"
click node_tools "https://github.com/miscusi-peek/cheatengine-mcp-bridge/blob/main/MCP_Server/mcp_cheatengine.py"
click node_shell_gate "https://github.com/miscusi-peek/cheatengine-mcp-bridge/blob/main/MCP_Server/mcp_cheatengine.py"
click node_relay "https://github.com/miscusi-peek/cheatengine-mcp-bridge/blob/main/MCP_Server/ce_tcp_relay.py"
click node_transport_config "https://github.com/miscusi-peek/cheatengine-mcp-bridge/blob/main/MCP_Server/mcp_cheatengine.py"
click node_bridge_worker "https://github.com/miscusi-peek/cheatengine-mcp-bridge/blob/main/MCP_Server/ce_mcp_bridge.lua"
click node_bridge_dispatch "https://github.com/miscusi-peek/cheatengine-mcp-bridge/blob/main/MCP_Server/ce_mcp_bridge.lua"
click node_dependencies "https://github.com/miscusi-peek/cheatengine-mcp-bridge/blob/main/MCP_Server/requirements.txt"
click node_tcp_dependencies "https://github.com/miscusi-peek/cheatengine-mcp-bridge/blob/main/MCP_Server/requirements-tcp.txt"
click node_protocol_reference "https://github.com/miscusi-peek/cheatengine-mcp-bridge/blob/main/AI_Context/MCP_Bridge_Command_Reference.md"
click node_lua_docs "https://github.com/miscusi-peek/cheatengine-mcp-bridge/blob/main/AI_Context/CE_LUA_Documentation.md"
click node_implementation_guide "https://github.com/miscusi-peek/cheatengine-mcp-bridge/blob/main/AI_Context/AI_Guide_MCP_Server_Implementation.md"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_client,node_stdio,node_server,node_tools,node_shell_gate toneBlue
class node_pipe,node_relay,node_transport_config,node_tcp_dependencies toneAmber
class node_bridge_worker,node_bridge_dispatch,node_cheat_engine,node_target,node_dependencies toneMint
class node_protocol_reference,node_lua_docs,node_implementation_guide toneRose
```

## Components

### MCP control plane

- **AI MCP client**: client · Requests privileged reverse-engineering operations.
- **stdio JSON-RPC**: protocol
- [FastMCP tool server](https://github.com/miscusi-peek/cheatengine-mcp-bridge/blob/main/MCP_Server/mcp_cheatengine.py): Python server · Validates tool calls, applies timeouts, and formats structured results. · `MCP_Server/mcp_cheatengine.py`
- [Tool surface](https://github.com/miscusi-peek/cheatengine-mcp-bridge/blob/main/MCP_Server/mcp_cheatengine.py): MCP handlers · Process, memory, debug, injection, symbols, GUI, and DBVM/DBK operations. · `MCP_Server/mcp_cheatengine.py`
- [Shell capability gate](https://github.com/miscusi-peek/cheatengine-mcp-bridge/blob/main/MCP_Server/mcp_cheatengine.py): trust control · Shell-related operations require CE_MCP_ALLOW_SHELL. · `MCP_Server/mcp_cheatengine.py`

### Transport boundary

- **Windows named pipe**: local transport · Default pywin32 transport to the Cheat Engine host.
- [TCP relay](https://github.com/miscusi-peek/cheatengine-mcp-bridge/blob/main/MCP_Server/ce_tcp_relay.py): Python relay · Network-exposed relay; bind only to trusted interfaces. · `MCP_Server/ce_tcp_relay.py`
- [Transport selection](https://github.com/miscusi-peek/cheatengine-mcp-bridge/blob/main/MCP_Server/mcp_cheatengine.py): environment settings · CE_MCP_TRANSPORT, CE_MCP_HOST, and CE_MCP_PORT select relay mode. · `MCP_Server/mcp_cheatengine.py`
- [TCP dependencies](https://github.com/miscusi-peek/cheatengine-mcp-bridge/blob/main/MCP_Server/requirements-tcp.txt): dependency manifest · `MCP_Server/requirements-tcp.txt`

### Cheat Engine runtime

- [Bridge pipe worker](https://github.com/miscusi-peek/cheatengine-mcp-bridge/blob/main/MCP_Server/ce_mcp_bridge.lua): Lua transport worker · Receives serialized requests away from CE's GUI execution context. · `MCP_Server/ce_mcp_bridge.lua`
- [Main-thread dispatcher](https://github.com/miscusi-peek/cheatengine-mcp-bridge/blob/main/MCP_Server/ce_mcp_bridge.lua): Lua command dispatcher · Runs CE Lua API handlers on the appropriate main thread. · `MCP_Server/ce_mcp_bridge.lua`
- **Cheat Engine**: Windows runtime · Hosts the Lua bridge and privileged CE APIs.
- **Attached target process**: process · Memory and execution target controlled through Cheat Engine.
- [Runtime dependencies](https://github.com/miscusi-peek/cheatengine-mcp-bridge/blob/main/MCP_Server/requirements.txt): dependency manifests · pywin32 supports named pipes; CE and DBVM enable advanced operations. · `MCP_Server/requirements.txt`

### Documentation

- [Bridge command reference](https://github.com/miscusi-peek/cheatengine-mcp-bridge/blob/main/AI_Context/MCP_Bridge_Command_Reference.md): protocol documentation · Defines MCP-to-bridge command expectations. · `AI_Context/MCP_Bridge_Command_Reference.md`
- [CE Lua documentation](https://github.com/miscusi-peek/cheatengine-mcp-bridge/blob/main/AI_Context/CE_LUA_Documentation.md): API documentation · `AI_Context/CE_LUA_Documentation.md`
- [Implementation guide](https://github.com/miscusi-peek/cheatengine-mcp-bridge/blob/main/AI_Context/AI_Guide_MCP_Server_Implementation.md): engineering documentation · `AI_Context/AI_Guide_MCP_Server_Implementation.md`

## Connections

- AI MCP client → stdio JSON-RPC: JSON-RPC
- stdio JSON-RPC → FastMCP tool server: serves
- FastMCP tool server → Tool surface: dispatches
- Tool surface → Shell capability gate: shell requests
- Tool surface → Windows named pipe: default commands
- Transport selection → FastMCP tool server: configures
- Transport selection → TCP relay: selects address
- FastMCP tool server → TCP relay: remote transport
- TCP relay → Windows named pipe: forwards TCP to
- Windows named pipe → Bridge pipe worker: serialized requests
- Bridge pipe worker → Main-thread dispatcher: coordinates
- Main-thread dispatcher → Cheat Engine: CE Lua APIs
- Cheat Engine → Attached target process: inspect / mutate / debug
- Runtime dependencies → FastMCP tool server: pywin32
- TCP dependencies → TCP relay: installs
- Bridge command reference → FastMCP tool server: documents commands
- Bridge command reference → Main-thread dispatcher: documents commands
- CE Lua documentation → Main-thread dispatcher: documents APIs
- Implementation guide → FastMCP tool server: implementation context
