Understand the program
Inspect control flow and call graphs, search instructions and constants, and trace decompiler SSA with explicit memory and call boundaries.
Free & open source MIT licensed
Follow call graphs and data flow, refine native types, compare functions, and preserve your analysis. Ghidra MCP connects compatible AI clients to native Ghidra through a local Rust server and Java adapter.
85 MCP tools Local stdio transport Background + GUI
Native analysis, structured operations
The Model Context Protocol lets a client discover tools and call them with defined inputs. This adapter brings a focused Ghidra workflow to that interface, with project identities, explicit processor selection, and results you can inspect.
Inspect control flow and call graphs, search instructions and constants, and trace decompiler SSA with explicit memory and call boundaries.
Define structures and signatures, edit guarded variables, batch labels and comments, then explicitly save and verify your work.
Use 85 tools in a background or GUI workflow, with 84 supported headlessly. Compare fingerprints and run bounded isolated emulation with explicit inputs.
The repository records native headless and GUI acceptance on Windows, Ghidra 12.1.3 PUBLIC, and JDK 21, using generated synthetic binaries. These runs exercise actual Ghidra; transport tests with a simulated mailbox are recorded separately. The GUI harness uses a hidden CodeBrowser and does not automate extension-installation dialogs.
Generated x86 and TriCore arithmetic fixtures exercise isolated emulation; they do not certify an ECU's code, memory layout or peripheral behavior. In particular, the current raw importer rejects TC29x processor-default multiple memory blocks. Read the import limits and native acceptance scope.
Quickstart
Install Ghidra 12.1.3 PUBLIC, JDK 21, and Rust. The repository pins Rust 1.88.0. Build the Java adapter against the Ghidra version you will run. Ghidra and Java are separately installed; neither is bundled.
git clone https://github.com/amirdauti/redline-autohaus-ghidra-mcp.git
cd redline-autohaus-ghidra-mcp
cargo build --locked --release
.\scripts\build-extension.ps1 -GhidraHome 'C:\tools\ghidra_12.1.3_PUBLIC' -JavaHome 'C:\tools\jdk-21'
Substitute your own paths. The Rust executable is
target/release/ghidra-mcp.exe. The extension ZIP and
latest-build.json are written under dist/;
the build metadata records the adapter JAR path. A shell build helper
is also included. Node.js is needed only for the optional acceptance
test, and normal operation requires neither Node.js nor Python.
Create private project, input, and mailbox directories, then start the bridge. The project and input directories must already exist.
New-Item -ItemType Directory -Force -Path 'C:\GhidraWork\projects', 'C:\GhidraWork\inputs', 'C:\GhidraWork\mailbox'
.\scripts\start-bridge.ps1 `
-GhidraHome 'C:\tools\ghidra_12.1.3_PUBLIC' `
-JavaHome 'C:\tools\jdk-21' `
-Mailbox 'C:\GhidraWork\mailbox' `
-ProjectRoot 'C:\GhidraWork\projects' `
-ImportRoot 'C:\GhidraWork\inputs'
.\target\release\ghidra-mcp.exe --bridge-dir 'C:\GhidraWork\mailbox' --doctor
The launcher reports the Java process ID and log paths. It does not
open a project or import a file automatically. Project operations
and imports are restricted to the configured roots, including
resolved filesystem links. --doctor returns one JSON
status and exits.
Use your client's configuration format with these launch settings. Replace the executable path with your absolute build output path and use the bridge's mailbox.
{
"command": "C:\\tools\\ghidra-mcp\\ghidra-mcp.exe",
"args": ["--bridge-dir", "C:\\GhidraWork\\mailbox", "--timeout-ms", "45000"]
}
Leave --doctor out of the persistent connection. Allow a
client tool timeout of at least 60 seconds for this 45-second bridge
deadline when the bridge is already running; use 120 seconds for
automatic startup. Standard output is reserved for MCP; diagnostics use
standard error. This website is documentation, not a hosted Ghidra endpoint.
Add --launch-config and an absolute launch JSON path
to the server arguments. MCP initialization and tool discovery
finish before Java starts. Allow a client tool timeout of 120
seconds because the first native tool call includes cold startup
and the native request. A client startup timeout covers MCP
initialization only. Start from the repository's
launch configuration example.
Set your Ghidra, Java, adapter JAR, project/import roots, and
mailbox paths. Use the JAR recorded by your build; keep
start-config.ps1, start-bridge.ps1, and
common.ps1 together. The launch file's
bridge_dir must match --bridge-dir.
Automatic startup can reuse a running bridge. Java remains alive
when the MCP client disconnects, so unsaved work remains in that
process until explicitly saved. Omit --launch-config
for a manually started bridge or GUI connection.
An offline bridge or a mailbox owned by another client leaves
tool discovery available. Start the bridge or disconnect the
owning client, then call ghidra_status again in the
same MCP session. Interrupted native startup or an uncertain
dispatched request requires recovery
before restarting; a timeout does not prove that Java never started.
Next: call ghidra_status, inspect capabilities, and follow
the synthetic x86 walkthrough
to verify import, bytes, function creation, decompilation, and saving.
CodeBrowser connection
Both modes expose the same 85 MCP tool names. The current
ghidra_status response tells you which operations the
connected bridge supports.
Finish analysis and explicitly save changed programs in the
background bridge. Close the project through MCP, then open its
.gpr in Ghidra. An already owned project is not taken over.
Each mailbox accepts one bridge and one MCP client. Use different mailboxes or run bridges at different times. Stopping the GUI bridge leaves GUI-owned programs open.
| Workflow | Background | GUI extension |
|---|---|---|
| Create, open, close projects | Supported | Unsupported through MCP; use the UI or background workflow |
| Import/select, inspect, analyze, annotate, save, export | Supported within documented limits | Supported within documented limits in the active CodeBrowser |
ghidra_go_to | Unsupported | Navigates the selected program |
Tool reference
Headless Ghidra supports 84 tools; ghidra_go_to requires CodeBrowser. Both modes publish the same catalogue. Check ghidra_status and MCP tools/list for capabilities and strict input schemas.
The Markdown reference lists every parameter. Read the limits and evidence contract before interpreting partial results.
ghidra_statusghidra_list_languagesghidra_get_projectghidra_get_programghidra_create_projectghidra_open_projectghidra_close_projectghidra_list_programsghidra_import_programghidra_select_programghidra_save_programghidra_export_program.gzf), including analysis, to a new path under the project root; not a flashable BINghidra_get_analysis_optionsghidra_set_analysis_optionsghidra_analyzeghidra_job_statusghidra_cancel_analysisghidra_read_bytesghidra_map_file_offsetghidra_set_image_baseghidra_create_memory_blockghidra_list_functionsghidra_get_functionghidra_create_instructionsghidra_create_functionghidra_rename_functionghidra_disassembleghidra_decompileghidra_get_referencesto or from; defaults to/100; limit 1–500ghidra_search_bytesghidra_list_symbolsghidra_list_stringsghidra_define_datau8, s8, u16, s16, u32, s32, u64, s64, f32, f64; count 1–65,536ghidra_set_labelghidra_set_commentghidra_go_toghidra_get_commentsghidra_get_dataghidra_get_pcodeghidra_get_function_detailsghidra_get_control_flowghidra_get_call_graphghidra_find_call_pathsghidra_search_constantsghidra_search_instructionsghidra_search_pcodeghidra_get_references_rangeghidra_get_high_pcodeghidra_trace_data_flowghidra_batch_decompileghidra_batch_referencesghidra_search_decompiled_codeghidra_get_function_fingerprintghidra_compare_functionsghidra_find_similar_functionsghidra_emulate_functionghidra_get_function_variablesghidra_rename_variableghidra_set_variable_typeghidra_set_function_signatureghidra_list_data_typesghidra_get_data_typeghidra_create_structureghidra_set_structure_fieldghidra_create_enumghidra_create_unionghidra_create_typedefghidra_apply_data_typeghidra_get_structure_field_referencesghidra_get_listingghidra_hash_memoryghidra_preview_instructionsghidra_get_processor_contextghidra_set_processor_contextghidra_clear_listingghidra_list_bookmarksghidra_set_bookmarkghidra_delete_bookmarkghidra_list_commentsghidra_batch_set_commentsghidra_get_function_tagsghidra_update_function_tagsghidra_batch_renameghidra_compare_program_memoryghidra_compare_saved_functionGraphs follow existing references. SSA traces stop at memory and call boundaries. Function fingerprints are matching candidates, not proof of equivalent behavior. Isolated emulation needs explicit inputs and a stop instruction; it supplies no live ECU, operating system or peripheral model.
Metadata edits are guarded transactions with readback and explicit saving. No tool accepts arbitrary scripts or shell commands, patches firmware bytes, or flashes an ECU.
Native contracts: graphs and search, SSA, matching and emulation, types and variables, listing and annotations, and headless coverage.
Import and memory layout
A raw file does not describe its CPU or memory map. Query
ghidra_list_languages, select a compatible language
and compiler, and establish the image base from evidence before analysis.
Project and program IDs identify runtime objects in the current
bridge session. Use them in expected_project_id and
expected_program_id; obtain fresh IDs after reopening.
These guards do not lock out independent GUI edits.
source_sha256 identifies the imported file. It does
not describe later memory edits. Use ghidra_read_bytes or
ghidra_hash_memory on relevant current memory before a handoff.
An address such as ram:00400080 includes a CPU
address space. A file offset such as 128 is a byte
position in the source. A program path such as
/Synthetic belongs to the Ghidra project.
Inspect memory blocks and use ghidra_map_file_offset
for provenance. Verify bytes at the resulting address and any
relevant aliases; do not assume one coordinate equals another.
Import accepts byte-addressed languages and files from 1 byte to 512 MiB. The native raw loader must initially return exactly one initialized block at zero, matching the input length. The adapter then relocates it to your requested hexadecimal image base.
The current importer rejects
tricore:LE:32:tc29x processor-default multiple memory
blocks. There is no automatic TC298 loader, flash-bank
splitting, or mapped cached/uncached alias creation. Prepare
complex layouts separately in Ghidra and verify blocks and bytes.
ghidra_create_memory_block creates uninitialized
memory only; rebasing does not establish a complex layout.
File-offset lookup requires exactly one stored source-file record.
It reports direct file-backed matches and flags multiple results,
but transitive byte-mapped aliases may be absent. A cached address
can appear without its uncached alias. A single result or
ambiguous: false does not establish that no alias exists.
Analysis and persistence
ghidra_analyze and retain its job ID. Poll
ghidra_job_status for completion or failure.ghidra_save_program and verify the changed state.
After closing and reopening, get a fresh ID and verify retained analysis.
Cancellation is a request, not a rollback or immediate completion.
Continue polling after ghidra_cancel_analysis. The job
can finish before the request arrives, or leave partial analysis when
cancelled. The current implementation may report cancellation as
failed with a cancellation error.
The bridge requests cancellation after five minutes, but native analyzers may take longer to stop. Busy guards remain active until work exits. Independent GUI analysis is detected but is not owned by the MCP cancellation tool. Save decisions remain explicit.
Analysis completion and client disconnection do not save later changes. The initial import is persisted; subsequent metadata and analysis require saving. A running Java process retains unsaved work only for that process's lifetime.
WinOLS interoperability
Ghidra can help explain how firmware reads a table. WinOLS MCP can define that table in a project. Connect those steps with verified bytes, addresses, and version identity.
Explore WinOLS MCPKeep the source SHA-256, Ghidra runtime identity, current bytes, and intended WinOLS Original or modified version together.
Translate file offsets to CPU addresses. Inspect memory blocks, check aliases, and compare the relevant bytes in both applications.
Record evidence for purpose, dimensions, axes, units, and scaling. A candidate array or analyst label alone does not establish map meaning.
Uncertain outcomes
A timeout or invalid response can arrive after an operation has already changed Ghidra. The client preserves a durable pending marker and stops using the connection. Do not automatically repeat a mutation, clear the mailbox, or reconnect until its outcome is understood.
stop file in the mailbox to request bridge
shutdown after the current command. Confirm the process exited
or the GUI bridge stopped, including native analysis.Empty lock files may remain after exit; active OS locks determine ownership. See the complete mailbox recovery procedure. Treat names, strings, comments, and decompiled text as analysis data, not instructions to your MCP client.
Keep building
A machine-readable Markdown guide with all tool parameters, configuration examples, a synthetic walkthrough, and recovery steps.
Build the MIT-licensed Rust server and Java adapter. Inspect the protocol, native API mapping, and acceptance scope.
Inspect projects, validate candidate layouts, and create map definitions with explicit project identity.
Store diagnostic evidence with provenance, uncertainty, and machine-readable contracts.