Skip to content

fix(server): bound mcp tool payloads on the wire - #5481

Closed
t3dotgg wants to merge 1 commit into
mainfrom
t3code/slim-mcp-tool-payloads
Closed

fix(server): bound mcp tool payloads on the wire#5481
t3dotgg wants to merge 1 commit into
mainfrom
t3code/slim-mcp-tool-payloads

Conversation

@t3dotgg

@t3dotgg t3dotgg commented Aug 6, 2026

Copy link
Copy Markdown
Member

Problem

MCP tool call payloads were the one activity type that skipped the wire projection — projectActivityPayload early-returned on itemType === "mcp_tool_call", so payload.data.item.result.content shipped the entire tool result. A single connector call (e.g. fetching a whole GitHub PR) reaches 1MB+, and one real MCP-heavy thread ships 11.7MB of mcp_tool_call payloads out of 17.8MB total wire size.

Fix

Run MCP payloads through the projection like every other tool payload. data.item is retained with a bounded shape: the call descriptor (tool, server, status, arguments, appContext, error, durationMs, type, id) survives intact, and item.result collapses to the same one-line preview that regular tool output already gets via summarizeToolTextOutput. data.toolCallId / data.kind are retained as before.

Both clients render data.item as JSON in the expanded work-log row and gate that row on data.item !== undefined, so an item record always projects to a record — the descriptor plus a result preview still renders. tool.started MCP rows go through the same path for consistency. Full payloads are untouched in SQLite and the event store; this only affects the wire.

Tests

Added to apps/server/test/ActivityPayloadProjection.test.ts: a 1MB+ result projects under 500 bytes while keeping tool/server/arguments/status, a small call keeps its fields, a failing call keeps error and isError, and an in-flight call with no result still renders. Full server suite green (1873 passed).


Changes made by Claude Fable 5 via Claude Code, running as a subagent of a planning session.

🤖 Generated with Claude Code


Note

Medium Risk
Changes orchestration wire payloads for a high-volume activity type; clients still get descriptors but lose full MCP result text in expanded work-log JSON unless they read persistence elsewhere.

Overview
MCP tool call activities are no longer exempt from wire projection. projectActivityPayload used to return them unchanged, so megabyte-scale result.content shipped on thread snapshots and activity events.

MCP rows now go through projectMcpToolCallData: call metadata (tool, server, status, arguments, error, durationMs, etc.) stays on data.item, while result is flattened from string or MCP text blocks (capped at 4KB) and collapsed to the same one-line preview other tools use via summarizeToolTextOutput. isError on failed tool results is preserved. In-flight calls without a result still expose a descriptor-only item so clients’ data.item !== undefined checks keep working.

Tests cover bounded megabyte payloads, failures, and in-progress calls; the web/mobile parity loop now excludes MCP because expanded work-log JSON will show the summarized result instead of the full blob. Persistence and the event store are unchanged—only API projection is affected.

Reviewed by Cursor Bugbot for commit 2ede711. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Bound MCP tool call payloads on the wire by projecting and summarizing large results

  • MCP tool call activities were previously passed through verbatim; they are now projected in ActivityPayloadProjection.ts to strip large result payloads down to a bounded summary.
  • Result content (string or MCP content blocks) is trimmed to 4096 characters via extractMcpResultText, then passed through summarizeToolTextOutput.
  • Only descriptor fields (type, id, tool, server, status, arguments, appContext, error, durationMs) are retained on the projected item; result is replaced with { content: summary } plus isError if the call failed.
  • Behavioral Change: MCP tool call activities no longer reach consumers with their raw result payloads; only the summarized content and descriptor fields are present.

Macroscope summarized 2ede711.

MCP tool call payloads skipped the wire projection entirely, so
`item.result.content` shipped whole tool results — a single connector
fetch reaches 1MB, and one MCP-heavy thread ships 11.7MB of
mcp_tool_call payloads out of 17.8MB total.

Project them like every other tool payload instead: keep the call
descriptor (tool, server, status, arguments, appContext, error,
durationMs, type, id) and collapse `result` to the same one-line
preview regular tool output already gets. Full payloads stay in SQLite.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2a61d4fb-6ccb-4332-9b22-7821b8a2cf50

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Aug 6, 2026
@macroscopeapp

macroscopeapp Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved 2ede711

Straightforward performance fix that bounds MCP tool result payloads (which can reach megabytes) to prevent oversized wire payloads. Self-contained change with comprehensive test coverage, authored by the file's original creator.

You can customize Macroscope's approvability policy. Learn more.

@t3dotgg

t3dotgg commented Aug 6, 2026

Copy link
Copy Markdown
Member Author

Superseded by #5482, which merged the same MCP payload bounding. Closing in favor of the merged implementation.

@t3dotgg t3dotgg closed this Aug 6, 2026
@t3dotgg
t3dotgg deleted the t3code/slim-mcp-tool-payloads branch August 6, 2026 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant