Pyghidra Lite

io.github.johnzfitch由 GitHub 账号 johnzfitch 发布v0.9.1更新于 Oct 24, 2026

Token-efficient Ghidra RE: decompile, xrefs, Swift/ObjC, ELF/Mach-O, async analysis

已验证STDIO仅桌面开发者工具安全与监控

概览

AI 生成的概览

基于 Ghidra 的省 token 逆向工程服务器,让助手加载、反编译、搜索和交叉引用 ELF、Mach-O 与 PE 二进制文件。

可以做什么
  • 加载与管理二进制:导入并分析文件、列出已加载二进制与任务状态、删除二进制并取消任务
  • 查看二进制概况:摘要、格式、节区与熵值,以及函数、导入、导出和类型列表
  • 读取代码:反编译、反汇编、p-code 与原始字节及文件偏移,可选控制流图
  • 追踪引用:交叉引用、调用图以及地址与函数间的值流切片
  • 搜索内容:字符串、字节模式、符号和恢复出的数据类型,可后台执行
  • 标注(可选开启):重命名函数、添加注释或设置原型,每次修改需用户确认
适用场景
适合让助手对编译后的二进制做初步分析或逆向:恶意软件初筛、理解陌生程序、比较不同构建版本之间的变化。也适合已安装 Ghidra、希望获得紧凑低 token 输出的分析人员。
运行要求
以 Python 包在本地通过 stdio 运行(pip install pyghidra-lite);使用 Claude Code 插件方式需要 PATH 中有 uv。需要 64 位 JDK 21+ 和 Ghidra 11.x 或 12.x,若未自动检测到需设置 GHIDRA_INSTALL_DIR。可选设置包括 PYGHIDRA_LITE_PROJECT_DIR、PYGHIDRA_LITE_RESTRICT_PATHS,以及 HTTP 传输用的 PYGHIDRA_LITE_AUTH_TOKEN。
安装前请注意
默认可从任意路径加载二进制,建议用 PYGHIDRA_LITE_RESTRICT_PATHS 或 --restrict-path 限制范围。annotate 工具会写入 Ghidra 项目,默认关闭,需设置 PYGHIDRA_LITE_ALLOW_WRITE 或 --allow-write;其确认依赖客户端,自动批准的客户端可自行确认,应检查审计日志。HTTP 绑定到非回环地址时必须提供 bearer token 并限制路径。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Pyghidra Lite,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

pyghidra-lite

[PyPI] [Python] [Downloads] [License]
[CI] [MCP Registry] [MCP spec] [Claude Code plugin] [Ghidra] [Platforms]

Token-efficient MCP server for Ghidra-based reverse engineering. Analyze ELF, Mach-O, and PE binaries with Swift, Objective-C, and Hermes support — decompile, disassemble, trace calls and value flow, recover data types, and map addresses back to file offsets. Runs on Linux, macOS, and Windows; ships as a Claude Code plugin with a bundled reverse-engineering skill.

Bottom line: a lean, security-first Ghidra MCP. It is read-only by default — analysis tools never mutate your binaries or the server's configuration (which is frozen for the life of the process). The one tool that writes, annotate (rename / comment / prototype), is opt-in (--allow-write) and human-confirmed: every change is approved by you through an MCP elicitation prompt before it's committed, and it fails closed if your client can't ask. You get an analyst-agent that can persist its findings — under supervision — without giving up the read-only safety story.

Quick Start

1. Prerequisites

A 64-bit JDK 21+ and Ghidra 11.x or 12.x are required (tested with Ghidra 12.1.2 and JDK 21).

bash
# macOSbrew install openjdk@21brew install ghidra
# Ubuntu/Debiansudo apt install openjdk-21-jdk# Download Ghidra from https://ghidra-sre.org
# Arch Linuxsudo pacman -S jdk21-openjdkyay -S ghidra

Ghidra installed via Homebrew (brew install ghidra) or to /opt/ghidra or ~/ghidra is found automatically. Elsewhere — including any Windows install — point GHIDRA_INSTALL_DIR at the extracted ghidra_<version>_PUBLIC folder.

2. Install — pick one

Claude Code plugin (recommended for Claude Code)
MCP server + reverse-engineering skill in one step; prompts for your Ghidra directory. Needs uv on PATH.
/plugin install pyghidra-lite --marketplace johnzfitch/pyghidra-lite
Any MCP client
Install the package, then add it to your client (Claude Code: .mcp.json in your project or ~/.claude.json; other clients: see MCP Configuration).
bash
pip install pyghidra-lite
json
{  "mcpServers": {    "pyghidra-lite": {      "command": "pyghidra-lite"    }  }}

3. Check the environment

bash
pyghidra-lite doctor   # Ghidra, JDK, decompiler, project dir, locks; exits 1 on problems

[!TIP] Plugin users without a shell install can run the same check with uvx pyghidra-lite doctor.

4. Use it

You: Analyze the binary at /path/to/binaries/app
Claude: [calls load, info, code...]

Installation

Claude Code plugin

Installs the MCP server (run with uvx, so uv must be on PATH) together with the pyghidra-lite:reverse-engineering workflow skill, and asks for your Ghidra directory, cache directory, optional path restriction and whether to allow annotate:

/plugin install pyghidra-lite --marketplace johnzfitch/pyghidra-lite
  • On Claude Code before 2.1.275, run /plugin marketplace add johnzfitch/pyghidra-lite first, then /plugin install pyghidra-lite@pyghidra-lite.
  • The plugin pins an exact package version and runs one server per session. After a plugin update, run /reload-plugins (or start a new session) to switch to it.
  • Change the settings later under /config.

[!WARNING] If you also have a manual pyghidra-lite entry in .mcp.json or ~/.claude.json, remove it — otherwise every tool appears twice.

PyPI (recommended)

bash
pip install pyghidra-lite

Arch Linux (AUR)

bash
yay -S python-pyghidra-lite

From source

bash
git clone https://github.com/johnzfitch/pyghidra-litecd pyghidra-litepip install -e .

MCP Configuration

Claude Desktop

Add to ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):

json
{  "mcpServers": {    "pyghidra-lite": {      "command": "uvx",      "args": ["pyghidra-lite"]    }  }}

uvx auto-installs pyghidra-lite from PyPI on first run. Ghidra is auto-detected; set GHIDRA_INSTALL_DIR in env if needed:

json
{  "mcpServers": {    "pyghidra-lite": {      "command": "uvx",      "args": ["pyghidra-lite"],      "env": {        "GHIDRA_INSTALL_DIR": "/path/to/ghidra"      }    }  }}

Claude Code

Create .mcp.json in your project (or ~/.claude.json for global):

json
{  "mcpServers": {    "pyghidra-lite": {      "command": "pyghidra-lite"    }  }}
Direct mode (skip proxy)

For single-session use or debugging, run the server directly:

json
{  "mcpServers": {    "pyghidra-lite": {      "command": "pyghidra-lite",      "args": ["serve"]    }  }}
With explicit Ghidra path
json
{  "mcpServers": {    "pyghidra-lite": {      "command": "pyghidra-lite",      "args": [        "serve",        "--ghidra-dir", "/path/to/ghidra"      ]    }  }}
Restrict to specific paths

By default, pyghidra-lite can load binaries from any path (the MCP client handles permissions). Use --restrict-path to lock down access:

json
{  "mcpServers": {    "pyghidra-lite": {      "command": "pyghidra-lite",      "args": [        "serve",        "--restrict-path", "/home/user/binaries",        "--restrict-path", "/opt/targets"      ]    }  }}
Shared HTTP transport (network access)

The HTTP/SSE transports are shared and apply DNS-rebinding protection (Host/Origin validation). Binding to a non-loopback address additionally requires both --restrict-path and a bearer token:

bash
pyghidra-lite serve -t streamable-http --host 0.0.0.0 \  --restrict-path /opt/targets \  --auth-token "$PYGHIDRA_LITE_AUTH_TOKEN" \  --allowed-host re.example.com:8000   # if fronted under another hostname

Clients then send Authorization: Bearer <token> on every request. Terminate TLS at a reverse proxy for remote access.

Tools (9)

pyghidra-lite provides 8 read-only analysis tools plus 1 opt-in write tool, all auto-detecting format (ELF/Mach-O/PE) and language (Swift/ObjC/Hermes):

ToolPurposeKey Parameters
loadImport and analyze binarypath, profile?, fresh?, bootstrap?, bootstrap_mode?
deleteRemove binary and cancel jobsname
binariesList binaries + job statusjobs?, rank_sources?
infoBinary overviewbinary, detail? (summary/full/format/sections/entropy)
functionsList/search functions, imports, exportsbinary, query?, type? (all/swift/objc/imports/exports/types/got/dylibs), limit?
codeDecompile, disassemble, p-code, bytesbinary, target, what? (decompile/asm/pcode/bytes/string), cfg?
xrefsReferences and call graphsbinary, target, direction?, depth?, diff?
searchFind strings, bytes, symbols, data typesbinary, query, type? (strings/symbols/bytes/all/blob/extract/types), mode?, bg?
annotate 🔒Rename / comment / set prototypebinary, target, action, name?/comment?/prototype?

🔒 annotate is the only tool that writes. It is disabled unless the server is started with --allow-write, and every change requires interactive confirmation (MCP elicitation) before it is committed — clients that can't confirm get a preview only. See Writing back.

Examples

python
# Import and analyzeload("/path/to/binary", profile="fast")
# Version-track from a prior build, including synthetic IDs for unnamed codeload("/path/to/new.bin", profile="deep", bootstrap="old.bin", bootstrap_mode="all")
# Get overview with full triageinfo("mybinary", detail="full")
# List Swift functionsfunctions("mybinary", type="swift")
# Decompile with CFGcode("mybinary", "main", cfg=True)
# Search strings in backgroundsearch("mybinary", ["password", "api_key"], bg=True)
# Get cross-referencesxrefs("mybinary", "malloc", depth=2)
# Value flow: SSA p-code, grouped by basic block; each value is defined oncecode("mybinary", "parse_header", what="pcode")# ...or just where one argument's value goes (forward slice; ~10x smaller on real code)code("mybinary", "parse_header,param_2", what="pcode")
# Raw bytes plus where they live in the file (for patching)code("mybinary", "0x4011a0,64", what="bytes")   # -> hex, ascii, file_offset, block
# Recovered struct layouts / enums / typedefssearch("mybinary", "sockaddr", type="types")

Auto-Detection

All tools automatically detect:

  • Format: ELF, Mach-O, PE
  • Language: Swift, Objective-C, Hermes/React Native
  • Runtime: Bun, Node.js, Electron, PyInstaller

Use the type and detail parameters to access format/language-specific features.

Bootstrap Modes

  • bootstrap_mode="named": transfer only meaningful source names (default).
  • bootstrap_mode="all": also assign stable synthetic labels to source FUN_* functions during transfer, which is useful for large version-to-version bootstrap workflows where uniqueness matters more than semantics.

Writing back

By default pyghidra-lite is read-only — no tool mutates your binaries. To let an agent persist findings (rename a function, attach a comment, fix a prototype), start the server with --allow-write:

bash
pyghidra-lite serve --allow-write          # or PYGHIDRA_LITE_ALLOW_WRITE=1

Then the annotate tool becomes usable:

python
annotate("mybinary", target="FUN_00401000", action="rename", name="parse_header")annotate("mybinary", target="parse_header", action="comment", comment="validates the v2 header")annotate("mybinary", target="parse_header", action="prototype", prototype="int parse_header(char *buf, int len)")

Every call is human-confirmed: the server sends an MCP elicitation prompt showing the exact old -> new change, and only commits if you accept. If the server was started without --allow-write, the tool refuses; if your MCP client doesn't support elicitation, the tool returns a preview with applied: false and writes nothing (fail closed). Confirmed changes are written in a single Ghidra transaction and saved to the on-disk project.

Audit journal. Because MCP elicitation ultimately trusts the client (an autonomous "auto-approve" client can self-confirm), every write is recorded in annotate_audit.jsonl next to the projects — and every declined or failed attempt is logged too. Each line records old -> new, so the journal is both an accountability trail and an undo log; a flood of entries is your signal that an auto-agent is churning, and the server also nudges (ctx.warning) as write volume climbs. The journal is fail-closed and hardened: a write is recorded before it's applied (if it can't be journaled, it isn't committed), the file is created 0o600 and opened with O_NOFOLLOW (a symlinked journal is refused), and it rotates by size so it can't grow without bound.

Analysis Profiles

ProfileUse Case
fastQuick triage, disables 20 slow analyzers (default)
defaultBalanced, full Ghidra analysis
deepThorough analysis for obfuscated code

The server defaults to fast to stay within MCP timeout limits. Use load(fresh=True) to run deeper analysis when needed:

python
# Default import uses fast profileload("/path/to/binary")
# Re-analyze with deep profileload("/path/to/binary", profile="deep", fresh=True)

Token Efficiency

pyghidra-lite is designed for minimal token usage:

  • Compact JSON - results are serialized without indentation, one text block per call (measured: 33% fewer characters than pretty-printed output across all tools on a sample binary)
  • No empty fields - false flags, empty tag lists and null context are omitted
  • Slices, not dumps - code("func,var", what="pcode") returns only the ops a value flows into (on ws2_32.dll WSAStartup: ~1.9K characters vs ~22K for the full listing)
  • Compact output by default - functions(binary, type="all") returns minimal {name, addr} pairs
  • Opt-in detail - use info(detail="full"), code(cfg=True), or richer type/what modes only when needed
  • Progress reporting - large imports report progress every 10% or 60s
  • Truncated strings - long strings capped at 500 chars

Architecture

By default, pyghidra-lite runs as a lightweight stdio proxy (~10MB) that forwards to a persistent shared HTTP backend (~500MB JVM). Multiple sessions share a single JVM instead of each spawning their own.

Claude Code session 1 ──stdio──> proxy ──┐Claude Code session 2 ──stdio──> proxy ──┼──HTTP──> shared backend (1 JVM)Claude Code session 3 ──stdio──> proxy ──┘        localhost:19101

The proxy auto-starts the backend on first use, and a file lock plus a port check stop concurrent proxies from spawning duplicates. The backend keeps running until pyghidra-lite stop; binaries idle for 30 minutes are unloaded from memory (the 2 most recent stay loaded) and reload transparently from disk.

[!IMPORTANT] The proxy reuses whatever backend is already listening, whatever its version. After upgrading pyghidra-lite, run pyghidra-lite stop so the next session starts the new code. (serve and the Claude Code plugin run one server per session and don't have this issue.)

CommandWhat it does
pyghidra-liteStdio proxy (default) -- auto-starts backend
pyghidra-lite serveDirect stdio server (1 JVM per session)
pyghidra-lite serve -t streamable-httpStart persistent HTTP backend manually
pyghidra-lite stopStop the shared backend
pyghidra-lite doctor [--json]Diagnose the environment (read-only; exit 1 if analysis would fail)

Set PYGHIDRA_LITE_NO_AUTOSTART=1 to disable auto-start (useful with systemd).

Configuration

Every setting is a serve flag or an environment variable (handy in an MCP env block):

VariableFlagDefaultPurpose
GHIDRA_INSTALL_DIR--ghidra-dirauto-detectGhidra installation
PYGHIDRA_LITE_PROJECT_DIR--project-dirsee belowAnalysis cache
PYGHIDRA_LITE_RESTRICT_PATHS--restrict-path (repeatable)unrestrictedOnly load binaries under these dirs (env: OS path separator)
PYGHIDRA_LITE_ALLOW_WRITE--allow-writeoffEnable annotate (still human-confirmed)
PYGHIDRA_LITE_DEFAULT_PROFILE--profilefastDefault analysis profile
PYGHIDRA_LITE_TOOL_TIMEOUT—300 secondsPer-call budget so a wedged JVM call can't hang the client; 0 disables
PYGHIDRA_LITE_AUTH_TOKEN--auth-tokennoneBearer token for HTTP transports (required off-loopback)
PYGHIDRA_LITE_NO_AUTOSTART—offProxy never spawns a backend
—--evict-after / --min-loaded30 min / 2Memory eviction of idle binaries
—--autopurge-daysoffDelete projects not opened in N days

Multi-Agent Support

Each binary gets its own Ghidra project, enabling:

  • Parallel analysis of different binaries
  • Shared results across agents
  • Persistent analysis (survives restarts)
  • Content-addressed storage (same binary = same analysis)

Projects are stored in ~/pyghidra-lite/projects/ (Windows: %LOCALAPPDATA%\pyghidra-lite\projects\), or in the pre-0.8 location ~/.local/share/pyghidra-lite/projects/ if that already exists. Override with --project-dir or PYGHIDRA_LITE_PROJECT_DIR. Ghidra 12+ rejects project paths with a component starting with ., so a legacy ~/.local directory only works with Ghidra 11.x — pyghidra-lite doctor flags this.

Links

License

MIT

来源:README.md,提交 b0fc4c4

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

2
  1. v0.9.1最新Oct 10, 2026
  2. v0.7.0Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分