feat(mcp): Batch thread reads with full bodies - #114
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
fedster99
force-pushed
the
fedster99/mcp-batch-thread
branch
from
August 1, 2026 11:37
f009d4e to
5182139
Compare
[gstack-context] Decisions: Cache the in-flight sync_trust query per account set inside one read_thread batch; keep the external MCP contract unchanged. Remaining: Push the commit, refresh PR evidence, and confirm CI. Tried: A regression assertion first proved that two same-account seeds issued two identical trust scans. Skill: /investigate [/gstack-context]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Product principle
Keep the MCP simple, powerful, and fast. Let an agent complete common goals with few requests, while keeping the tool surface small. Prefer bounded batching in an existing tool when the items share one intent, permission, selector model, and result shape.
MCP instructions describe capabilities, identifiers, limits, and guarantees. They do not prescribe how an agent reasons or sequences its work. Infrastructure enforces authentication, tenant isolation, and resource boundaries. The agent owns the task and its questions.
Summary
read_threadaccepts one message seed or 1–10message_idsthrough the existing tool. It removes exact duplicates, reads at most four threads at once, preserves order, and isolates each result or error.read_messageandread_threadreturn the full available cleaned body by default. They do not apply a per-message character cap.Original Messageblocks remain available.include_quoted=truekeeps quoted text.read_messagesupports optional Unicode-safebody_offsetand positivemax_body_charsranges without a product ceiling.body_content_status,body_omissions,thread_content_status,thread_omissions, andomitted_message_countmake every known omission explicit.source_truncatedmeans sync stored an incomplete source message. It is separate from an explicitly requested response range.draft_replyquotes the complete selected source body. A single-pass byte transform prefixes lines without building one JavaScript string per line.includeBody: falseread option to fetch metadata before Storage hydration. Public MCP defaults do not change.The MCP surface remains five tools.
Evidence
A real mailbox test found 319 matching emails in 118 threads. Serial thread reads took about 1 minute 54 seconds. The median thread took 0.79 seconds. The slowest first read took 6.79 seconds and later took 1.5–2.3 seconds. Metadata encryption added only 3–4 milliseconds. MCP round trips and Storage reads caused the material delay.
A smaller-model evaluation showed the cost of the former 4,096-character MCP cap:
Full bodies prevent silent server-side loss. Optional ranges provide recovery when a client host truncates an unusually large response.
Review fixes
sync_trustcache.raw_truncatedas the explicitsource_truncatedomission.Final contract and adversarial reviews found no remaining issue after these fixes.
Test coverage
The final cross-repository audit found direct tests for 48 of 54 changed behavior paths (89%). The remaining gaps are additional listener-level disconnect coverage and narrow edge assertions for response mapping, control/astral characters, initialization publication, and UTF-8 quoting. The audit found no regression.
Plan completion
All public-core implementation, documentation, review, verification, commit, push, and PR-update items are complete. Image publication and Cloud repinning remain ordered follow-up gates after an approved merge.
Verification
INSTALL_CMD=true RUN_LIVE_DB=1 ./init.shpassed under local Node 26; the repo targets Node 24.git diff --checkpassed.Documentation
Updated README, the agent email guide, MCP instructions, the architecture indexes, the attachment content ADR, and ADR 0030.
Cloud dependency
The hosted wrapper remains draft PR #226. Merge this PR only after explicit maintainer approval. After the public image publishes, Cloud must pin the exact commit and image digest and pass its packaged hosted MCP smoke test.