feat(mcp): DB-backed session store for cross-instance/LB deployments (v4.6.0)#93
Merged
Merged
Conversation
Adds KyteMCPSession + DbSessionStore so MCP protocol sessions are shared across instances behind a load balancer, fixing the per-host FileSessionStore breakage on multi-instance installs (e.g. ETOM). The DB store is the default; KYTE_MCP_SESSION_STORE='file' opts back to the SDK file store. TTL semantics mirror the file store (idle timeout via last-write); lookups are per-account scoped, gc() is a global capped sweep. - src/Mvc/Model/KyteMCPSession.php new model (auto-registered by loader) - src/Mcp/Session/DbSessionStore.php SessionStoreInterface implementation - src/Mcp/Endpoint.php buildSessionStore() backend selector - migrations/4.6.0_mcp_session_store.sql CREATE TABLE IF NOT EXISTS - tests/DbSessionStoreTest.php 7 tests (round-trip, miss, upsert, destroy, account isolation, TTL expiry, gc) -- green on MariaDB 10.5 - CHANGELOG.md v4.6.0 entry Refs KYTE-183. 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
Adds a DB-backed MCP protocol-session store so deployments behind a load balancer share session state across instances. Fixes the per-host
FileSessionStorebreakage whereinitializeand follow-up requests land on different boxes (the blocker for thekyte-etometryMCP connection on ETOM's 2 nodes). Refs KYTE-183.What changed
src/Mvc/Model/KyteMCPSession.php— new model, auto-registered by theMvc/Modelloader.src/Mcp/Session/DbSessionStore.php—SessionStoreInterfaceimpl againstKyteMCPSession.src/Mcp/Endpoint.php—buildSessionStore()selects backend.migrations/4.6.0_mcp_session_store.sql—CREATE TABLE IF NOT EXISTS, indexed (UNIQUEsession_id, compositekyte_account,session_id,last_activity).tests/DbSessionStoreTest.php— 7 tests; full unit suite green (194 tests) on MariaDB 10.5.CHANGELOG.md— v4.6.0.Behavior / decisions
define('KYTE_MCP_SESSION_STORE', 'file')opts back to the SDK file store (kept as a break-glass option).KYTE_MCP_SESSION_TTLoverrides idle TTL (default 3600s).FileSessionStoreexactly —last_activityslides on each request (Protocolcallssave()per request);exists()reports expiry without deleting,read()purges on expiry.gc()sweep capped at 1000/call. Rows are hard-deleted (purge), not soft-deleted, to keep thesession_idUNIQUE index clean.Rollout note
With DB as default, the migration must run on every install before it serves MCP on v4.6.0 (additive,
IF NOT EXISTS). Single-instance installs (dev, ORB/ORT) are functionally unaffected — they just move to the DB store. ETOM is the one that actually needs it.Validation so far
dev-branch pin (no tag yet).