[GH-ISSUE #3020] [Bug] Engine error results bypass the declared outputSchema: hosts see -32602 instead of the real failure (success path is schema-clean) #1059

Closed
opened 2026-10-15 18:30:44 +00:00 by bsakaguchi · 2 comments
Owner

Originally created by @hj01857655 on GitHub (Oct 13, 2026).
Original GitHub issue: https://github.com/morluto/rea/issues/3020

Summary

When an analysis fails, the MCP wrapper serializes the error payload into structuredContent without mapping it into the tool's declared output envelope (result / evidence_id / evidence). Clients then reject it with:

MCP error -32602: Structured content does not match the tool's output schema:
data must have required property 'result',
data must have required property 'evidence_id',
data must have required property 'evidence',
data must NOT have additional properties

The actual engine error is masked. The success path is fine — this is purely an error-path schema violation.

Evidence (systematic bridge sweep, rea-agents 4.0.1, Windows 11 10.0.26100)

  • 50 whitelisted read-only tools called with empty args: binary_session, get_evidence_bundle, list_unknowns returned valid structured results; the rest failed fast on input validation (never reached the output layer). No schema failures among those.
  • Success path verified clean: analyze_javascript_application with a clean JS project dir returns ~1.5 MB structuredContent containing exactly result, evidence_id, evidence — schema-compliant, host consumes it normally.
  • Failure path reproduces the bug on two tools, both against the same genuinely-failing target (a patched app.asar):
    • analyze_javascript_application { input_path: "...\app.asar" } → -32602 via MCP; the CLI on the identical target exits 1 with a well-formed JSON error: code: artifact_integrity_mismatch, details logical_path / declared_sha256 / calculated_sha256 / unpacked.
    • inspect_artifact { integrity_policy: "record-and-continue" } (no active artifact → engine error) → same -32602.
  • Reproduced identically from two different MCP hosts, so this is server-side payload assembly, not host-specific.

Why it matters

Hosts see "server produced schema-invalid output" instead of the actionable engine error (integrity mismatch, no-binary-open, …). It reads like a broken integration and pushes users to abandon MCP for the tool — while the analysis layer itself is fine. In my case the masking sent everyone hunting for a nonexistent "bridge is dead" bug instead of the real artifact_integrity_mismatch.

Suggested fix

Wrap error payloads inside the declared result envelope, or return them as isError: true content blocks (per MCP spec, structuredContent validation is then not the failure carrier), so schema validation passes and the original error survives transport.

Env notes

  • rea-agents 4.0.1 (npm global), MCP registered via npx rea-agents setup (rea.cmd --mcp, stdio)
  • Node v25.8.0 — outside the documented matrix (22.x >= 22.19 / 24.x >= 24.11 / 26+); the failure is app-level payload assembly, but worth ruling out on supported Node too.
Originally created by @hj01857655 on GitHub (Oct 13, 2026). Original GitHub issue: https://github.com/morluto/rea/issues/3020 ## Summary When an analysis **fails**, the MCP wrapper serializes the error payload into `structuredContent` without mapping it into the tool's declared output envelope (`result` / `evidence_id` / `evidence`). Clients then reject it with: ``` MCP error -32602: Structured content does not match the tool's output schema: data must have required property 'result', data must have required property 'evidence_id', data must have required property 'evidence', data must NOT have additional properties ``` **The actual engine error is masked.** The success path is fine — this is purely an error-path schema violation. ## Evidence (systematic bridge sweep, rea-agents 4.0.1, Windows 11 10.0.26100) - 50 whitelisted read-only tools called with empty args: `binary_session`, `get_evidence_bundle`, `list_unknowns` returned valid structured results; the rest failed fast on input validation (never reached the output layer). No schema failures among those. - **Success path verified clean**: `analyze_javascript_application` with a clean JS project dir returns ~1.5 MB `structuredContent` containing exactly `result`, `evidence_id`, `evidence` — schema-compliant, host consumes it normally. - **Failure path reproduces the bug on two tools**, both against the same genuinely-failing target (a patched `app.asar`): - `analyze_javascript_application { input_path: "...\app.asar" }` → -32602 via MCP; the **CLI** on the identical target exits 1 with a well-formed JSON error: `code: artifact_integrity_mismatch`, details `logical_path / declared_sha256 / calculated_sha256 / unpacked`. - `inspect_artifact { integrity_policy: "record-and-continue" }` (no active artifact → engine error) → same -32602. - Reproduced identically from two different MCP hosts, so this is server-side payload assembly, not host-specific. ## Why it matters Hosts see "server produced schema-invalid output" instead of the actionable engine error (integrity mismatch, no-binary-open, …). It reads like a broken integration and pushes users to abandon MCP for the tool — while the analysis layer itself is fine. In my case the masking sent everyone hunting for a nonexistent "bridge is dead" bug instead of the real `artifact_integrity_mismatch`. ## Suggested fix Wrap error payloads inside the declared `result` envelope, or return them as `isError: true` content blocks (per MCP spec, structuredContent validation is then not the failure carrier), so schema validation passes and the original error survives transport. ## Env notes - rea-agents 4.0.1 (npm global), MCP registered via `npx rea-agents setup` (`rea.cmd --mcp`, stdio) - Node v25.8.0 — outside the documented matrix (22.x >= 22.19 / 24.x >= 24.11 / 26+); the failure is app-level payload assembly, but worth ruling out on supported Node too.
bsakaguchi 2026-10-15 18:30:44 +00:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@hj01857655 commented on GitHub (Oct 13, 2026):

Closing — fixed upstream between 4.0.1 and 6.4.0

Re-tested on rea-agents 6.4.0 (npm latest, no local patch): the same failing target now returns a wire-clean result — isError: true, structuredContent absent (the transport strips the private error carrier before the wire, per the comment in projectedErrorResult), and the real engine diagnostic (artifact_integrity_mismatch, including the offending unpacked entry) reaches the host intact.

Original repro was on the stale global 4.0.1 that predated the transport strip. Thanks for the fix; closing.

<!-- gh-comment-id:6155820374 --> @hj01857655 commented on GitHub (Oct 13, 2026): ## Closing — fixed upstream between 4.0.1 and 6.4.0 Re-tested on **rea-agents 6.4.0** (npm latest, no local patch): the same failing target now returns a wire-clean result — `isError: true`, `structuredContent` absent (the transport strips the private error carrier before the wire, per the comment in `projectedErrorResult`), and the real engine diagnostic (`artifact_integrity_mismatch`, including the offending unpacked entry) reaches the host intact. Original repro was on the stale global 4.0.1 that predated the transport strip. Thanks for the fix; closing.
Author
Owner

@hj01857655 commented on GitHub (Oct 13, 2026):

Resolved: behavior verified fixed on 6.4.0.

<!-- gh-comment-id:6155820825 --> @hj01857655 commented on GitHub (Oct 13, 2026): Resolved: behavior verified fixed on 6.4.0.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#1059
No description provided.