Skip to main content
Glama
SuZiXunYue

IDA Script MCP

by SuZiXunYue

execute_idapython

Destructive

Execute Python code or script files in IDA Pro to automate reverse engineering, query binary data, and return results using the full IDA API.

Instructions

Execute Python code or script file in IDA Pro context.

This tool sends Python code to the IDA Pro plugin for execution. The code runs in IDA's main thread with full access to all IDA API modules.

For long-running scripts, the tool polls for completion up to timeout seconds. If the timeout is exceeded, a task_id is returned so you can check status later using the check_task_status tool. Long scripts should poll the injected mcp_cancelled() helper so they can be stopped cooperatively via the cancel_ida_task tool.

Avoid calling ida_kernwin.ask_* and other interactive dialogs in scripts: they block IDA's main thread until answered and freeze the whole task queue.

Args: params (ExecuteScriptInput): Validated input parameters containing: - code (Optional[str]): Python code string to execute - script_path (Optional[str]): Path to Python script file - capture_output (bool): Whether to capture stdout/stderr - instance_id (Optional[str]): Target IDA instance ID (e.g., "crackme.exe" or full ID) - port (Optional[int]): Target IDA instance port (e.g., 13338) - timeout (int): Maximum wait time in seconds (default: 600)

Returns: str: JSON-formatted string containing: - result: The value of the last expression (or a local result variable), as a string or null - stdout: Captured standard output - stderr: Captured standard output (including errors) - instance: The IDA instance that executed the code - task_id: Present if script is still running or timed out

Examples: # Execute on default instance execute_idapython(code="print(idaapi.get_root_filename())")

# Execute on specific instance by database name
execute_idapython(code="len(list(idautils.Functions()))", instance_id="crackme.exe")

# Execute on specific instance by port
execute_idapython(code="idc.get_func_name(0x401000)", port=13339)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed4 schema fields changedv1.3.0
    • changedInput schema / $defs / ExecuteScriptInput / properties / port / anyOf
      Previous value: -[
      -  {
      -    "type": "integer"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]New value: +[
      +  {
      +    "maximum": 65535,
      +    "minimum": 1,
      +    "type": "integer"
      +  },
      +  {
      +    "type": "null"
      +  }
      +]
    • changedInput schema / $defs / ExecuteScriptInput / properties / timeout / description
      Previous value: -"Maximum time in seconds to wait for script execution to complete (default: 600). If the script takes longer, a task_id will be returned to check status later."New value: +"Maximum time in seconds to wait for script execution to complete (default: 600, max: 86400). If the script takes longer, a task_id will be returned to check status later."
    • addedInput schema / $defs / ExecuteScriptInput / properties / timeout / maximum
      Added value: +86400
    • addedInput schema / $defs / ExecuteScriptInput / properties / timeout / minimum
      Added value: +1
  2. First observedv1.2.0

TDQS

A4.6/5.0
Behavior5/5

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

Annotations only declare destructive/not-idempotent/not-read-only; the description goes far beyond, disclosing that code runs in IDA's main thread with full API access, that blocking dialogs freeze the entire task queue, and how timeout/cancellation behave. These are exactly the behavioral traits an agent needs before firing arbitrary code into a host process.

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-loads the core action and caveats before the Args/Returns/Examples blocks, and the examples are genuinely illustrative (default instance, by name, by port). It is on the long side and the Args/Returns text restates schema-level detail, but no sentence is filler.

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?

Given a dangerous arbitrary-code tool with a nested params object, the description covers execution context, threading implications, timeout/task_id lifecycle, cancellation helper, output shape (result/stdout/stderr/instance/task_id), and worked examples. Nothing an agent needs in order to invoke it safely is absent.

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

Parameters4/5

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

The Args section enumerates all six fields (code, script_path, capture_output, instance_id, port, timeout) with their roles, and gives concrete example call forms for instance_id and port. Much of this overlaps the schema's own descriptions, so it adds examples rather than new semantics, but it does compensate for the reported low schema description coverage.

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?

States a specific verb and resource ('Execute Python code or script file in IDA Pro context') and immediately distinguishes itself from siblings by naming check_task_status and cancel_ida_task as its follow-up companions. An agent can tell what this tool does and roughly where it sits in the workflow without opening the schema.

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?

Gives clear operational context: long-running scripts poll up to `timeout`, timeouts yield a task_id to be resolved via check_task_status, and long scripts should poll `mcp_cancelled()` for cooperative cancellation via cancel_ida_task. It also warns against interactive dialogs. What's missing is an explicit statement of when this tool is preferable to any alternative (none exists among siblings), so it stops just short of full routing guidance.

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