Repository navigation
fix(mcp-sessions): require a minimum idle age before LRU eviction at capacity (#467) - #468
Merged
Merged
Conversation
James3014
enabled auto-merge (squash)
October 9, 2026 01:35
…capacity (#467) LRU eviction at capacity now only evicts sessions idle for at least DEVSPACE_MCP_SESSION_LRU_MIN_IDLE_MS (default 60s, <= idle timeout), so one client cannot churn others' recently active sessions. Rejections report rejectionCause (all_in_flight | no_session_idle_min) in the mcp_session_capacity_rejected log; the HTTP response is unchanged. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
James3014
force-pushed
the
fix/issue-467-lru-min-idle-guard
branch
from
October 9, 2026 01:51
31ad630 to
59bfe99
Compare
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.
Closes #467. LRU eviction at capacity (added in #461) now only considers sessions with no in-flight request, not pending close, and idle for at least
DEVSPACE_MCP_SESSION_LRU_MIN_IDLE_MS(default 60 000 ms). Younger sessions stay protected, so one noisy client can no longer evict other clients' recently active sessions; if no session qualifies, registration is rejected with the same 503 / -32004 as before #461.DEVSPACE_MCP_SESSION_LRU_MIN_IDLE_MS(config-file keymcpSessionLruMinIdleMs), validated as a positive integer no greater than the effective idle timeout (sameInvalid <NAME>: <value>error as the sibling settings). The unset default is clamped to the idle timeout so a short idle timeout never makes the default invalid.evictLruToLimit()andhasEvictableSession()share the rule, socanAcceptRegistration()/admitRegistration()still agree withregister().register()rejections carryrejectionCause: "all_in_flight" | "no_session_idle_min"and the registry exposescapacityRejectionCause()for the pre-check path.mcp_session_capacity_rejectedlogs it asrejectionCause. The HTTP response is unchanged.lruMinIdleMsdefaults tomin(60 s, idleTimeoutMs)when omitted, so callers that only set an idle timeout keep pre-P1: MCP session store rejects new sessions with 503 while idle sessions with no in-flight requests remain evictable #461 behavior for young sessions.no_session_idle_min,capacityRejections+1,lruEvictionsunchanged); 256 idle 90 s evicts the LRU with no rejection; exact-boundary check; all in flight rejects withall_in_flight; mixed young/in-flight case; config default, env override, config clamp, and rejection of 0, negative, non-integer, and values above the idle timeout. P1: MCP session store rejects new sessions with 503 while idle sessions with no in-flight requests remain evictable #461 tests that assumed unconditional eviction now setlruMinIdleMsexplicitly and the rejection assertions includerejectionCause.Verification:
npx tsx src/mcp-sessions.test.ts,npx tsx src/config.test.ts,npx tsx src/server.test.ts(67 pass),npm run typecheck,npm run build.🤖 Generated with Claude Code