Files
rea/src/ida/IdaProviderCapabilities.ts
T
d1aaeee400 feat(ida): support optional native IDA Free MCP in attached mode (#1544)
Add an explicit attached native IDA MCP compatibility profile while preserving the legacy and headless workflows. Keep recorded input identity, complete source observations and the user's open GUI database. Batch unique callee lookups, conservatively prefilter literal strings, preserve Unicode matching and unavailable caller coverage, and require distinct-function switching in native verification.

Verified with Windows IDA Pro 9.3 and the native MCP plugin built from c9d15d98e8a143fc74f6e14037c48f63889b6d6c with a loopback listener. Production CLI/MCP and an unchanged Windows whoami.exe passed. Windows IDA Free was not used. No personal paths or license registration information are included.

Validation: 200 focused tests, static and documentation checks, architecture guards and discovery passed. Historical same-main warm task measurements improved from 675 to 317 ms; response token estimates fell from 16618 to 11509. Fresh-start, overall CPU and memory improvement were not established. Detailed scope is in experiments/analysis-efficiency/ida-native-windows.md.

Co-authored-by: imissapixel <140405963+imissapixel@users.noreply.github.com>
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
Co-authored-by: N0zoM1z0 <161784452+N0zoM1z0@users.noreply.github.com>
2026-10-13 03:10:21 +08:00

92 lines
4.0 KiB
TypeScript

import type {
AnalysisOperation,
CapabilityDescriptor,
} from "../application/AnalysisProvider.js";
/** This version identifies REA's adapter, not IDA or the upstream MCP server. */
export const IDA_PROVIDER_IDENTITY = Object.freeze({
id: "ida",
name: "IDA MCP adapter",
version: "1",
});
/** Read-only analyst outcomes supported by the upstream compatibility profiles. */
export const IDA_OPERATIONS = Object.freeze([
"list_procedures",
"search_procedures",
"list_strings",
"search_strings",
"procedure_address",
"procedure_pseudo_code",
"procedure_assembly",
"procedure_callers",
"procedure_callees",
"read_function_instructions",
"xrefs",
"analyze_function",
] as const satisfies readonly Exclude<AnalysisOperation, "health">[]);
export type IdaOperation = (typeof IDA_OPERATIONS)[number];
/** Shared limitations of observations from an externally mutable analysis database. */
export const IDA_LIMITATIONS = Object.freeze([
"Provider version identifies the REA IDA adapter. IDA engine and upstream distribution versions are unknown unless separately observed; MCP serverInfo is reported independently.",
"Results describe the current IDA analysis database. Input identity does not prove an unmodified database; patches, annotations, analysis completeness, and database revision remain unknown.",
"Live results are never replayed from analysis snapshots. Target checks before and after a request do not provide an atomic lock against external GUI changes.",
"Caller cancellation drains the in-flight MCP request before cleanup; it does not prove that IDA engine work was interrupted.",
"Headless workers are released through the upstream database lifecycle. Abrupt termination of REA, its proxy, or the supervisor cannot prove worker cleanup; inspect upstream inventory after an interrupted process.",
"Complete function body ranges, typed references, unresolved indirect calls, referenced data, and basic blocks are unavailable in this adapter. Empty unsupported dossier facets are unknown, not observed absence.",
]);
export const IDA_NATIVE_STRING_LIMITATION =
"Native string observations use upstream C-string rendering; other string representations remain unknown.";
/**
* Attached mode requires the legacy 1.4 profile, whose `disassemble_function`
* jumps to the function and whose `decompile_function` opens or reuses a
* pseudocode view whenever an IDA window is active.
*/
const ATTACHED_GUI_NAVIGATION_OPERATIONS: ReadonlySet<IdaOperation> = new Set([
"procedure_pseudo_code",
"procedure_assembly",
"read_function_instructions",
"analyze_function",
]);
/** Advertise live observations and configured lifecycle effects truthfully. */
export const idaCapabilities = (
mode: "attached" | "headless",
stdio: boolean,
native = false,
): readonly CapabilityDescriptor[] =>
IDA_OPERATIONS.map((operation) => ({
provider: IDA_PROVIDER_IDENTITY,
operation,
...((mode === "headless" || native) && operation === "procedure_callers"
? ({
available: false,
reason: native
? "The native upstream profile reports code references without proving direct call edges."
: "The modern upstream profile reports code references without proving direct call edges.",
} as const)
: ({ available: true, reason: null } as const)),
cachePolicy: "live",
effects: {
mutatesArtifact: false,
launchesProcess: stdio || mode === "headless",
mayShowUi:
mode === "attached" &&
(native
? operation === "procedure_pseudo_code" ||
operation === "analyze_function"
: ATTACHED_GUI_NAVIGATION_OPERATIONS.has(operation)),
mayAccessNetwork: true,
mayWriteFilesystem: stdio || mode === "headless",
changesPermissions: false,
requiresRoot: false,
},
limitations:
native && (operation === "list_strings" || operation === "search_strings")
? [...IDA_LIMITATIONS, IDA_NATIVE_STRING_LIMITATION]
: IDA_LIMITATIONS,
}));