ghidra-mcp
If you find this useful, please ⭐ star the repo — it helps others discover it!
A production-ready Model Context Protocol (MCP) server that bridges Ghidra's powerful reverse engineering capabilities with modern AI tools and automation frameworks.
🌟 Features
Core MCP Integration
- Full MCP Compatibility - Complete implementation of Model Context Protocol
- 110 MCP Tools Available - Comprehensive API surface for binary analysis
- Production-Ready Reliability - Tested batch operations and atomic transactions
- Real-time Analysis - Live integration with Ghidra's analysis engine
Binary Analysis Capabilities
- Function Analysis - Decompilation, call graphs, cross-references
- Data Structure Discovery - Automatic struct/union/enum creation
- String Extraction - Comprehensive string analysis and categorization
- Import/Export Analysis - Symbol table and library dependency mapping
- Memory Mapping - Complete memory layout documentation
- Cross-Binary Documentation - Function hash matching across binary versions
Development & Automation
- Automated Development Cycle - Complete build-test-deploy-verify pipeline
- Ghidra Script Management - Create, run, and manage Ghidra scripts via MCP
- Multi-Program Support - Switch between and compare multiple open programs
- Batch Operations - Efficient bulk renaming, commenting, and typing
🚀 Quick Start
Prerequisites
- Java 21 LTS (OpenJDK recommended)
- Apache Maven 3.9+
- Ghidra 12.0.2 (or compatible version)
- Python 3.8+ with pip
Installation
Recommended for Windows: use
ghidra-mcp-setup.ps1as the primary entry point. It handles prerequisite setup + build + deployment in one command.Important:
-SetupDepsinstalls Maven/Ghidra JAR dependencies only.-Deployis the end-user command and (by default) also ensures Python requirements before build/deploy.
Clone the repository:
git clone https://github.com/bethington/ghidra-mcp.git cd ghidra-mcpRecommended: run environment preflight first:
.\ghidra-mcp-setup.ps1 -Preflight -GhidraPath "C:\ghidra_12.0.2_PUBLIC"Build and deploy to Ghidra (single command):
.\ghidra-mcp-setup.ps1 -Deploy -GhidraPath "C:\ghidra_12.0.2_PUBLIC"Optional strict/manual mode (advanced):
# Skip automatic prerequisite setup .\ghidra-mcp-setup.ps1 -Deploy -NoAutoPrereqs -GhidraPath "C:\ghidra_12.0.2_PUBLIC"Show script help:
.\ghidra-mcp-setup.ps1 -Help # or Get-Help .\ghidra-mcp-setup.ps1 -DetailedOptional build-only mode (advanced/troubleshooting):
# Preferred: script-managed build-only .\ghidra-mcp-setup.ps1 -BuildOnly# Manual Maven build (requires Ghidra deps already installed in local .m2) mvn clean package assembly:single -DskipTests
Basic Usage
Option 1: Stdio Transport (Recommended for AI tools)
python bridge_mcp_ghidra.py
Option 2: SSE Transport (Web/HTTP clients)
python bridge_mcp_ghidra.py --transport sse --mcp-host 127.0.0.1 --mcp-port 8081
In Ghidra
- Start Ghidra and open a CodeBrowser window
- In CodeBrowser, enable the plugin via File > Configure > Configure All Plugins > GhidraMCP
- Optional: configure custom port via CodeBrowser > Edit > Tool Options > GhidraMCP HTTP Server
- Start the server via Tools > GhidraMCP > Start MCP Server
- The server runs on
http://127.0.0.1:8089/by default
📊 Production Performance
- MCP Tools: 110 tools fully implemented
- Speed: Sub-second response for most operations
- Efficiency: 93% reduction in API calls via batch operations
- Reliability: Atomic transactions with all-or-nothing semantics
- Deployment: Automated version-aware deployment script
🛠️ API Reference
Core Operations
check_connection- Verify MCP connectivityget_metadata- Program metadata and infoget_version- Server version informationget_entry_points- Binary entry points discovery
Function Analysis
list_functions- List all functions (paginated)search_functions_by_name- Search functions by name/patternsearch_functions_enhanced- Advanced function search with filtersdecompile_function- Decompile function to C pseudocodeget_decompiled_code- Get decompiled code by addressget_function_callers- Get function callersget_function_callees- Get function calleesget_function_call_graph- Function relationship graphget_full_call_graph- Complete call graph for programanalyze_function_complete- Comprehensive function analysisanalyze_function_completeness- Documentation completeness score
Memory & Data
list_segments- Memory segments and layoutget_function_by_address- Function at addressdisassemble_function- Disassembly listingdisassemble_bytes- Raw byte disassemblyget_xrefs_to- Cross-references to addressget_xrefs_from- Cross-references from addressget_bulk_xrefs- Bulk cross-reference lookupanalyze_data_region- Analyze memory region structureinspect_memory_content- View raw memory contentdetect_array_bounds- Detect array boundaries
Cross-Binary Documentation (v1.9.4+)
get_function_hash- SHA-256 hash of normalized function opcodesget_bulk_function_hashes- Paginated bulk hashing with filterget_function_documentation- Export complete function documentationapply_function_documentation- Import documentation to target functionbuild_function_hash_index- Build persistent JSON indexlookup_function_by_hash- Find matching functions in indexpropagate_documentation- Apply docs to all matching instances
Data Types & Structures
list_data_types- Available data typessearch_data_types- Search for data typescreate_struct- Create custom structureadd_struct_field- Add field to structuremodify_struct_field- Modify existing fieldremove_struct_field- Remove field from structurecreate_enum- Create enumerationget_enum_values- Get enumeration valuescreate_array_type- Create array data typeapply_data_type- Apply type to addressdelete_data_type- Delete a data typeconsolidate_duplicate_types- Merge duplicate typesget_valid_data_types- Get list of valid Ghidra types
Symbols & Labels
list_imports- Imported symbols and librarieslist_exports- Exported symbols and functionslist_external_locations- External location referenceslist_strings- Extracted strings with analysislist_namespaces- Available namespaceslist_globals- Global variablescreate_label- Create label at addressbatch_create_labels- Bulk label creationdelete_label- Delete label at addressbatch_delete_labels- Bulk label deletionrename_label- Rename existing labelrename_or_label- Rename or create label
Renaming & Documentation
rename_function- Rename function by namerename_function_by_address- Rename function by addressrename_data- Rename data itemrename_variables- Rename function variablesrename_global_variable- Rename global variablerename_external_location- Rename external referencebatch_rename_function_components- Bulk renamingset_decompiler_comment- Set decompiler commentset_disassembly_comment- Set disassembly commentset_plate_comment- Set function plate commentget_plate_comment- Get function plate commentbatch_set_comments- Bulk comment setting
Type System
set_function_prototype- Set function signatureset_local_variable_type- Set variable typeset_parameter_type- Set parameter typebatch_set_variable_types- Bulk type settingset_variable_storage- Control variable storage locationset_function_no_return- Mark function as non-returninglist_calling_conventions- Available calling conventionsget_function_variables- Get all function variablesget_function_labels- Get labels in function
Ghidra Script Management
list_scripts- List available scriptsrun_script- Run a scriptlist_ghidra_scripts- List custom Ghidra scriptssave_ghidra_script- Save new scriptget_ghidra_script- Get script contentsrun_ghidra_script- Execute Ghidra scriptupdate_ghidra_script- Update existing scriptdelete_ghidra_script- Delete script
Multi-Program Support
list_open_programs- List all open programsget_current_program_info- Current program detailsswitch_program- Switch active programlist_project_files- List project filesopen_program- Open program from projectcompare_programs_documentation- Compare documentation between programs
Analysis Tools
find_next_undefined_function- Find undefined functionsfind_undocumented_by_string- Find functions by string referencebatch_string_anchor_report- String anchor analysissearch_byte_patterns- Search for byte patternsget_assembly_context- Get assembly contextanalyze_struct_field_usage- Analyze structure field accessget_field_access_context- Get field access patternscreate_function- Create function at addressget_function_jump_target_addresses- Get jump targets
See docs/README.md for complete documentation.
🏗️ Architecture
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ AI/Automation │◄──►│ MCP Bridge │◄──►│ Ghidra Plugin │
│ Tools │ │ (bridge_mcp_ │ │ (GhidraMCP.jar) │
│ (Claude, etc.) │ │ ghidra.py) │ │ │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│ │ │
MCP Protocol HTTP REST Ghidra API
(stdio/SSE) (localhost:8080) (Program, Listing)
Components
- bridge_mcp_ghidra.py - Python MCP server that translates MCP protocol to HTTP calls
- GhidraMCP.jar - Ghidra plugin that exposes analysis capabilities via HTTP
- ghidra_scripts/ - Collection of 70+ automation scripts for common tasks
🔧 Development
Building from Source
# Recommended: one command does setup + build + deploy
.\ghidra-mcp-setup.ps1 -Deploy -GhidraPath "C:\ghidra_12.0.2_PUBLIC"
# Optional: build only (no deploy)
.\ghidra-mcp-setup.ps1 -BuildOnly
Script Command Reference
Primary actions (choose one):
-Deploy(default): auto-setup prereqs, build, deploy-SetupDeps: install Ghidra JARs into local.m2(Maven deps only; no Python package install)-BuildOnly: build artifacts only-Clean: remove build/cache artifacts and local Ghidra dependency folders in.m2for the active Ghidra version-Preflight: validate tools, paths, required Ghidra jars, and write access without making changes
Useful options:
-GhidraPath "C:\ghidra_12.0.2_PUBLIC"-GhidraVersion "12.0.2"-StrictPreflight-NoAutoPrereqs-SkipBuild-SkipRestart-DryRun-Force-Verbose-Help
Quick examples:
# Standard deploy (recommended)
.\ghidra-mcp-setup.ps1 -Deploy -GhidraPath "C:\ghidra_12.0.2_PUBLIC"
# First-time dependency setup only
.\ghidra-mcp-setup.ps1 -SetupDeps -GhidraPath "C:\ghidra_12.0.2_PUBLIC"
# Build only
.\ghidra-mcp-setup.ps1 -BuildOnly
# Preflight checks only
.\ghidra-mcp-setup.ps1 -Preflight -GhidraPath "C:\ghidra_12.0.2_PUBLIC"
# Strict preflight (fails on warnings)
.\ghidra-mcp-setup.ps1 -Preflight -StrictPreflight -GhidraPath "C:\ghidra_12.0.2_PUBLIC"
# Show command help
.\ghidra-mcp-setup.ps1 -Help
Project Structure
ghidra-mcp/
├── bridge_mcp_ghidra.py # MCP server (Python)
├── src/main/java/ # Ghidra plugin (Java)
├── lib/ # Optional local workspace cache (not used by Maven resolution)
├── ghidra_scripts/ # 70+ automation scripts
├── docs/ # Documentation
│ ├── prompts/ # AI workflow prompts
│ ├── releases/ # Version release notes
│ └── project-management/ # Project docs
├── examples/ # Example usage
└── scripts/ # Build/utility scripts
Library Dependencies
Ghidra JARs must be installed into your local Maven repository (~/.m2/repository) before compilation.
This is a one-time setup per machine, and again when your Ghidra version changes.
-Deploy now installs these automatically by default.
The tool enforces version consistency between:
pom.xml(ghidra.version)-GhidraVersion(if provided)-GhidraPathversion segment (e.g.,ghidra_12.0.2_PUBLIC)
If these do not match, deployment fails fast with a clear error.
Troubleshooting: Version Mismatch
If you see a version mismatch error, align all three values:
pom.xml→ghidra.version-GhidraVersion(if used)-GhidraPathversion segment (ghidra_X.Y.Z_PUBLIC)
Then rerun:
.\ghidra-mcp-setup.ps1 -Deploy -GhidraPath "C:\ghidra_12.0.2_PUBLIC" -GhidraVersion "12.0.2"
# Windows
.\ghidra-mcp-setup.ps1 -SetupDeps -GhidraPath "C:\path\to\ghidra_12.0.2_PUBLIC"
# Optional version override
.\ghidra-mcp-setup.ps1 -SetupDeps -GhidraPath "C:\path\to\ghidra_12.0.2_PUBLIC" -GhidraVersion "12.0.2"
Required Libraries (14 JARs, ~37MB):
| Library | Source Path | Purpose |
|---|---|---|
| Base.jar | Features/Base/lib/ |
Core Ghidra functionality |
| Decompiler.jar | Features/Decompiler/lib/ |
Decompilation engine |
| PDB.jar | Features/PDB/lib/ |
Microsoft PDB symbol support |
| FunctionID.jar | Features/FunctionID/lib/ |
Function identification |
| SoftwareModeling.jar | Framework/SoftwareModeling/lib/ |
Program model API |
| Project.jar | Framework/Project/lib/ |
Project management |
| Docking.jar | Framework/Docking/lib/ |
UI docking framework |
| Generic.jar | Framework/Generic/lib/ |
Generic utilities |
| Utility.jar | Framework/Utility/lib/ |
Core utilities |
| Gui.jar | Framework/Gui/lib/ |
GUI components |
| FileSystem.jar | Framework/FileSystem/lib/ |
File system support |
| Graph.jar | Framework/Graph/lib/ |
Graph/call graph analysis |
| DB.jar | Framework/DB/lib/ |
Database operations |
| Emulation.jar | Framework/Emulation/lib/ |
P-code emulation |
Note: Libraries are NOT included in the repository (see
.gitignore). You must install them from your Ghidra installation before building.
Script roles:
ghidra-mcp-setup.ps1: unified automation script (-SetupDeps,-BuildOnly,-Deploy,-Clean)- default
-Deploybehavior: auto-setup prerequisites, then build and deploy- use
-NoAutoPrereqsfor strict/manual prerequisite management
Development Features
- Automated Deployment: Version-aware deployment script
- Batch Operations: Reduces API calls by 93%
- Atomic Transactions: All-or-nothing semantics
- Comprehensive Logging: Debug and trace capabilities
📚 Documentation
Core Documentation
- Documentation Index - Complete documentation navigation
- Project Structure - Project organization guide
- Naming Conventions - Code naming standards
- Hungarian Notation - Variable naming guide
AI Workflow Prompts
- Prompts Overview - AI prompting system guide
- Function Documentation Workflow - Complete workflow
- Quick Start Prompt - Simplified beginner workflow
- Cross-Version Matching - Hash-based matching
Release History
- Complete Changelog - All version release notes
- Release Notes - Detailed release documentation
🤝 Contributing
See CONTRIBUTING.md for detailed contribution guidelines.
Quick Start
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Build and test your changes (
mvn clean package assembly:single -DskipTests) - Update documentation as needed
- Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
📄 License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
🏆 Production Status
| Metric | Value |
|---|---|
| Version | 2.0.0 |
| MCP Tools | 110 fully implemented |
| Compilation | ✅ 100% success |
| Batch Efficiency | 93% API call reduction |
| Ghidra Scripts | 70+ automation scripts |
| Documentation | Comprehensive with AI prompts |
See CHANGELOG.md for version history and release notes.
🙏 Acknowledgments
- Ghidra Team - For the incredible reverse engineering platform
- Model Context Protocol - For the standardized AI integration framework
- Contributors - For testing, feedback, and improvements
🔗 Related Projects
- re-universe — Ghidra BSim PostgreSQL platform for large-scale binary similarity analysis. Pairs perfectly with GhidraMCP for AI-driven reverse engineering workflows.
- cheat-engine-server-python — MCP server for dynamic memory analysis and debugging.
Ready for production deployment with enterprise-grade reliability and comprehensive binary analysis capabilities.
