GhydraMCP v2.0
GhydraMCP is a powerful bridge between Ghidra and AI assistants that enables comprehensive AI-assisted reverse engineering through the Model Context Protocol (MCP).
Overview
GhydraMCP v2.0 integrates three key components:
- Modular Ghidra Plugin: Exposes Ghidra's powerful reverse engineering capabilities through a HATEOAS-driven REST API
- MCP Bridge: A Python script that translates MCP requests into API calls with comprehensive type checking
- Multi-instance Architecture: Connect multiple Ghidra instances to analyze different binaries simultaneously
This architecture enables AI assistants like Claude to seamlessly:
- Decompile and analyze binary code with customizable output formats
- Map program structures, function relationships, and complex data types
- Perform advanced binary analysis (cross-references, call graphs, data flow, etc.)
- Make precise modifications to the analysis (rename, annotate, create/delete/modify data, etc.)
- Read memory directly and manipulate binary at a low level
- Navigate resources through discoverable HATEOAS links
GhydraMCP is based on GhidraMCP by Laurie Wired but has evolved into a comprehensive reverse engineering platform with enhanced multi-instance support, extensive data manipulation capabilities, and a robust HATEOAS-compliant API architecture.
Features
GhydraMCP version 2.0 provides a comprehensive set of reverse engineering capabilities to AI assistants through its HATEOAS-driven API:
Advanced Program Analysis
-
Enhanced Decompilation:
- Convert binary functions to readable C code
- Toggle between clean C-like pseudocode and raw decompiler output
- Show/hide syntax trees for detailed analysis
- Multiple simplification styles for different analysis approaches
-
Comprehensive Static Analysis:
- Cross-reference analysis (find callers and callees)
- Complete call graph generation and traversal
- Data flow analysis with variable tracking
- Type propagation and reconstruction
- Function relationship mapping
-
Memory Operations:
- Direct memory reading with hex and raw byte representation
- Address space navigation and mapping
- Memory segment analysis
-
Symbol Management:
- View and analyze imports and exports
- Identify library functions and dependencies
- Symbol table exploration and manipulation
- Namespace hierarchy visualization
Interactive Reverse Engineering
-
Code Understanding:
- Explore function code with rich context
- Analyze data structures and complex types
- View disassembly with linking to decompiled code
- Examine function prototypes and signatures
-
Comprehensive Annotation:
- Rename functions, variables, and data
- Add multiple comment types (EOL, plate, pre/post)
- Create and modify data types
- Set and update function signatures and prototypes
Complete Data Manipulation
-
Data Creation and Management:
- Create new data items with specified types
- Delete existing data items
- Rename data items with proper scope handling
- Set and update data types for existing items
- Combined rename and retype operations
- Type definition management
-
Function Manipulation:
- Rename functions with proper scoping
- Update function signatures with parameter information
- Modify local variable names and types
- Set function return types
Multi-instance Support
- Run multiple Ghidra instances simultaneously
- Analyze different binaries in parallel
- Connect to specific instances using port numbers
- Auto-discovery of running Ghidra instances
- Instance metadata with project and file information
- Plugin version and API checking for compatibility
Program Navigation and Discovery
- List and search functions, classes, and namespaces
- View memory segments and layout
- Search by name, pattern, or signature
- Resource discovery through HATEOAS links
- Pagination for handling large result sets
- Filtering capabilities across all resources
Installation
Prerequisites
Ghidra
First, download the latest release from this repository. The "Complete" artifact contains the zipped Ghidra plugin and the Python MCP bridge. Unpack the outer archive, then, add the plugin to Ghidra:
- Run Ghidra
- Select
File->Install Extensions - Click the
+button - Select the
GhydraMCP-[version].zipfile from the downloaded release - Restart Ghidra
- Make sure the GhydraMCPPlugin is enabled in
File->Configure->Developer
Note: By default, the first CodeBrowser opened in Ghidra gets port 8192, the second gets 8193, and so on. You can check which ports are being used by looking at the Console in the Ghidra main (project) window - click the computer icon in the bottom right to "Open Console". Look for log entries like:
(HydraMCPPlugin) Plugin loaded on port 8193 (HydraMCPPlugin) HydraMCP HTTP server started on port 8193GhydraMCP now includes auto-discovery of running Ghidra instances, so manually registering each instance is typically not necessary. The MCP bridge will automatically discover and register instances on startup and periodically check for new ones.
Video Installation Guide:
https://github.com/user-attachments/assets/75f0c176-6da1-48dc-ad96-c182eb4648c3
MCP Clients
GhydraMCP works with any MCP-compatible client using stdio transport. It has been tested and confirmed working with:
- Claude Desktop - Anthropic's official desktop application
- Claude Code - Anthropic's VS Code extension and CLI tool
- Cline - Popular VS Code extension for AI-assisted coding
See the Client Setup section below for detailed configuration instructions for each client.
API Reference (Updated for v2.0)
Available Tools
Program Analysis:
list_functions: List all functions (params: offset, limit)list_classes: List all classes/namespaces (params: offset, limit)decompile_function: Get decompiled C code (params: name or address)get_function: Get function details (params: name or address)get_callgraph: Get function call graph (params: address)list_segments: View memory segments (params: offset, limit)list_imports: List imported symbols (params: offset, limit)list_exports: List exported functions (params: offset, limit)list_namespaces: Show namespaces (params: offset, limit)list_data_items: View data labels (params: offset, limit)list_strings: List all defined strings in binary (params: offset, limit, filter)search_functions_by_name: Find functions (params: query, offset, limit)
Function Operations:
rename_function: Rename a function (params: name, new_name)set_function_signature: Update function prototype (params: address, signature)set_comment: Add comments (params: address, comment, comment_type)remove_comment: Remove comments (params: address, comment_type)
Memory Operations:
read_memory: Read bytes from memory (params: address, length)get_disassembly: Get disassembled instructions (params: address, length)
Data Manipulation:
create_data: Create new data at address (params: address, data_type)delete_data: Delete data at address (params: address)set_data_type: Change data type at address (params: address, data_type)rename_data: Rename data at address (params: address, name)update_data: Update both name and type (params: address, name, data_type)
Instance Management:
list_instances: List active Ghidra instances, automatically discovering new ones on default host (no params) - use this firstdiscover_instances: Discover instances on a specific host (params: host [optional]) - only use for non-default hostsregister_instance: Register new instance (params: port, url)unregister_instance: Remove instance (params: port)
Example Usage:
# Program analysis
client.use_tool("ghydra", "decompile_function", {"name": "main"})
client.use_tool("ghydra", "get_function", {"address": "0x00401000"})
client.use_tool("ghydra", "get_callgraph", {"address": "0x00401000"})
# Memory and disassembly operations
client.use_tool("ghydra", "read_memory", {"address": "0x00401000", "length": 16})
client.use_tool("ghydra", "get_disassembly", {"address": "0x00401000", "length": 32})
# String analysis
client.use_tool("ghydra", "list_strings") # List all strings in the binary
client.use_tool("ghydra", "list_strings", {"limit": 100, "offset": 0}) # Pagination
client.use_tool("ghydra", "list_strings", {"filter": "password"}) # Search for strings containing "password"
# Function operations
client.use_tool("ghydra", "set_function_signature", {"address": "0x00401000", "signature": "int main(int argc, char **argv)"})
client.use_tool("ghydra", "set_comment", {"address": "0x00401100", "comment": "This instruction initializes the counter", "comment_type": "plate"})
# Data manipulation
client.use_tool("ghydra", "create_data", {"address": "0x00401234", "data_type": "int"})
client.use_tool("ghydra", "set_data_type", {"address": "0x00401238", "data_type": "char *"})
client.use_tool("ghydra", "rename_data", {"address": "0x00401234", "name": "my_variable"})
client.use_tool("ghydra", "update_data", {"address": "0x00401238", "name": "ptr_var", "data_type": "char *"})
client.use_tool("ghydra", "delete_data", {"address": "0x0040123C"})
# Instance management
client.use_tool("ghydra", "list_instances") # Lists all instances (auto-discovers on default host)
client.use_tool("ghydra", "discover_instances", {"host": "192.168.1.10"}) # Only if scanning different host
client.use_tool("ghydra", "register_instance", {"port": 8192, "url": "http://localhost:8192/"})
client.use_tool("ghydra", "register_instance", {"port": 8193})
Client Setup
GhydraMCP works with any MCP-compatible client. Below are configuration examples for popular AI coding assistants.
Claude Desktop Configuration
Add this to your Claude Desktop configuration file (~/Library/Application Support/Claude/claude_desktop_config.json on macOS, %APPDATA%\Claude\claude_desktop_config.json on Windows):
{
"mcpServers": {
"ghydra": {
"command": "uv",
"args": [
"run",
"/ABSOLUTE_PATH_TO/bridge_mcp_hydra.py"
],
"env": {
"GHIDRA_HYDRA_HOST": "localhost"
}
}
}
}
Note: You can also use
pythoninstead ofuv run, but then you'll need to manually install the requirements first withpip install mcp requests.
Claude Code Configuration
Claude Code automatically discovers MCP servers configured in Claude Desktop. If you've set up the configuration above, Claude Code will have access to GhydraMCP tools immediately.
Alternatively, you can configure Claude Code separately by adding the same configuration to the MCP settings in Claude Code's configuration.
Cline Configuration
Cline (VS Code extension) uses a separate configuration file. To set up GhydraMCP with Cline:
- Open VS Code with Cline installed
- Click the "MCP Servers" icon in Cline's interface
- Select the "Configure" tab
- Click "Configure MCP Servers" to edit
cline_mcp_settings.json - Add the following configuration:
{
"mcpServers": {
"ghydra": {
"command": "uv",
"args": [
"run",
"/ABSOLUTE_PATH_TO/bridge_mcp_hydra.py"
],
"env": {
"GHIDRA_HYDRA_HOST": "localhost"
},
"disabled": false
}
}
}
If you prefer to use python directly instead of uv:
{
"mcpServers": {
"ghydra": {
"command": "python",
"args": [
"/ABSOLUTE_PATH_TO/bridge_mcp_hydra.py"
],
"env": {
"GHIDRA_HYDRA_HOST": "localhost"
},
"disabled": false
}
}
}
Important: Replace
/ABSOLUTE_PATH_TO/with the actual absolute path to yourbridge_mcp_hydra.pyfile. For example:
- Linux/macOS:
/home/username/GhydraMCP/bridge_mcp_hydra.py- Windows:
C:\\Users\\username\\GhydraMCP\\bridge_mcp_hydra.py
After saving the configuration, restart Cline to load the GhydraMCP server.
5ire Configuration
- Tool Key: ghydra
- Name: GhydraMCP
- Command:
uv run /ABSOLUTE_PATH_TO/bridge_mcp_hydra.py
Example Session
Below is an example of how an AI assistant might interact with multiple Ghidra instances using GhydraMCP:
User:
Check which Ghidra instances are currently running.
Assistant:
I'll check which Ghidra instances are currently running.
View result from list_instances from ghydra (local)
{
"instances": [
{
"port": 8192,
"url": "http://localhost:8192",
"project": "TestProject",
"file": "application.exe"
},
{
"port": 8193,
"url": "http://localhost:8193",
"project": "FirmwareAnalysis",
"file": "firmware.bin"
}
]
}
I found two active Ghidra instances:
1. Port 8192: Analyzing "application.exe" in project "TestProject"
2. Port 8193: Analyzing "firmware.bin" in project "FirmwareAnalysis"
I'm ready to analyze these binaries. What would you like me to examine?
User:
List the functions through ghydra for both instances and identify any related functionality.
Assistant:
I'll list the functions from both instances and analyze them.
View result from list_functions from ghydra (local){
`port`: 8192
}
[Function list for application.exe...]
View result from list_functions from ghydra (local){
`port`: 8193
}
[Function list for firmware.bin...]
I notice some interesting functions in both binaries. Let me decompile a few to understand their behavior.
View result from get_function from ghydra (local){
`port`: 8192,
`name`: "process_command"
}
[Decompiled code for process_command...]
View result from get_function from ghydra (local){
`port`: 8193,
`name`: "handle_message"
}
[Decompiled code for handle_message...]
Based on this analysis, I can see these binaries communicate using a simple protocol where...
JSON Communication
GhydraMCP uses structured JSON for all communication between the Python bridge and Java plugin. This ensures consistent and reliable data exchange.
API Architecture
GhydraMCP v2.0 implements a comprehensive HATEOAS-driven REST API that follows hypermedia design principles:
Core API Design
- HATEOAS Architecture: Each response includes navigational links for resource discovery
- Versioned Endpoints: All requests verified against API version for compatibility
- Structured Responses: Standardized JSON format with consistent field naming
- Proper HTTP Methods: GET for retrieval, POST for creation, PATCH for updates, DELETE for removal
- Appropriate Status Codes: Uses standard HTTP status codes for clear error handling
Response Format
All responses follow this HATEOAS-driven format:
{
"id": "req-123",
"instance": "http://localhost:8192",
"success": true,
"result": "...",
"timestamp": 1712159482123,
"_links": {
"self": {"href": "/endpoint/current"},
"related": [
{"href": "/endpoint/related1", "name": "Related Resource 1"},
{"href": "/endpoint/related2", "name": "Related Resource 2"}
]
}
}
For list responses, pagination information is included:
{
"id": "req-123",
"instance": "http://localhost:8192",
"success": true,
"result": [ ... objects ... ],
"size": 150,
"offset": 0,
"limit": 50,
"_links": {
"self": { "href": "/functions?offset=0&limit=50" },
"next": { "href": "/functions?offset=50&limit=50" },
"prev": { "href": "/functions?offset=0&limit=50" }
}
}
Error responses include detailed information:
{
"id": "req-123",
"instance": "http://localhost:8192",
"success": false,
"error": {
"code": "RESOURCE_NOT_FOUND",
"message": "Function 'main' not found in current program"
},
"status_code": 404,
"timestamp": 1712159482123,
"_links": {
"self": {"href": "/functions/main"}
}
}
This HATEOAS approach enables resource discovery and self-documenting APIs, making integration and exploration significantly easier.
Testing
GhydraMCP includes comprehensive test suites for both the HTTP API and MCP bridge. See TESTING.md for details on running the tests.
HTTP API Tests
Tests the HTTP endpoints exposed by the Java plugin:
- Response format and structure
- JSON structure consistency
- Required fields in responses
- Error handling
MCP Bridge Tests
Tests the MCP bridge functionality:
- MCP protocol communication
- Tool availability and structure
- Response format and structure
- JSON structure consistency
Building from Source
You can build different artifacts with Maven:
Build Everything (Default)
Build both the Ghidra plugin and the complete package:
mvn clean package
This creates:
target/GhydraMCP-[version].zip- The Ghidra plugin onlytarget/GhydraMCP-Complete-[version].zip- Complete package with plugin and bridge script
Build Ghidra Plugin Only
If you only need the Ghidra plugin:
mvn clean package -P plugin-only
Build Complete Package Only
If you only need the combined package:
mvn clean package -P complete-only
The Ghidra plugin includes these files required for Ghidra to recognize the extension:
- lib/GhydraMCP.jar
- extension.properties
- Module.manifest