Evaluate Python in the worker (REPL)
py_evalExecute 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
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | Python code | |
| new_locals | No | False (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_id | No | Optional database instance id. If omitted, use the current target. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes | ||
| stderr | Yes | ||
| stdout | Yes |