Evaluate Python in the worker (REPL)
py_evalExecute 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
| 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 |