fix(mcp): report Linux-only integrations as unsupported_host off their hosts (#5793)

* fix(mcp): report Linux-only integrations as unsupported_host off their hosts

Session discovery folded the host check into each optional integration's
enabled flag, so on macOS or Windows the Linux-only packet, signal,
firmware, pwntools, EVM and Wakaru tools reported provider_missing.
Their execution guards refuse those hosts whatever is configured, so
installing a provider there could never make them available.

The server now records, per integration, when the host is outside its
verified host and no service is injected. Discovery checks that before
configuration and reports unsupported_host with the existing
remediation. Injected services and supported hosts behave as before.

Fixes #5730

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* refactor(mcp): share provider host checks with session discovery

Discovery restated each Linux-only integration's host rule in
createServer while its provider kept a separate execution check, so the
two could drift apart again. Each provider now exports its host
predicate, uses it in its execution guard, and composition hands the
same predicate to createServer for both the host restriction and the
enabled flag.

Observed host restrictions now also apply when an embedder supplies its
own availability policy, as provider load failures already do, because
no policy lets the default providers pass their host checks.

The MCP regression moves to tests/process-global and emulates darwin
arm64, linux arm64 and linux x64 through the real createServer, so CI on
Linux x64 exercises the unsupported-host branch. It also covers a
configured policy and the matching execution refusals.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(mcp): keep caller host restrictions beside observed ones

The observed host restriction replaced a configured policy's whole
hostUnsupported map. For an injected service the observed value is
false, so a caller's own restriction was lost and the tool was reported
available. Combine both per integration: either the caller or the
observed host can mark it unsupported.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(pcap): expect unsupported_host for packet tools off Linux

The host-independent PATH case asserted provider_missing on every host.
Off Linux the packet tools are unavailable because of the host, so
discovery now reports unsupported_host there; Linux still reports
provider_missing for an unusable PATH.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Lewis WangandClaude Opus 5.5 authored and GitHub committed 2026-10-23 05:14:26 +08:00
1 parent 7695466081
commit 5a311d8afe
18 files changed
+531 -89

No files matched your search

@@ -762,3 +762,56 @@ describe("trace_feature requirements", () => {
).toMatchObject({ available: false, reason: "provider_missing" });
});
});
const HOST_RESTRICTED_TOOLS = [
["inspect_packet_capture", "packetCapture", "packetCaptureEnabled"],
["inspect_packet_fields", "packetCapture", "packetCaptureEnabled"],
["decode_signal_recording", "signalRecording", "signalRecordingEnabled"],
["inspect_signal_decoders", "signalRecording", "signalRecordingEnabled"],
["inspect_evm_interface", "evmInterface", "evmInterfaceEnabled"],
["inspect_binary_layout", "binaryLayout", "binaryLayoutEnabled"],
["inspect_recorded_crash", "recordedCrash", "recordedCrashEnabled"],
[
"inspect_firmware_regions",
"firmwareInspection",
"firmwareInspectionEnabled",
],
["extract_firmware", "firmwareExtraction", "firmwareExtractionEnabled"],
[
"recover_javascript_sources",
"javascriptRecovery",
"javascriptRecoveryEnabled",
],
] as const;
describe("host-restricted integrations", () => {
it.each(HOST_RESTRICTED_TOOLS)(
"reports %s on an unsupported host before its configuration",
(name, feature, enabledField) => {
const availability = (enabled: boolean, hostUnsupported: boolean) =>
buildCapabilityInventory(
{ open: false, capabilities: [] },
{
processCaptureEnabled: true,
...({ [enabledField]: enabled } as Record<
typeof enabledField,
boolean
>),
hostUnsupported: { [feature]: hostUnsupported },
},
).find((tool) => tool.name === name);
expect(availability(true, true)).toMatchObject({
available: false,
reason: "unsupported_host",
});
expect(availability(false, false)).toMatchObject({
available: false,
reason: "provider_missing",
});
expect(availability(true, false)).toMatchObject({
available: true,
reason: "available",
});
},
);
});
+80 -51
View File
@@ -51,7 +51,25 @@ const statusSchema = z.object({
type ToolAvailabilityReason = "available" | ToolUnavailabilityReason;
type ProviderDescriptor = ProviderCapability;
/** Optional integrations whose verified hosts exclude some platforms. */
export const HOST_RESTRICTED_FEATURES = [
"packetCapture",
"signalRecording",
"evmInterface",
"binaryLayout",
"recordedCrash",
"firmwareInspection",
"firmwareExtraction",
"javascriptRecovery",
] as const;
export type HostRestrictedFeature = (typeof HOST_RESTRICTED_FEATURES)[number];
export type AvailabilityPolicy = {
/** Integrations this host cannot run, whatever their configuration. */
readonly hostUnsupported?: Readonly<
Partial<Record<HostRestrictedFeature, boolean>>
>;
readonly packetCaptureEnabled?: boolean;
readonly signalRecordingEnabled?: boolean;
readonly wasmArtifactEnabled?: boolean;
@@ -461,37 +479,33 @@ const workflowAvailabilityFor = ({
],
};
if (name === "recover_javascript_sources")
return policy.javascriptRecoveryEnabled === true
? { reason: "available", remediation: null }
: {
reason: "provider_missing",
remediation:
"On Linux x64, provide an absolute REA_WAKARU_COMMAND for Wakaru ^1.13.0 (verified with 1.14.0) and util-linux prlimit; see docs/javascript-recovery.md#install-wakaru. No binary target is required.",
};
return hostRestrictedAvailability(
policy,
"javascriptRecovery",
policy.javascriptRecoveryEnabled,
"On Linux x64, provide an absolute REA_WAKARU_COMMAND for Wakaru ^1.13.0 (verified with 1.14.0) and util-linux prlimit; see docs/javascript-recovery.md#install-wakaru. No binary target is required.",
);
if (name === "inspect_binary_layout")
return policy.binaryLayoutEnabled === true
? { reason: "available", remediation: null }
: {
reason: "provider_missing",
remediation:
"On Linux x64, set absolute REA_PWNTOOLS_PYTHON to caller-supplied Python with pwntools 4.15.0. No active binary target is required.",
};
return hostRestrictedAvailability(
policy,
"binaryLayout",
policy.binaryLayoutEnabled,
"On Linux x64, set absolute REA_PWNTOOLS_PYTHON to caller-supplied Python with pwntools 4.15.0. No active binary target is required.",
);
if (name === "inspect_packet_capture" || name === "inspect_packet_fields")
return policy.packetCaptureEnabled === true
? { reason: "available", remediation: null }
: {
reason: "provider_missing",
remediation:
"On Linux, supply TShark 4.x on PATH or through absolute REA_TSHARK_COMMAND, and util-linux prlimit (REA_TSHARK_PRLIMIT_COMMAND, default /usr/bin/prlimit). No active binary target or hardware is required; the tool is checked at execution.",
};
return hostRestrictedAvailability(
policy,
"packetCapture",
policy.packetCaptureEnabled,
"On Linux, supply TShark 4.x on PATH or through absolute REA_TSHARK_COMMAND, and util-linux prlimit (REA_TSHARK_PRLIMIT_COMMAND, default /usr/bin/prlimit). No active binary target or hardware is required; the tool is checked at execution.",
);
if (name === "decode_signal_recording" || name === "inspect_signal_decoders")
return policy.signalRecordingEnabled === true
? { reason: "available", remediation: null }
: {
reason: "provider_missing",
remediation:
"On Linux, supply sigrok-cli 0.7.2 via absolute REA_SIGROK_COMMAND and util-linux prlimit (REA_SIGROK_PRLIMIT_COMMAND, default /usr/bin/prlimit). No active binary target or hardware is required; the tool is checked at execution.",
};
return hostRestrictedAvailability(
policy,
"signalRecording",
policy.signalRecordingEnabled,
"On Linux, supply sigrok-cli 0.7.2 via absolute REA_SIGROK_COMMAND and util-linux prlimit (REA_SIGROK_PRLIMIT_COMMAND, default /usr/bin/prlimit). No active binary target or hardware is required; the tool is checked at execution.",
);
if (name === "inspect_wasm_artifact")
return policy.wasmArtifactEnabled === true
? { reason: "available", remediation: null }
@@ -507,37 +521,35 @@ const workflowAvailabilityFor = ({
if (name === "inspect_elf_notes")
return { reason: "available", remediation: null };
if (name === "inspect_evm_interface") {
if (policy.evmInterfaceEnabled !== true)
return {
reason: "provider_missing",
remediation:
"The bundled offline EVM interface profile is currently real-verified on Linux x64. No active binary target or chain endpoint is required.",
};
const profile = hostRestrictedAvailability(
policy,
"evmInterface",
policy.evmInterfaceEnabled,
"The bundled offline EVM interface profile is currently real-verified on Linux x64. No active binary target or chain endpoint is required.",
);
if (profile.reason !== "available") return profile;
const limiter = policy.evmLimiterAvailability;
if (limiter?.status === "unavailable")
return { reason: "provider_missing", remediation: limiter.reason };
return { reason: "available", remediation: null };
}
if (name === "inspect_recorded_crash")
return policy.recordedCrashEnabled === true
? { reason: "available", remediation: null }
: {
reason: "provider_missing",
remediation:
"On Linux x64, set absolute REA_PWNTOOLS_PYTHON to caller-supplied Python with pwntools 4.15.0. No active binary target is required.",
};
return hostRestrictedAvailability(
policy,
"recordedCrash",
policy.recordedCrashEnabled,
"On Linux x64, set absolute REA_PWNTOOLS_PYTHON to caller-supplied Python with pwntools 4.15.0. No active binary target is required.",
);
if (kind === "firmware-provider") {
const enabled =
name === "inspect_firmware_regions"
const inspection = name === "inspect_firmware_regions";
return hostRestrictedAvailability(
policy,
inspection ? "firmwareInspection" : "firmwareExtraction",
inspection
? policy.firmwareInspectionEnabled
: policy.firmwareExtractionEnabled;
return enabled === true
? { reason: "available", remediation: null }
: {
reason: "provider_missing",
remediation:
"On Linux, provide an absolute REA_BINWALK_COMMAND (Binwalk 3.1.x, verified with 3.1.0) or REA_UNBLOB_COMMAND (Unblob 26.6.x, verified with 26.6.4) path and util-linux prlimit. Extraction also requires the selected format’s external extractor.",
};
: policy.firmwareExtractionEnabled,
"On Linux, provide an absolute REA_BINWALK_COMMAND (Binwalk 3.1.x, verified with 3.1.0) or REA_UNBLOB_COMMAND (Unblob 26.6.x, verified with 26.6.4) path and util-linux prlimit. Extraction also requires the selected format’s external extractor.",
);
}
if (kind === "android-provider")
return policy.androidAnalysisAvailability?.status === "available"
@@ -604,6 +616,23 @@ const workflowAvailabilityFor = ({
return null;
};
/**
* An unsupported host takes precedence over configuration: no environment
* setting lets these integrations pass their execution host checks here.
*/
const hostRestrictedAvailability = (
policy: AvailabilityPolicy,
feature: HostRestrictedFeature,
enabled: boolean | undefined,
remediation: string,
): Availability => {
if (policy.hostUnsupported?.[feature] === true)
return { reason: "unsupported_host", remediation };
return enabled === true
? { reason: "available", remediation: null }
: { reason: "provider_missing", remediation };
};
const ownerProbeAvailability = (
observation: ProviderAvailability | undefined,
missingRemediation: string,