|
28 | 28 | * - `session_id` carries the RFC4122 UUID and must be UNIQUE; the index is |
29 | 29 | * created in the Phase-2/4.6.0 migration, not here (the model framework |
30 | 30 | * doesn't declare indexes). |
31 | | - * - `payload` is the raw `json_encode` of the SDK session array — small and |
32 | | - * bounded (a handful of scalar/array keys), TEXT is ample headroom. |
| 31 | + * - `payload` is the raw `json_encode` of the SDK session array. It is NOT |
| 32 | + * small/bounded: the streamable-HTTP SDK persists its outgoing-message |
| 33 | + * queue (`_mcp.outgoing_queue`) — i.e. full JSON-RPC tool *responses* — |
| 34 | + * inside the session between request and delivery. A single large read |
| 35 | + * (e.g. `read_page` on a 300KB+ page) puts a ~800KB response in here. So |
| 36 | + * `payload` is LONGTEXT, not TEXT: a TEXT column (64KB) silently truncates |
| 37 | + * the queued response → corrupt JSON → `json_decode` ctrl-char error on the |
| 38 | + * next read. The FileSessionStore this replaced had no size cap, so |
| 39 | + * LONGTEXT restores parity. See migrations/4.6.1_mcp_session_payload_longtext.sql. |
33 | 40 | */ |
34 | 41 |
|
35 | 42 | $KyteMCPSession = [ |
|
45 | 52 | 'date' => false, |
46 | 53 | ], |
47 | 54 |
|
48 | | - // Encoded session state: json_encode of the SDK session data array |
49 | | - // (initialized, client_info, client_capabilities, protocol_version, |
50 | | - // log_level). Opaque to Kyte — written and read verbatim by the store. |
| 55 | + // Encoded session state: json_encode of the SDK session data array. |
| 56 | + // Includes the SDK's `_mcp.outgoing_queue` — full JSON-RPC tool |
| 57 | + // responses staged for delivery — so this can run to hundreds of KB |
| 58 | + // for a large read. LONGTEXT ('lt'), NOT TEXT: a 64KB TEXT column |
| 59 | + // truncates large queued responses and corrupts the session. Opaque |
| 60 | + // to Kyte — written and read verbatim by the store. |
51 | 61 | 'payload' => [ |
52 | | - 'type' => 't', |
| 62 | + 'type' => 'lt', |
53 | 63 | 'required' => true, |
54 | 64 | 'date' => false, |
55 | 65 | ], |
|
0 commit comments