Skip to main content
Glama

IDA ↔ DSH deep integration

中文说明

Give an AI agent real, scriptable control of IDA Pro 9.x: headless analysis through idalib, or a live session through a bridge plugin inside the GUI. The same analysis core and the same 36 tools work through either path.

Layout

dsh_ida/
  api.py       analysis core — IDAPython only, runs inside an IDA kernel
  worker.py    headless kernel in a child process (imports idapro; owns the IDB)
  client.py    transports: worker subprocess or TCP to the GUI bridge
  server.py    MCP server, newline-delimited JSON-RPC over stdio, zero deps
  cli.py       dsh-ida probe|call|selftest|install-plugin
plugin/
  dsh_ida_bridge.py   IDA GUI plugin — TCP bridge, executes on IDA's main thread
cordis.patch.yml      registers the MCP server in a DSH profile
tests/mcp_probe.py    scripted MCP client; full tool-surface verification

The kernel lives in a child process so a crash, a bad loader or a long analysis never takes the MCP server down. Calls are sequential (idalib is single-threaded); ida_open accepts timeout_s for large databases such as libUE4.so.

Related MCP server: IDA Pro MCP Server

Install

Prerequisites: IDA Pro 9.0+ (must have been licensed once), Python 3.9+, and idapro installed from your IDA directory:

pip install "C:\Program Files\IDA\idalib\python\idapro-*.whl"
python "C:\Program Files\IDA\idalib\python\py-activate-idalib.py" -d "C:\Program Files\IDA"
pip install -e .
python -m dsh_ida.cli install-plugin     # copies the bridge into IDA's user plugins dir

Then add this checkout to your DSH profile's package.json:

"dependencies": { "@local/ida-mcp": "link:C:/Users/x/Desktop/IDA-agent" },
"dsh": { "profile": { "bundles": [ "...", "@local/ida-mcp" ] } }

and run pnpm install in the profile. Restart DSH to load the new tools. The MCP server name is ida, so tools appear as ida_status, ida_decompile, etc.

Two ways in

Headless (default). No GUI needed. The server picks this automatically when no bridge is listening:

ida_open(path, analyze=true, timeout_s=900) → ida_status → ida_functions →
ida_decompile / ida_string_refs / ida_search_bytes / ida_xrefs_to ...

Live GUI. Load dsh_ida_bridge.py as an IDA plugin (Alt-F7 or place it in the user plugins dir). It listens on 127.0.0.1:13371; the MCP server prefers it when present, so the agent and the human look at the same database. ida_gui_state reads the cursor position and ida_gui_jump / ida_gui_mark move the view and highlight findings for the analyst. open/close stay headless-only — in GUI mode you open the database in IDA itself.

Set DSH_IDA_BACKEND=idalib or gui to force one, DSH_IDA_GUI_PORT to change the port, and DSH_IDA_TIMEOUT for the default per-call timeout.

Tools (36)

Group

Tools

Database

ida_status, ida_open, ida_close, ida_save

Navigate

ida_segments, ida_functions, ida_function, ida_disasm, ida_decompile, ida_read_bytes

Cross-refs

ida_xrefs_to, ida_xrefs_from, ida_call_graph

Find things

ida_strings, ida_string_refs, ida_names, ida_imports, ida_entries, ida_search_bytes, ida_search_text, ida_search_immediate

Cheat workflow

ida_sig, ida_sig_verify, ida_lua_bindings, ida_import_sdk

Types

ida_structs, ida_struct, ida_enums

Write

ida_rename, ida_comment, ida_set_type, ida_patch_bytes

GUI

ida_gui_state, ida_gui_jump, ida_gui_mark

Escape hatch

ida_exec — arbitrary IDAPython with captured stdout

ida_string_refs is the offset-hunting workhorse: give it a string fragment and it returns the addresses and functions that reference it.

Cheat workflow

The four tools that turn analysis into shippable offsets:

ida_sig builds the shortest unique AOB signature for a function. It walks the instructions and wildcards exactly the operands that move when the game is rebuilt — call/jump targets, RIP-relative globals, absolute immediates, true imm64 — while keeping opcodes, stack sizes and struct offsets ([rsi+0xC8] stays literal, because a field offset is what you want to pin). It never reads past end_ea, so alignment padding and the next function's prologue are not part of the pattern, and it grows the pattern until it matches once.

ida_sig_verify runs a saved signature against the open database. That is the update loop: dump sigs from the old build, open the new libUE4.so, verify, and every offset that broke is reported with its hit count before it ships.

ida_lua_bindings recovers luaL_Reg tables — {name, lua_CFunction} arrays terminated by {NULL, NULL}. Games built on Lua inside UE4 (BGMI, PUBG Mobile) register their whole scripting surface this way, so this maps a name from a Lua dump straight onto the native implementation address.

ida_import_sdk parses a Dumper-7 (or any) C++ header into the local type library. Dumper-7 writes real offsets as char pad_XXXX[0x10] members, so the structs land byte-exact and field names appear in the decompiler as soon as a pointer is retyped.

Verification

python tests/mcp_probe.py                       # protocol: 5 checks
python tests/mcp_probe.py <binary>              # full surface: 35 checks
python tests/gui_probe.py                       # live GUI bridge: 14 checks
python tests/cheat_probe.py                     # sig + lua + sdk: 12 checks
python -m dsh_ida.cli selftest <binary>         # open + analyse + decompile

Headless, on IDA Pro 9.5.261026 with repak.exe (9,138 functions, Hex-Rays available): 35 passed, 0 failed — decompilation, masked AOB search, immediate search, string xrefs, writes, save, and clean errors for bad addresses and for GUI-only tools.

tests/cheat_probe.py runs against tests/fixtures/lua_reg_sample.exe, a real PE built from the .c beside it with two genuine luaL_Reg tables: 12 passed, 0 failed — both tables recovered with all 8 names and their addresses, a 24-byte signature that is unique and stable across runs, and a Dumper-7 header imported with UObject at 0x30 and AActor.RootComponent at 0x38.

Rebuild survival was checked separately: the fixture was recompiled with an extra function inserted ahead of l_teleport so every address shifted. The 26-byte signature taken from the first build matched exactly once in the second, at the new address.

Live GUI, with ida.exe open on a 9,956-function binary: 14 passed, 0 failed — gui_state reports IDA View-A / BWN_DISASM, gui_jump moves the cursor, gui_mark colours the line, and open/close are refused with a clear message instead of touching the open database.

gui_state's widget fields depend on IDA having keyboard focus; from a background shell they can come back empty while screen_ea stays correct.

Host notes (this machine)

  • IDA 9.5 needed HKCU\Software\Hex-Rays\IDA\EULA 95 as REG_DWORD 1 before idalib would run batch analysis; REG_SZ values are ignored. That acceptance is now set on this host.

  • The GUI was dying on startup with "Errors while processing idagui.cfg" then a fatal "MENUS_LAYOUT directive ... missing or wrong format". This install was an in-place upgrade from 9.3, so cfg\ had no idagui.cfg at all — IDA cannot synthesise one on first run and quits. Restoring the 9.3 file as cfg\idagui.cfg (kept as idagui.cfg.ida93.bak) makes 9.5 start cleanly with no dialog; the old layout is accepted as-is. If the GUI ever stops starting again, that file is the first thing to check.

  • The GUI only loads Python plugins once idapyswitch has a target: it points at Python314\python314.dll here. Without that, .py plugins are skipped silently. plugin/dsh_ida_bridge.py logs every step to %TEMP%\dsh_ida_bridge.log (override with DSH_IDA_LOG) — check it first if the bridge is not listening.

  • The plugin is copied, not linked: re-run python -m dsh_ida.cli install-plugin after editing it, and restart IDA.

  • IDA 9.5 API differences handled here: open_database returns 0 on success; structs/enums are enumerated through numbered tinfo_t types rather than ida_typeinf.get_struc_qty; bin_search takes a compiled pattern vector with 4 arguments; find_imm returns (ea, operand); parse_binpat_str returns an empty string on success, so the vector size is checked instead; there is no get_widget_type_name (the BWN_* constants are mapped back manually) and set_item_color lives in ida_nalt, not ida_bytes.

MIT licensed. No IDA binaries, licence material or credentials are included.

Available Tools

36 tools
ida_call_graphB

Breadth-first call graph around a function, capped at 400 nodes. direction=down (callees), up (callers) or both.

Inputs: target (required), depth, direction.

ida_closeA

Headless only. Close the current database, optionally saving the IDB first.

Inputs: save.

ida_commentB

Set a comment at an address. repeatable=true writes a repeatable comment that follows xrefs.

Inputs: text (required), target (required), repeatable.

ida_decompileB

Hex-Rays pseudocode for the function containing the address. This is the main tool for understanding game logic.

Inputs: target (required).

ida_disasmC

Linear disassembly from an address, one item per line, with resolved names and comments.

Inputs: target (required), skip, count.

ida_entriesC

Entry points / exports with ordinal, address and name.

Inputs: no named parameters.

ida_enumsC

Declared enums with their underlying size.

Inputs: limit.

ida_execA

Escape hatch: run arbitrary IDAPython inside the kernel and return captured stdout plus a 'result' variable if the script sets one. Use when no dedicated tool fits.

Inputs: code (required).

ida_functionA

Everything about one function: bounds, prototype, basic-block count, and up to 40 callers and callees.

Inputs: target (required).

ida_functionsB

Paginated function list with address, name, size and library/thunk flags. Filter by substring, restrict to or exclude library functions.

Inputs: limit, filter, offset, library.

ida_gui_jumpA

Live GUI only: navigate the open IDA window to an address so the analyst sees what the agent is looking at.

Inputs: target (required).

ida_gui_markB

Live GUI only: colour an address in the listing to flag a finding for the analyst.

Inputs: target (required), size, color.

ida_gui_stateA

Live GUI only: the address the analyst's cursor is on, the function it belongs to, the active widget title and any selection.

Inputs: no named parameters.

ida_importsB

Imported functions grouped by module, with the IAT address of each.

Inputs: no named parameters.

ida_import_sdkA

Parse a C/C++ header (Dumper-7 or any SDK dump) into the local type library so structs, field names and offsets appear in the decompiler. Returns the error count and how many types were added.

Inputs: path (required).

ida_lua_bindingsB

Recover luaL_Reg tables — every native function registered into the Lua VM, as {name, address, function} rows. Use it to go from a Lua dump name straight to the C++ implementation.

Inputs: limit, max_bytes, min_entries.

ida_namesB

The name list: every symbol with its address. Filter by substring to find a class, field or function by name.

Inputs: limit, filter, offset.

ida_openA

Headless only. Open a binary (or existing .i64/.idb) and run auto-analysis. Returns the resulting database status. Analysis of a large libUE4.so can take many minutes; raise timeout_s for those.

Inputs: path (required), analyze, timeout_s.

ida_patch_bytesB

Patch bytes at an address (hex string). Affects the database, not the original file unless applied to input.

Inputs: target (required), hex_bytes (required).

ida_read_bytesC

Raw bytes at an address as hex plus printable ASCII.

Inputs: target (required), size.

ida_renameA

Rename an address (function, global, field). Writes to the database; call ida_save to persist.

Inputs: name (required), target (required).

ida_saveA

Write the current database to disk (keeps renames, comments, types and patches).

Inputs: no named parameters.

ida_search_bytesA

Masked byte-pattern search over the database. '??' matches any byte: '48 8B ?? 89', 'E8 ? ? ? ?' for calls. Returns addresses plus the containing function.

Inputs: pattern (required), end, limit, start.

ida_search_immediateB

Find instructions whose immediate operand equals a constant — useful for magic numbers, struct offsets and enum values.

Inputs: value (required), limit.

ida_search_textC

Search string literals by substring (case-insensitive).

Inputs: text (required), limit.

ida_segmentsA

Memory map: every segment with name, class, start/end, size, permissions and bitness.

Inputs: no named parameters.

ida_set_typeB

Apply a C declaration at an address — a function prototype or a data type, e.g. 'int __fastcall f(void *self, int idx)'.

Inputs: target (required), declaration (required).

ida_sigA

Build the shortest unique AOB signature for a function: grows the pattern until it matches once, wildcarding call targets, RIP-relative displacements and absolute immediates so the sig survives a game update. Start here when you need a stable offset.

Inputs: target (required), length, max_length.

ida_sig_verifyB

Test a saved signature against the currently open database — the post-update binary. Reports how many times it matches and where, so a broken offset is caught before it ships.

Inputs: pattern (required), limit.

ida_statusA

State of the loaded IDA database: backend (headless idalib or live GUI), input file, processor, bitness, imagebase, function/segment/entry counts, whether Hex-Rays is available.

Inputs: no named parameters.

ida_string_refsA

Strings matching a filter plus the code that references them. The fastest way to go from a known string ('Killed by', '/Game/', 'AntiCheat') to the functions and offsets behind it.

Inputs: filter (required), limit.

ida_stringsB

String literals in the database, paginated, with address, length and value. Filter by substring.

Inputs: limit, filter, offset, min_length.

ida_structC

One struct's full member layout: offset, name and size per field.

Inputs: name (required).

ida_structsC

Declared structs with size and member count.

Inputs: limit.

ida_xrefs_fromB

Every reference made from an address (what it calls, reads, writes or points at).

Inputs: target (required), limit.

ida_xrefs_toC

Every reference to an address (who calls, reads, writes or points at it).

Inputs: target (required), limit.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.2/5.0

    Scored across 36 tools

    Disambiguation4/5

    Most tools have a clear resource+action identity: read_bytes vs patch_bytes vs disasm, xrefs_to vs xrefs_from, structs vs struct, GUI vs headless operations are all distinguishable. A few boundaries blur: ida_strings vs ida_search_text both do substring string lookup, ida_names vs ida_functions both enumerate symbols by name filter, and ida_sig_verify vs ida_search_bytes both test byte patterns, so an agent could pick the wrong one without reading closely.

    Naming Consistency4/5

    A uniform ida_ prefix makes the toolset easy to scan, and most names are verb_noun or clear single nouns. The convention is mixed, though: verbs (ida_open, ida_close, ida_save, ida_rename), verb_noun (ida_read_bytes, ida_set_type, ida_search_bytes), and bare plurals (ida_segments, ida_strings, ida_names, ida_structs, ida_enums) coexist, and ida_sig vs ida_sig_verify breaks the pattern of the rest.

    Tool Count3/5

    Reverse engineering is a genuinely broad domain, and most of the 36 tools map to distinct IDA capabilities, but 36 is on the heavy side and a few could be consolidated (strings/search_text, names/functions, sig_verify/search_bytes). The three GUI-only tools and the headless-only open/close split also add surface that many agents will never use in a given session.

    Completeness5/5

    The surface covers the full workflow: open/close/save/status, memory map, function listing and detail, disassembly, decompilation, xrefs both ways, strings, imports, entries, structs, enums, multiple search modes, renaming, typing, commenting and patching. Gap areas (creating/deleting structs and enums, undefining functions, instruction-level edits) are explicitly covered by the ida_exec escape hatch and ida_set_type/ida_import_sdk.

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      A
      maintenance
      Enables AI assistants to interact with IDA Pro for reverse engineering and binary analysis, including executing Python scripts, extracting strings/imports/exports/functions, searching immediate values/text/byte sequences, and retrieving disassembly.
      -
    • F
      license
      Not graded
      quality
      A
      maintenance
      Enables AI assistants to interact with IDA Pro for reverse engineering and binary analysis, including executing Python scripts, retrieving strings, imports, exports, and functions, searching values, text, and byte sequences, and getting disassembly for address ranges.
      -
    • F
      license
      Not graded
      quality
      A
      maintenance
      Enables AI assistants to interact with IDA Pro for reverse engineering and binary analysis, including executing Python scripts, retrieving strings, imports, exports, and functions, searching immediate values, text, and byte sequences, and getting disassembly.
      -
    • F
      license
      Not graded
      quality
      A
      maintenance
      Enables AI assistants to interact with IDA Pro for reverse engineering and binary analysis, including executing Python scripts, retrieving strings/imports/exports/functions, searching immediates/text/byte sequences, and getting disassembly.
      -