Chapter 02Model Context Protocol (MCP) Setup

REA MCP: Configure rea-agents with Your Coding Agent

Reverse engineer apps, binaries and browser behavior with your coding agent.

AI Overview Direct AnswerREA Agent & MCP Server

REA MCP connects coding agents (Claude Code, Cursor, Windsurf, Cline) directly to application runtimes, Hopper/Ghidra decompilers, and Electron ASAR bundles via Model Context Protocol. Use REA to reverse engineer apps, binaries and browser behavior with your coding agent in seconds.

REA MCP Configuration Builder

17 Clients Supportedrea-agents v6.4+
Instant Automated Setup for Claude CodeInteractive guided setup transaction
Run in Terminal
npx rea-agents setup --client claude_code
Manual Configuration Location:~/.claude/config.json (or run: npx rea-agents setup --client claude_code)
Manual mcp_config.json
{
  "mcpServers": {
    "rea": {
      "command": "npx",
      "args": ["-y", "rea-agents@latest"],
      "env": {
        "REA_CLEAN_ROOM": "true",
        "REA_MAX_DEPTH": "3"
      }
    }
  }
}

Architecture Choice: Full MCP Server vs. Skill-Only

Full MCP Server (Recommended)

Connects the agent directly to your local system. Allows active execution of bundle unpacking, Ghidra/Hopper native disassembly, and live process inspection.

npx rea-agents setup
Skill-Only via skills.sh

Installs agent workflow instructions and domain reasoning prompts without registering a background MCP server or native disassembler bridge.

npx skills add morluto/rea --skill reverse-engineer-anything
First PrinciplesThe Structural Bottleneck

Why Reverse Engineering Needs MCP: Solving the Context Bottleneck

Every reverse engineer and security researcher knows the core challenge of modern software deconstruction: <strong>the scale of decompilation output dwarfs human and LLM context windows</strong>. A standard Electron application or native Mach-O/ELF binary contains millions of compiled instructions, tens of thousands of basic blocks, and hundreds of minified modules.

The Naive LLM Approach (Paste & Pray)
  • Context Window Saturation:Dumping 50,000 lines of Ghidra pseudocode into ChatGPT/Claude chokes attention heads (O(N²) degradation).
  • Severe Hallucination:When overwhelmed with raw assembly, LLMs invent function arguments, ignore jump conditions, and misattribute control flow.
  • No Execution Feedback:Static text prompts cannot query cross-references (xrefs), verify memory addresses, or inspect live process state.
The MCP Paradigm (Selective Autonomous Probing)
  • Targeted Subgraph Queries:The agent never ingests the entire binary. Instead, it queries specific functions, symbols, and call sites on demand.
  • Deterministic Evidence Ledgers:Every assertion made by the AI is backed by reproducible tool execution output stored in a structured JSON ledger.
  • Continuous Hypothesis Loop:The agent formulates a hypothesis → calls REA via MCP → inspects results → pivots or refines analysis autonomously.
System ArchitectureThe Operational Triad

The Triad: Security Engineers ↔ Model Context Protocol ↔ AI Agents

The Model Context Protocol (MCP), open-sourced by Anthropic, is not a chat prompt—it is a <strong>bidirectional JSON-RPC protocol over standard input/output (stdio) or HTTP/SSE</strong>. In REA, it bridges three distinct layers:

  +-------------------------------------------------------------------------+
  |              1. Security Analyst / Reverse Engineer (Human)             |
  |  High-level mission: "Trace IPC clipboard serialization in Notion.app"   |
  +-------------------------------------------------------------------------+
                                      │
                                      ▼ (Natural Language Intent)
  +-------------------------------------------------------------------------+
  |               2. AI Reasoning Engine (Claude Code / Cursor)             |
  |  Deconstructs mission into step-by-step hypothesis & tool call DAG      |
  +-------------------------------------------------------------------------+
                                      │
                                      │ [Model Context Protocol: stdio JSON-RPC]
                                      │ ──► tools/call: { name: "rea_inspect_bundle", ... }
                                      │ ◄── result: { status: "success", channels: [...] }
                                      ▼
  +-------------------------------------------------------------------------+
  |                   3. REA MCP Server Runtime (rea-agents)                |
  |  Local sandboxed orchestration layer driving decompilers and inspectors |
  +-------------------------------------------------------------------------+
         │                       │                       │
         ▼                       ▼                       ▼
  [AST & JS Inspector]   [Native Disassembler]   [Dynamic Hooking & Tracing]
  • Electron app.asar    • Hopper (Unix socket)   • Frida dynamic hooks
  • Webpack AST graphs   • Ghidra (headless Java) • LLDB memory breakpoints
  • API route schemas    • Hex-Rays IDA Pro       • mitmproxy network capture
1. Tools (`tools/call`)

Deterministic functions executed locally on the analyst's machine: <code>rea function</code>, <code>rea xrefs</code>, <code>rea decompile</code>. The model requests analysis; REA executes and returns structured JSON.

2. Resources (`resources/*`)

Structured read-only artifacts: normalized Evidence Ledgers, AST symbol tables, and extracted IPC channel directories that the agent can read on demand.

3. Prompts (`prompts/get`)

Pre-packaged expert workflows: clean-room specification generation, vulnerability surface mapping, and cryptographic routine verification.

Real Wire Traffic: JSON-RPC over stdio

Here is what happens under the hood when Claude Code invokes REA to decompile a native function:

1. Claude Request (tools/call):
{
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "name": "rea_function",
    "arguments": {
      "path": "./dxball.exe",
      "symbol": "SoundPanHelper",
      "provider": "hopper"
    }
  },
  "id": 104
}
2. REA Response (Evidence Ledger):
{
  "jsonrpc": "2.0",
  "result": {
    "evidence_id": "ev_8a129f",
    "entrypoint": "0x00401a20",
    "instruction_count": 63,
    "pseudocode": "int pan(int x, int w) { ... }",
    "xrefs_in": ["0x00401050", "0x004018e0"],
    "status": "success"
  },
  "id": 104
}
Under The HoodFour Engine Pipelines

REA's Four Core Engineering Subsystems

REA (rea-agents by morluto) translates high-level AI agent queries into concrete system executions across four specialized subsystems:

Engine 01:JavaScript & Electron ASAR Static AST Projection

Instead of unpacking multi-gigabyte Electron applications to disk, REA reads the ASAR header table in-memory, maps module graphs, resolves webpack runtime chunk boundaries, and identifies IPC message patterns (<code>ipcRenderer.send</code> / <code>ipcMain.handle</code>) without executing untrusted code.

rea analyze-javascript-application /path/to/app.asar --json

Engine 02:Headless Native Disassembler Bridges (Hopper, Ghidra, IDA)

For native Mach-O, ELF, and PE binaries, REA communicates with disassemblers via dedicated IPC channels: a Unix-domain socket bridge (<code>hopper_bridge.py</code>) for instant Hopper queries, a headless Java script bridge (<code>ReaGhidraBridge.java</code>) for Ghidra, and an MCP proxy for live IDA Pro sessions. It parses <code>LC_DYLD_CHAINED_FIXUPS</code>, authenticated arm64e pointer chains, Objective-C class records (<code>_OBJC_CLASS_$_</code>), and Swift witness tables directly to extract function dossiers and CFGs.

rea function ./target_binary Entrypoint --provider hopper --json

Engine 03:Compact Evidence Projection (Evidence Reduction)

Raw binary disassemblies and AST traces can exceed 300MB. REA's Evidence Projection engine filters, normalizes, and compresses the raw output into a dense 10KB semantic slice (<code>inspect-analysis-view</code>). This eliminates context window exhaustion and ensures the LLM focuses purely on relevant decision nodes.

jq -c '{source: {kind: "inline", evidence: .}, view: {kind: "summary"}}' raw.json | rea inspect-analysis-view

Engine 04:Clean-Room Model & Spec Synthesis

Once the agent validates its behavioral hypothesis against the Evidence ledger, it synthesizes clean-room specifications: standalone TypeScript interfaces, Rust data structures, or verified C functions—reconstructing interoperable logic without containing any proprietary binary bytecode.

Practical GuideDual-Mode Operational Workflows

How to Use REA: Dual-Mode Operation for Engineers

REA accommodates both conversational interactive exploration with AI agents and automated deterministic pipelines in CLI/CI environments:

A

Mode A: Interactive Agent Exploration

You steer; the AI agent drives. In Claude Code, Cursor, or Windsurf, the agent invokes REA MCP tools autonomously in the background while you converse in natural language.

Step 1: Setup oncenpx rea-agents setup
Step 2: Natural language steering"Find how the application encrypts session tokens in memory and write a clean-room Rust decryptor."
Step 3: OutputVerified spec + evidence citations linked to exact binary offsets.
B

Mode B: Headless Deterministic CLI

Direct terminal execution for scripting, batch triage, CI/CD audits, and headless decompilation pipelines without an interactive UI.

Step 1: Install persistent CLInpm install -g rea-agents
Step 2: Scriptable binary probingrea function ./app main --provider hopper --json
Step 3: Verification & healthrea doctor

Exposed REA MCP Tools Catalog

Once connected through the Model Context Protocol, REA registers the following high-level tools with Claude Code, Cursor, and Codex:

Tool IdentifierTargetFunctionality
rea_inspect_bundleElectron / WebExtracts ASAR header directory, IPC channels, and preload scripts.
rea_extract_symbolsNative BinariesParses Mach-O/PE/ELF exports using Hopper, Ghidra, or IDA Pro bridges.
rea_query_routesAPI SchemasDiscovers private REST, GraphQL, and WebSocket endpoints from bundle strings.
rea_generate_clean_specClean-RoomSynthesizes clean-room TypeScript or Rust interfaces free of proprietary bytecode.

Prompting Your AI Agent

After restarting your agent, ask it to investigate a target feature using the new REA tools:

Agent Natural Language Prompt
Inspect the search architecture in the target application using REA, show the evidence behind how index ranking operates, and build a clean-room TypeScript interface for my project.