Python 命令行 Ghidra MCP
pyghidra-mcp is a command-line Model Context Protocol (MCP) server that brings the full analytical power of Ghidra, a robust software reverse engineering (SRE) suite, into the world of intelligent agents and LLM-based tooling.
It bridges Ghidra’s ProgramAPI and FlatProgramAPI to Python using pyghidra and jpype, then exposes that functionality via the Model Context Protocol.
MCP is a unified interface that allows language models, development tools (like VS Code), and autonomous agents to access structured context, invoke tooling, and collaborate intelligently. Think of MCP as the bridge between powerful analysis tools and the LLM ecosystem.
With pyghidra-mcp, Ghidra becomes an intelligent backend—ready to respond to context-rich queries, automate deep reverse engineering tasks, and integrate into AI-assisted workflows.
pyghidra-mcp now supports two operating modes:
headless mode for CLI-driven analysis and automation--gui mode, which launches Ghidra through pyghidra-mcp and shares live program state with the running GUI[!NOTE] This beta project is under active development. We would love your feedback, bug reports, feature requests, and code.
Yes, the original ghidra-mcp is fantastic. But pyghidra-mcp takes a different approach:
--gui when you want live GUI navigation and edits.This project provides a Python-first experience optimized for local development, headless environments, and testable workflows.
…flowchart TD
Start["What do you need?"]
Start --> Headless["Agent or automation"]
Start --> GuiNeed["Live Ghidra GUI control"]
Start --> Terminal["Interactive terminal client"]
Headless --> Http["pyghidra-mcp
--transport streamable-http"]
GuiNeed --> GuiMode["pyghidra-mcp --gui
--transport streamable-http
--project-path project.gpr"]
Terminal --> HttpServer["Start pyghidra-mcp
--transport streamable-http"]
HttpServer --> CliMode["Run pyghidra-mcp-cli commands"]streamable-http. It keeps Ghidra and its project alive as one long-running server and works with both MCP hosts and the CLI client.pyghidra-mcp launches Ghidra, opens the project, and exposes extra tools that steer the CodeBrowser in the same JVM.pyghidra-mcp-cli is an HTTP client. Start a streamable-http server first, then issue terminal commands against that running server.Detailed architecture and tool surface
…Start a persistent Streamable HTTP server using the Python package and uv:
uvx pyghidra-mcp \
--transport streamable-http \
--project-path /absolute/path/to/ghidra-projects \
/absolute/path/to/binaryThe server is then available at http://127.0.0.1:8000/mcp. Leave it running and configure your MCP client to use that URL; the Claude Code and Codex examples below show the expected configuration.
To launch and control a live Ghidra GUI from MCP, use --gui with streamable-http:
uvx pyghidra-mcp \
--gui \
--transport streamable-http \
--host 127.0.0.1 \
--port 8000 \
--project-path /absolute/path/to/ghidra-projects \
--project-name my_project[!IMPORTANT]
--guilaunches Ghidra throughpyghidra-mcp. It does not attach to an already-running external Ghidra instance.
Or, run as a Docker container:
docker run --rm -p 8000:8000 ghcr.io/clearbluejar/pyghidra-mcppyghidra-mcp keeps the MCP surface intentionally narrow so agent clients spend fewer tokens on tool discovery and argument selection.
open_program_in_gui, list_open_programs, set_current_program, and goto are only exposed when the server is started with --gui.pyghidra-mcp-cli provides a direct command-line client over HTTP with grouped commands for common edit and analysis workflows.This keeps the default server usable for LLM agents, IDE integrations, and automation without exposing unnecessary tool surface or GUI-only controls in headless sessions.
For a more interactive command-line experience, you can use the separate pyghidra-mcp-cli package, which provides a user-friendly interface for interacting with a running pyghidra-mcp server.
Install the CLI client using uv (recommended):
uvx pyghidra-mcp-cliOr install with pip:
pip install pyghidra-mcp-clipyghidra-mcp --transport streamable-http /bin/ls# List available binaries
pyghidra-mcp-cli list binaries
# Decompile a function
pyghidra-mcp-cli decompile --binary ls main
# Decompile with callees, referenced strings, and cross-references
pyghidra-mcp-cli decompile --binary ls main --callees --strings --xrefs
# Search for symbols (supports regex patterns)
pyghidra-mcp-cli search symbols --binary ls printf -l 10[!NOTE] The CLI connects to pyghidra-mcp via HTTP to avoid the 10-60 second startup overhead of spawning a new Ghidra process for each command. See the CLI README for complete documentation.
You can create new projects in several ways, depending on your workflow:
pyghidra-mcp creates a self-contained project structure where each project has its own Ghidra project and pyghidra-mcp artifacts. This ensures complete isolation and easy project management.
# Create a new project with default settings
pyghidra-mcp
# Creates:
$ tree pyghidra_mcp_projects/
pyghidra_mcp_projects/
├── my_project.gpr
├── my_project-pyghidra-mcp
│ ├── chromadb
│ └── gzfs
└── my_project.rep# Create project with custom name and location
pyghidra-mcp --project-path ~/analysis/malware_study --project-name malware_analysis
$ tree ~/analysis/
/home/vscode/analysis/
└── malware_study
├── malware_analysis.gpr
├── malware_analysis-pyghidra-mcp
│ ├── chromadb
│ └── gzfs
└── malware_analysis.rep# Create separate projects for different analysis focuses
mkdir ~/reverse_engineering_workspace
# Project for suspicious binaries
pyghidra-mcp --project-path ~/reverse_engineering_workspace/suspicious_binaries --project-name suspicious_analysis
# Project for packed malware
pyghidra-mcp --project-path ~/reverse_engineering_workspace/packed_malware --project-name packed_analysisIf you have existing Ghidra projects (.gpr files), you can open them directly with pyghidra-mcp:
# Open existing Ghidra project (project name derived from filename)
pyghidra-mcp --project-path ~/existing/ghidra/my_research.gpr
# Result: ~/existing/ghidra/my_research-pyghidra-mcp/
# └── chromadb/, gzfs/ (pyghidra-mcp additions)Use GUI mode when you want MCP actions to operate against the same live program objects that Ghidra is displaying.
--gui requires --transport streamable-http (or --transport http as an alias)--project-path can be a project directory plus `--暂无开放 Issues,或尚未同步最近议题。