Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

pyghidra-scripting

БесплатноБез исполняемых скриптовНе проверен

Write and run Python (PyGhidra) code inside the Ghidra session that ReVa's MCP server is already attached to, using the five ReVa scripting tools…

cyberkaidaот cyberkaida★ 988 звёзд на GitHub

Об этом скилле

PyGhidra scripting via ReVa

ReVa exposes five MCP tools under the scripts provider that let an assistant write, edit, run, and inspect Python scripts inside the same Ghidra session ReVa is serving. The Python code runs under PyGhidra (CPython 3 + JPype), so it has the full Ghidra Java API available — the FlatProgramAPI, DecompInterface, FunctionManager, everything.

This skill teaches when to reach for these tools, how to structure the Python you send to run-script, and the pitfalls that bite in practice.

The five tools at a glance

Tool Purpose Use when
run-script Execute Python against a program. Inline code, or by scriptPath / scriptName. The dedicated ReVa MCP tools don't cover what you need, or you want one tight pass over the program.
list-scripts Enumerate scripts across registered directories. Filterable by name/path; paginated. Discovering what's already saved before writing a new one.
read-script cat -n view of a script with offset / limit and a truncated flag. Reading an existing script before editing it. The numbered output is what edit-script lines up against.
write-script Create a new .py file (or full overwrite with overwrite: true). User-writeable dirs only. Saving a reusable script. Never reach for this just to bundle inline code — use run-script with code for one-shot use.
edit-script old_string → new_string replacement. Errors if old_string matches multiple places unless replace_all: true. Iterating on an existing script. Pair with read-script to see line context first.

Reach-for-it triggers

run-script is the escape hatch. Use it when:

  • You need to run a custom predicate over every function/symbol/instruction and the existing list/find tools don't filter the right way.
  • You need to combine multiple Ghidra API calls into one operation that would otherwise take many MCP round-trips.
  • You want to use a Ghidra API ReVa doesn't expose — e.g. DecompInterface low-level features, PCode analysis, custom AddressSet arithmetic, the data flow API directly, BinaryReader, etc.
  • You're prototyping; once it works and is reusable, save it with write-script.

Don't use run-script when a dedicated ReVa MCP tool already does the job — those tools have stable schemas and structured output that's easier to reason about than free-form stdout. The decompiler / functions / strings / symbols / xrefs tools cover the common path.

Runtime gate: PyGhidra-only

run-script only works when Ghidra was launched under PyGhidra:

  • ✅ mcp-reva (Claude CLI / stdio mode)
  • ✅ pyghidra-gui (GUI mode launched with PyGhidra)
  • ✅ reva_headless_server.py (headless mode via PyGhidra)
  • ❌ Plain ghidraRun — PyGhidra is not wired in; you'll get a PyGhidraNotAvailableException error response with launch guidance.

If a run-script call comes back with that error, the right move is to tell the user how to relaunch (don't keep retrying). The other four tools (list-scripts, read-script, write-script, edit-script) work in every mode because they're plain file operations.

The execution contract for run-script

This is the contract your inline code (or saved script) runs under. Internalise it — most failures come from getting one of these wrong.

Pre-bound globals. The script runs as a Ghidra PyGhidra script, so the standard GhidraScript globals are already defined: currentProgram, currentAddress, currentSelection, currentHighlight, monitor, state, plus FlatProgramAPI helpers like toAddr, getFunctionAt, getFunctionContaining, getSymbolAt, getInstructionAt, getDataAt, getReferencesTo, getReferencesFrom, createLabel, setEOLComment, find, findBytes, clearListing. You do not need to import or set these up. currentProgram is the program identified by the programPath argument.

One transaction per run. ReVa wraps every run-script call in a single parent transaction, so you do not need to open one: any mutation (rename, retype, comment, label, create function, etc.) applies directly, and a clean run commits every change as one undo entry in Ghidra's history. The run is all-or-nothing:

  • a clean exit commits — one undo step covers everything the script did;
  • a Python exception or a timeout (timedOut: true) rolls every change back;
  • a script that opens its own transaction and ends it with commit=False aborts the whole run too: nothing sticks, and the result says so (success: false, transaction: "rolled back").

Scripts written for older ReVa builds that open their own transaction still work: those entries join the same unit, so nothing is committed until the run itself succeeds, and one endTransaction(tx, False) anywhere rolls the entire run back. Never leave an entry open — ReVa closes it after the run and reports transactionLeaked: true, and its changes then follow the run's outcome.

Read-o

Полный SKILL.md на GitHub

Установить pyghidra-scripting в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

references/decompiler-pcode.mdreferences/flat-api.mdreferences/jpype-interop.mdreferences/persistent-scripts.mdreferences/recipes.md

FAQ

Что делает скилл pyghidra-scripting?

Write and run Python (PyGhidra) code inside the Ghidra session that ReVa's MCP server is already attached to, using the five ReVa scripting tools — `run-script`, `list-scripts`, `read-script`, `write-script`, `edit-script`. Use this whenever the user asks to execute Python against the current program, reach for the Ghidra Flat API directly, write a custom analysis pass, automate something the other ReVa tools don't expose, or persist a `.py` script in Ghidra's scripts directory. Also use when an existing ReVa MCP tool can't do what's needed and the right answer is "drop into PyGhidra for one call." Do NOT use this skill for plain ReVa tool calls that already have a dedicated MCP tool (use that tool instead); do NOT use it to build standalone Python programs that run pyghidra in their own process (the run-script tool runs *inside* the ReVa-hosted Ghidra).

Как установить скилл pyghidra-scripting?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл pyghidra-scripting запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить pyghidra-scripting с