Skip to main content
Glama

🔍 Ghidra MCP Server

This project lets you use Ghidra in headless mode to extract rich binary analysis data (functions, pseudocode, structs, enums, etc.) into a JSON file, and expose it to LLMs like Claude via Model Context Protocol (MCP).

It turns Ghidra into an interactive reverse-engineering backend.


🚀 Features

  • Decompiles a binary using Ghidra headless mode

  • Extracts:

    • Function pseudocode, names, parameters, variables, strings, comments

    • Data structures (structs), enums, and function definitions

  • Outputs to ghidra_context.json

  • MCP server exposes tools like:

    • list_functions(), get_pseudocode(name)

    • list_structures(), get_structure(name)

    • list_enums(), get_enum(name)

    • list_function_definitions(), get_function_definition(name)


Related MCP server: Ghidra MCP Server

⚙️ System Requirements

  • macOS (tested)

  • Python 3.10+

  • Ghidra 11.3.1+

  • Java 21 (Temurin preferred)

  • MCP client (e.g. Claude Desktop)

  • mcp CLI (install via pip install mcp)


🧪 Installation & Setup

✅ 1. Install Java 21 (REQUIRED by Ghidra 11.3.1)

brew install --cask temurin@21

Then set it:

export JAVA_HOME=$(/usr/libexec/java_home -v 21)
echo 'export JAVA_HOME=$(/usr/libexec/java_home -v 21)' >> ~/.zshrc
source ~/.zshrc

Check it:

java -version

Should say: openjdk version "21.0.x"...


✅ 2. Install Ghidra

Download and extract Ghidra 11.3.1


✅ 3. Set up the project

cd ghidra_mcp
gcc -Wall crackme.c -o crackme

✅ 4. Install the server via MCP CLI

mcp install main.py

This registers the MCP server so Claude or other clients can access it.


✅ 5. Run in dev mode (for testing)

mcp dev main.py

This enables hot reload and developer logs.


🛰️ Tools Available

Tool

Description

setup_context(...)

Run Ghidra on a binary

list_functions()

All functions

get_pseudocode(name)

Decompiled pseudocode

list_structures()

All structs

get_structure(name)

Details of a struct

list_enums()

All enums

get_enum(name)

Enum values

list_function_definitions()

All function prototypes

get_function_definition()

Return type & args


Sample Promot

Analyze the binary file located at <BINARY_PATH> using Ghidra installed at <GHIDRA_PATH>. First, set up the analysis context using both paths, then list all functions in the binary. Examine the main entry point function and provide a high-level overview of what the program does.

🧠 Common Issues & Fixes

❌ Ghidra fails with “unsupported Java version”

➡️ Fix: Install Java 21, not 17 or 24:

brew install --cask temurin@21
export JAVA_HOME=$(/usr/libexec/java_home -v 21)

❌ spawn uv ENOENT (Claude Desktop can't find your UV binary)

➡️ Claude can't locate uv by name. To fix:

  1. Run in your terminal:

which uv

Example output:

/Users/yourname/.cargo/bin/uv
  1. Open your Claude Desktop config file:

open ~/Library/Application\ Support/Claude/claude_desktop_config.json
  1. Update it like so:

{
  "mcpServers": {
    "ghidra": {
      "command": "/Users/yourname/.cargo/bin/uv",
      "args": [
        "--directory",
        "/Users/yourname/Documents/ghidra_mcp",
        "run",
        "main.py"
      ]
    }
  }
}
  1. Restart Claude Desktop. You should now see your custom MCP tools.


❌ The operation couldn’t be completed. Unable to locate a Java Runtime.

➡️ Fix: Java not installed or JAVA_HOME is unset. Follow setup instructions above.


📂 Project Structure

File

Purpose

main.py

MCP server with tools

export_context.py

Ghidra script that extracts JSON

crackme.c

Sample C binary

crackme

Compiled binary to test


👨‍💻 Author

Tomi Bamimore
Ghidra by the NSA
MCP by Anthropic

Available Tools

9 tools
get_enumC

Get details of a specific enum by name.

Inputs: name (required).

get_function_definitionC

Get details of a specific function definition by name.

Inputs: name (required).

get_pseudocodeC

Get pseudocode for a specific function by name.

Inputs: name (required).

get_structureC

Get details of a specific structure by name.

Inputs: name (required).

list_enumsB

List all enum names from the loaded binary.

Inputs: no named parameters.

list_function_definitionsB

List all function definition names from the loaded binary.

Inputs: no named parameters.

list_functionsB

List all function names from the loaded binary.

Inputs: no named parameters.

list_structuresB

List all structure names from the loaded binary.

Inputs: no named parameters.

setup_contextC

Run Ghidra headless decompilation to export binary context.

Inputs: ghidra_path, binary_path.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A3.5/5.0

    Scored across 9 tools

    Disambiguation5/5

    Every tool has a clearly distinct purpose with no ambiguity. The 'get_' tools retrieve specific details for different binary elements (enum, function definition, pseudocode, structure), while the 'list_' tools enumerate names for those same elements, and 'setup_context' performs a distinct initialization task. There is no overlap in functionality that could cause misselection.

    Naming Consistency5/5

    Tool names follow a highly consistent verb_noun pattern throughout. All tools use snake_case with clear prefixes: 'get_' for retrieval, 'list_' for enumeration, and 'setup_' for initialization. This predictable naming scheme makes it easy for agents to understand and select the appropriate tool.

    Tool Count5/5

    With 9 tools, the server is well-scoped for its purpose of binary analysis with Ghidra. Each tool earns its place by covering distinct aspects of binary inspection (enums, functions, structures, pseudocode) and initialization. This count is typical for a domain-specific server and avoids being too thin or overwhelming.

    Completeness4/5

    The tool surface provides comprehensive read-only coverage for binary analysis, including listing and retrieving details for key elements like functions, structures, and enums, plus pseudocode and setup. A minor gap exists in write operations (e.g., modifying or creating elements), but agents can effectively work around this for analysis tasks.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables LLMs to autonomously reverse engineer binaries using Ghidra's capabilities including decompilation, function analysis, automatic renaming, and BSim integration for function similarity matching.
      1
      AGPL 3.0
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables LLMs and MCP clients to autonomously reverse engineer applications by exposing core Ghidra functionality, including decompiling and analyzing binaries, renaming methods and data, and listing methods, classes, imports, and exports.
      Apache 2.0
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI agents to analyze and diff binaries by driving Ghidra headless or inside its GUI, exposing native reverse-engineering tools such as listing functions and segments, searching strings, decompiling, disassembling, and following cross-references. Ships with a devcontainer and supports local stdio or remote HTTP deployment.
      MIT