Skip to main content
Glama
I-CAN-hack
by I-CAN-hack

execute

Run Python scripts in Ghidra's PyGhidra environment to analyze or modify programs, with full API access and captured output.

Instructions

Execute a Python snippet in Ghidra's scripting environment.

The snippet runs inside Ghidra with full access to the Ghidra API via
PyGhidra.

Available variables:
- currentProgram: exactly one program, selected via the required
  `program` argument
- flat: FlatProgramAPI-compatible script object
- toAddr(value): convert an address, function, symbol, or exact
  function/label name to an Address
- Helpers: getBytes, getDataAt, getFunctionAt, getFunctionContaining,
  getInstructionAt, getReferencesTo, getReferencesFrom
- state, monitor: Ghidra script state and task monitor

All Ghidra Java classes can be imported, e.g.:
  from ghidra.program.model.symbol import SymbolType
  from ghidra.app.decompiler import DecompInterface

Modifications are auto-wrapped in a transaction.
Use print() to return output.

The response includes:
- output: stdout captured from the snippet
- stderr: stderr captured from the snippet
- error: traceback string if execution failed

Program selection is based on the current Ghidra project name/path, not
the original imported filename. Use `get_programs()` to discover available
open programs.

Args:
    code: Python code to execute in Ghidra.
    program: Required Ghidra project path or name to target.
    timeout: Bridge execution timeout in seconds.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYes
programYes
timeoutNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.2.0

TDQS

A4.8/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full behavioral burden and succeeds: it discloses full API access, auto-wrapping of modifications in a transaction, captured stdout/stderr, traceback error reporting, and a timeout mechanism. It also clarifies how program targets are resolved, which is a meaningful behavioral nuance.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is long but efficiently organized with clear sections, bulleted variables, import examples, output details, and an Args list. Every sentence earns its place; no filler or redundant restatement of the schema exists.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a flexible code-execution tool, the description covers everything an agent needs: available predefined variables, import mechanics, transaction behavior, output capture, error reporting, and program name resolution. The output schema is also explained by naming the response fields, so the agent can reliably invoke and interpret results.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate, and it does. It documents all three parameters in an Args section: code, program (including the caveat that it is a project path/name rather than the original imported filename), and timeout. It also enriches the program parameter with guidance to use get_programs() for discovery.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a specific statement: 'Execute a Python snippet in Ghidra's scripting environment.' It names the verb, resource, and mechanism, and clearly distinguishes this general-purpose execution tool from the other data-specific sibling tools like decompile, read_data, or rename.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description gives concrete context on how to use the tool: run arbitrary Python with Ghidra API access, use print() for output, and expect response fields for stdout/stderr/error. It also warns about program selection being based on project path/name and points to get_programs() for discovery. It does not explicitly contrast against sibling tools, but the arbitrary-execution use case is clear enough.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.