Skip to main content
Glama

Evaluate Python in the worker (REPL)

py_eval

Execute Python code within IDA to automate reverse engineering tasks, with persistent locals and result capture.

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, and the helpers mcp_time_left() / mcp_deadline_exceeded() are injected into the snippet namespace. Poll them inside long loops so the main thread bails out cleanly instead of freezing every other MCP call (including server_health) behind a non-polling C++ call.

Input Schema

TableJSON 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

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
stderrYes
stdoutYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv20261008.0.1

TDQS

A3.7/5.0
Behavior4/5

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

With no annotations, the description carries the full burden and does so capably: it discloses the Jupyter-style locals persistence, that globals are rebuilt per call, the 300s ceiling, the injected mcp_time_left()/mcp_deadline_exceeded() helpers, and the concrete consequence of not polling (freezing other MCP calls including server_health). This is genuinely useful context beyond the schema. It stops short of describing error/exception behavior and any safety or permission implications.

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?

Front-loaded with the core purpose, then cleanly sectioned into persistence, return-value, and timeout guidance with labeled paragraphs. Every section earns its place, though the prose is slightly padded (e.g., restating the locals rule twice).

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?

An output schema exists, so return format need not be explained, and the description covers the two things an agent most needs to know: namespace persistence and timeout/polling behavior. Completeness would be higher if it routed against the sibling Python tools.

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 description coverage is 100%, so baseline is 3. The description's explanation of new_locals duplicates the schema's own description almost verbatim rather than adding new meaning, and instance_id is not addressed in prose at all.

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?

States a specific verb and resource: 'Execute Python in IDA context and return result/stdout/stderr.' The title reinforces this as a REPL-style evaluator. However, it does not distinguish itself from the two near-identical siblings execute_python and py_exec_file, leaving the agent to guess which of the three to call.

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

Usage Guidelines3/5

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

The description gives strong operating context (persistence model, timeout/polling guidance for long loops) which implies usage, but it never states when to choose py_eval over execute_python or py_exec_file. With three overlapping Python-execution siblings, routing guidance is the key missing piece.

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