fix(mcp): widen KyteMCPSession.payload to LONGTEXT (v4.6.0 regression — large read_page fails)#94
Merged
Conversation
…ssion) The streamable-HTTP SDK stages full JSON-RPC tool responses in the session payload (_mcp.outgoing_queue). v4.6.0's DbSessionStore made payload a TEXT column (64KB), so a large read (read_page on a 300KB+ page produces a ~786KB response) overflowed it; MySQL silently truncated at 65535 bytes, corrupting the stored JSON, which then failed json_decode on the next read (ctrl-char error) and surfaced to the client as HTTP 400. The FileSessionStore this replaced had no size cap, so this is a parity regression. - src/Mvc/Model/KyteMCPSession.php payload type t -> lt (LONGTEXT) - migrations/4.6.1_mcp_session_payload_longtext.sql ALTER MODIFY LONGTEXT + purge sessions truncated under the old column (LENGTH(payload) >= 65535) - tests/DbSessionStoreTest.php regression test: >64KB payload round-trip - CHANGELOG.md v4.6.1 Verified on dev: read_page on a 312KB current-version page returns clean JSON (previously 400). Existing installs only need the ALTER; fresh installs get LONGTEXT from the model. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Summary
Hotfix for a regression introduced in v4.6.0.
read_page(and any large MCP read) failed with HTTP 400 +"Control character error, possibly incorrectly encoded".Root cause
The streamable-HTTP SDK stages its outgoing JSON-RPC response inside the session payload (
_mcp.outgoing_queue) between handling and delivery. v4.6.0'sDbSessionStoredefinedKyteMCPSession.payloadasTEXT(64 KB). A large read (e.g. a 300 KB+ page → ~786 KB response, since the SDK also duplicates content as a text block andstructuredContent) overflows the column → MySQL silently truncates at 65535 bytes → corrupt JSON →json_decodectrl-char error on the next read → 400 to the client.The
FileSessionStorev4.6.0 replaced had no size cap, so large reads worked there — this is a parity regression, not pre-existing.Fix
KyteMCPSession.payload→LONGTEXT(model typelt).migrations/4.6.1_mcp_session_payload_longtext.sql:ALTER TABLE ... MODIFY payload LONGTEXT+ purge sessions already truncated under the old column (LENGTH(payload) >= 65535).Verification
Reproduced on dev (read_page on a 312 KB current-version page → 400). After the
ALTER, the same read returns clean JSON. Confirmed the dev column is nowlongtextand the corrupt session was purged.Rollout
Existing installs that took 4.6.0 with the default DB store need the
ALTER(it fixes the running code immediately — no app restart required for the column change to take effect).file-backend installs are unaffected.🤖 Generated with Claude Code