Skip to main content
Glama
ghidra-headless-mcp

ghidra-headless-mcp

by samudoria

ghidra-headless-mcp

Minimal headless MCP server for Ghidra. No GUI, no plugin, no HTTP bridge: it runs Ghidra in-process through PyGhidra. Sibling of Revoid (jadx) and uses the same tool style.

Install

Requires Python 3.9+, JDK 21+ and Ghidra 11.3+ (tested on 12.1).

pip install git+https://github.com/samudoria/ghidra-headless-mcp   # or the wheel from Releases
{
  "mcpServers": {
    "ghidra": {
      "command": "ghidra-headless-mcp",
      "env": { "GHIDRA_INSTALL_DIR": "/opt/ghidra" }
    }
  }
}

OpenCode

In opencode.json (project) or ~/.config/opencode/opencode.json:

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "ghidra": {
      "type": "local",
      "command": ["ghidra-headless-mcp"],
      "environment": { "GHIDRA_INSTALL_DIR": "/opt/ghidra" },
      "enabled": true
    }
  }
}

Related MCP server: REA (Reverse Engineer Anything)

Use with Revoid

For Android apps: in Revoid call list_native_libraries, then extract_native_library to get a .so path on disk, and pass that path to load_binary here. Each server keeps its own renames and comments. Tell the model to rename and comment as it goes; the notes are what the next analyst reads.

Tools

Tool

Description

load_binary

Import a binary (ELF/.so, PE, Mach-O...) and start auto-analysis in the background. Call first. Returns immediately. Cached per file. analyze=False skips analysis (started on demand).

load_status

Load state: idle/importing/analyzing/ready/error. Poll until {"state":"ready","analyzed":true}.

list_functions

Functions (name, address, signature); filter = regex. Paginated. Works right after import.

get_function

Decompiled C (function = name or any address inside).

get_disassembly

Assembly listing of a function.

list_strings / list_imports / list_exports

Paginated, filter = regex.

get_callers / get_callees

Call graph neighbours of a function.

get_xrefs

References to an address, function or string.

call_path

Shortest call chain from one function to another.

read_memory

Hex dump of bytes at an address (max 4096).

search_bytes

Byte pattern search, hex with ?? wildcards. Paginated.

search_constants

Instructions with a given scalar operand (crypto constants, magic numbers). Paginated.

set_signature

Apply a C prototype to a function (int f(char *key, int n)).

retype_variable

Change a local/parameter type as seen in the decompiled C.

rename

Rename a function or label.

rename_variable

Rename a local/parameter seen in the decompiled C.

add_comment

pre (default), eol, post, plate, repeatable. Empty text clears.

All lists take limit (default 50) and offset; the reply contains next_offset (null at the end). Edits are saved to the Ghidra project immediately and survive restarts: reloading the same file reopens your names and comments.

Load flow (non-blocking)

load_binary no longer blocks on Ghidra's multi-minute auto-analysis. The import is synchronous (seconds); full analysis then runs on a background thread. The intended agent flow:

  1. load_binary(path) — returns at once with {"state":"analyzing"|"ready", ...}.

  2. Read immediately, while analysis runs: list_exports, list_imports, list_strings, list_functions, read_memory, search_bytes — the structural questions (which exports? JNI functions? suspicious imports/strings?).

  3. Poll load_status() until {"state":"ready","analyzed":true}.

  4. Then call decompiler-driven tools: get_function, get_disassembly, get_callers/get_callees/get_xrefs, call_path, search_constants, rename*, retype_variable, set_signature, add_comment.

Called before analysis is done, a decompiler-driven tool returns a soft {"status":"analyzing","retry_after_s":N,"hint":...} — not an error and never an under-analyzed answer. With analyze=False, the first such call starts analysis itself (triage cheaply, pay for analysis only when you decompile). A re-analyzed cached project loads straight to ready with no re-analysis.

Environment

Variable

Purpose

GHIDRA_INSTALL_DIR (or GHIDRA_HOME)

Ghidra install directory (required)

GHIDRA_MCP_HOME

Where projects are stored (default ~/ghidra_mcp; no path element may start with .)

GHIDRA_MCP_TRANSPORT

stdio (default), sse, or streamable-http

GHIDRA_MCP_HOST / GHIDRA_MCP_PORT

Bind address for the HTTP transports (default 127.0.0.1:8000)

GHIDRA_MCP_DECOMPILE_TIMEOUT

Per-function decompile timeout in seconds (default 30; get_function takes a per-call timeout)

GHIDRA_MCP_TRIM_ANALYSIS

1 to disable the analyzers in GHIDRA_MCP_DISABLE_ANALYZERS before analysis (default off = full analysis)

GHIDRA_MCP_DISABLE_ANALYZERS

Comma-separated analyzer names to skip when trimming (default Embedded Media; decompiler-critical analyzers are never dropped)

HTTP / SSE

GHIDRA_INSTALL_DIR=/opt/ghidra GHIDRA_MCP_TRANSPORT=sse ghidra-headless-mcp
# SSE endpoint:        http://127.0.0.1:8000/sse
# streamable-http:     GHIDRA_MCP_TRANSPORT=streamable-http  -> http://127.0.0.1:8000/mcp
{
  "mcpServers": {
    "ghidra": { "type": "sse", "url": "http://127.0.0.1:8000/sse" }
  }
}

One binary is loaded at a time; load_binary closes the previous one. Only one server may open a given project at a time. Logs go to stderr; stdout is reserved for the protocol.

Test

python tests/test_state.py                                                      # state machine, no Ghidra needed
GHIDRA_INSTALL_DIR=/opt/ghidra python tests/smoke.py ./some_binary some_function # end-to-end over stdio

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      MCP server for analyzing Android APK, DEX, or JAR files via a headless jadx engine, enabling LLM agents to query decompiled code, symbols, call graphs, and more.
      2
      GPL 3.0
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI agents to inspect and decompile software they have no source for — Android APKs, Electron bundles, .NET assemblies, and Go, Rust or WASM binaries — plus adb device interaction, through a token-guarded Streamable HTTP MCP endpoint, stdio MCP, or a CLI. Ghidra-powered native binary decompilation can be opted in at startup for ELF, PE and Mach-O targets.
      6
      Do What The F*ck You Want To Public
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI coding agents to inspect and reverse-engineer large binaries through bounded stdio JSON-RPC 2.0 tools for graph queries, SSA facts, path solving, runtime grounding, and mod scaffolding.
      1
      AGPL 3.0
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI agents (and a matching CLI) to inspect native binaries, JavaScript/Electron apps, .NET assemblies, Go/Rust/WASM artifacts, EVM bytecode, SQLite databases, recorded crashes, and websites without source code, explaining how features work and returning the evidence and limitations behind each conclusion. Analysis runs locally, using optional Hopper, Ghidra, or IDA providers for native targets.
      351,335 npm
      MIT