Skip to main content
Glama

Evaluate Python in the worker (REPL)

py_eval

Execute Python code in IDA's context to automate reverse engineering tasks and inspect binaries, with persistent locals for iterative analysis.

Instructions

Execute Python in IDA context and return result/stdout/stderr.

Locals persistence (Jupyter-style): the locals namespace persists across calls by default, so variables, imports, and definitions from previous calls stay visible. Pass new_locals=True to reset the stored namespace and start fresh.

Note: the globals namespace (IDA modules and helpers) is always rebuilt per call; only locals persist. Jupyter-style last-expression return: if the code ends with an expression, its value is returned in "result".

Timeouts for long snippets: this tool runs with a 300s ceiling enforced by the nexus side — a snippet that blocks past it is cancelled there (the worker's main-thread pump cannot be interrupted from inside Python, so no pollable deadline helpers are provided).

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "code": "<code>"
    },
    "name": "py_eval"
  }
}

Input Schema

NameRequiredDescriptionDefault
codeYesPython code
new_localsNoFalse (default): reuse the locals namespace from previous py_eval calls, so variables assigned earlier remain visible (Jupyter-like persistence). True: reset and start with a fresh locals namespace.
instance_idNoOptional database instance id. If omitted, use the current target.

Output Schema

NameRequiredDescriptionDefault
resultYes
stderrYes
stdoutYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv20261008.0.1

TDQS

A3.5/5.0
Behavior4/5

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

With no annotations provided, the description does substantial work: it discloses locals persistence across calls, that globals are rebuilt per call, last-expression return behavior, and the 300s nexus-side timeout with cancellation semantics. It does not explicitly warn about arbitrary-code side effects or database mutation risk, which keeps it from a 5.

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

Conciseness4/5

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

The description is front-loaded with the core action and organized into clear notes about persistence, globals, return behavior, and timeouts. It is somewhat verbose and repeats the new_locals semantics already covered by the schema, but every section remains useful.

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

Completeness4/5

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

For a complex code-execution tool with rich schema and output schema, the description covers the key non-schema behaviors: persistence, globals rebuild, last-expression return, and timeout/cancellation. It is incomplete only in not differentiating from sibling execution tools and not stating side-effect or safety implications.

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

Parameters3/5

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

Schema coverage is 100%, so all parameters are already documented structurally. The description elaborates on new_locals persistence in narrative form but adds little beyond the schema and does not mention instance_id, so the baseline 3 is appropriate.

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

Purpose4/5

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

The description clearly states a specific action and context: execute Python in IDA and return result/stdout/stderr. It is not a tautology, but it does not distinguish this tool from the sibling execute_python, so the agent cannot tell from the description alone when this REPL-style tool is preferred.

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

Usage Guidelines2/5

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

The description explains how locals persistence works and how to reset it, but it gives no explicit guidance on when to use py_eval versus alternatives such as execute_python or py_exec_file. Usage is only implied by the Jupyter-style persistence note.

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