37 lines
1.4 KiB
Python
37 lines
1.4 KiB
Python
"""IDA startup script (-S) that boots the ida-pro-mcp HTTP server headless.
|
|
|
|
Launched via:
|
|
idat.exe -A -S"idat_mcp_serve.py" <target>
|
|
|
|
-A = autonomous/batch (no dialogs). This script starts the MCP plugin's
|
|
HTTP JSON-RPC server on 127.0.0.1:13337 and keeps the idat process alive so the
|
|
already-wired `xd://mcp__ida_pro_mcp_*` tools can drive analysis. idat runs the
|
|
startup script after initial auto-analysis of the input DB.
|
|
"""
|
|
import idaapi
|
|
import ida_auto
|
|
import ida_loader
|
|
|
|
# Ensure auto-analysis has settled before serving requests.
|
|
ida_auto.auto_wait()
|
|
|
|
# Load and start the MCP plugin server.
|
|
# The plugin file registers PLUGIN_ENTRY()->MCP(); run(0) starts the HTTP server.
|
|
_plugin_path = idaapi.idadir("plugins") # noqa: F841 (informational)
|
|
mod = ida_loader.load_plugin("mcp-plugin.py")
|
|
if mod:
|
|
ok = ida_loader.run_plugin(mod, 0)
|
|
print(f"[idat-mcp] run_plugin -> {ok}")
|
|
else:
|
|
# Fallback: import the plugin module directly and start its Server.
|
|
import importlib.util, os
|
|
pp = os.path.join(idaapi.get_user_idadir(), "plugins", "mcp-plugin.py")
|
|
spec = importlib.util.spec_from_file_location("mcp_plugin", pp)
|
|
m = importlib.util.module_from_spec(spec)
|
|
spec.loader.exec_module(m)
|
|
_srv = m.Server()
|
|
_srv.start()
|
|
print("[idat-mcp] started server via direct import")
|
|
|
|
print("[idat-mcp] MCP HTTP server should be live at http://127.0.0.1:13337")
|