fix(mcp): preserve project tool model output and error status

Merged
RU
2mo ago
+58-3
  • Render string outputs through a project's toModelOutput, matching how its tool presents results to an AI SDK model.
  • Preserve error-text and error-json as MCP results with isError: true, with the rendered text or JSON intact.
  • Cover both behaviors through a built stdio server and a real MCP client. Update MCP docs, the consumer skill, and the package changeset.

Verified

Ran it locally: yes

  • Started the built e2e mcp CLI on the real Chromium testbed, opened a session, invoked custom project tools, and closed it through the MCP SDK client. Node 24.18.0 and pnpm 12.3.4.
Toolmainthis branch
String formatterraw stringformatted: raw string
Rendered text errorText, no isErrorSame text, isError: true
Rendered JSON errorJSON text, no isErrorSame JSON text, isError: true
formatted_string {"content":[{"type":"text","text":"formatted: raw string"}]}
failure_text {"content":[{"type":"text","text":"not available"}],"isError":true}
failure_json {"content":[{"type":"text","text":"{\n  \"reason\": \"not available\"\n}"}],"isError":true}
  • Both new unit regressions and the live server regression fail against main. The branch's focused MCP tests pass 27/27; the full core unit suite passes 2452 tests with 1 skipped. All package builds, core typecheck, lint, and docs validation/broken links pass.
  • Fresh-context review found no important or critical findings. pnpm check stops at dead-code findings under the filtered dependency install; excluded Expo dependencies also block root-wide typecheck.
  • Full deterministic web benchmark passes, 41 files and 91 tests, using this branch's built packages against the unchanged production Next app served by the web verification worktree. Hosted Actions require maintainer approval for this fork.