Mecha Ghidra
GhidraMCP for headless
Ask AI about Mecha Ghidra
Powered by Claude · Grounded in docs
I know everything about Mecha Ghidra. Ask me about installation, configuration, usage, or troubleshooting.
0/500
Reviews
Documentation
Mecha Ghidra - Headless Ghidra MCP for Ghidra Server
Mecha Ghidra is a Python package that exposes Ghidra as a headless MCP server with PyGhidra and FastMCP. It supports analysis and editing in Ghidra projects, multi-target session management, import/load switching, and optional shared-project sync workflows for collaborative AI-assisted reverse engineering.
Documentation
- Usage Guide | 日本語: setup, shared-project operations, multi-target workflows, and Codex/Claude/Kilocode integration
- Development Guide | 日本語: development flow and testing
Quick Start
- Sync dependencies
uv sync - Set the Ghidra path
export GHIDRA_INSTALL_DIR=/path/to/ghidra - Start the server (Streamable HTTP)
uv run ghidra-mcp \ --project-location /Users/samsepi0l/ghidra_project.gpr \ --domain-path /main \ --transport http \ --mcp-host 127.0.0.1 \ --mcp-port 8081 \ --mcp-path /mcp
For operational patterns and shared-project authentication details, see the Usage Guide.
Key Features
- Function and symbol operations: list functions, decompile, rename, retrieve xrefs, and more.
- Data-type editing: create/update/delete structs, enums, and class-like data types.
- Memory access: read/search/write bytes and apply global data types.
- Comments: set disassembly/decompiler comments.
- PyGhidra-based runtime: calls Ghidra APIs directly from CPython (not Jython).
- Multi-target management: hold multiple sessions in one process and switch by target name.
- Project operations: list project programs with
list_project_programs, import new binaries withimport_program, and switch loaded programs withload_project_program.
FastMCP tools are grouped under ghidra_headless.handlers.core and exposed to MCP clients through ghidra_mcp.cli. For full CLI options, run uv run ghidra-mcp --help.
Available Tools
Core Operations
list_targets- List registered targets and associated project metadatacreate_session- Add a target by opening an existing project programregister_target- Register project metadata to a target without opening a programclose_session- Close a target sessionclose_session_and_remove_program- Close a session and remove the program from the projectlist_project_programs- List programs in the target's opened projectimport_program- Import a binary or.gzfinto the projectload_project_program- Load an existing program bydomain_path
Function Analysis
list_methods- List methods (with pagination)list_functions- List functionslist_classes- List classeslist_namespaces- List namespaces (with pagination)search_functions_by_name- Partial-match search by function namedecompile_function- Get C-like pseudocode by function namedecompile_function_by_address- Get C-like pseudocode by addressdisassemble_function- Get disassembly for a functionget_function_by_address- Get function metadata by addressget_function_xrefs- Get incoming/outgoing references from a function nameget_callee- Get callee function at a specific address
Memory and Data
list_segments- Get memory segment/layout infolist_imports- List imported symbolslist_exports- List exported symbolslist_data_items- List data itemslist_strings- List strings (filterable)get_xrefs_to- Get cross-references to an addressget_xrefs_from- Get cross-references from an addressget_data_by_label- Get data by label nameget_bytes- Read bytes at an addresssearch_bytes- Search byte patterns
Symbol and Comment Editing
rename_function- Rename a function (by old name)rename_function_by_address- Rename a function (by address)rename_variable- Rename a local variable or argumentrename_data- Rename a data labelset_function_prototype- Set function prototypeset_local_variable_type- Set type for local variable/argumentset_global_data_type- Set global data type (clear_modeoptional)set_bytes- Write bytes into memoryset_decompiler_comment- Set decompiler commentset_disassembly_comment- Set disassembly commentadd_bookmark- Add bookmark
Data Type Operations
create_struct- Create structadd_struct_members- Add struct membersclear_struct- Remove all struct membersremove_struct_members- Remove selected struct membersget_struct- Get struct definitioncreate_enum- Create enumadd_enum_values- Add enum valuesremove_enum_values- Remove enum valuesget_enum- Get enum definitioncreate_class- Create GhidraClass namespace and backing structadd_class_members- Add members to class-like data typeremove_class_members- Remove members from class-like data type
Shared Project Sync (only with --enable-shared-project-sync)
get_project_sync_status / get_version_history / get_version_diff / checkout / commit / pull / undo_checkout / terminate_checkout / reload support optional domain_path (if omitted, the currently loaded program is used).
get_project_sync_status- Get sync state against shared projectget_version_history- Get version history (version/user/comment/time)get_version_diff- Get summarized differences between two versions (count/type/address range)checkout_project_program- Checkout program (exclusive optional)add_project_program_to_version_control- Add private program to shared version controlcommit_project_program- Check in checked-out changespull_project_program- Pull latest state (with optional discard/follow behavior)undo_checkout_project_program- Undo checkout (optional local change discard)terminate_project_program_checkout- Force-close an existing checkout by checkout IDreload_project_program- Reload currently opened program
See the Usage Guide for detailed workflows and constraints.
License
See the bundled LICENSE file for project licensing.
