Skip to content

feat(session): bound the in-memory session store#152

Open
SVilgelm wants to merge 1 commit into
rust-mcp-stack:mainfrom
SVilgelm:feat/session-store-bounds
Open

feat(session): bound the in-memory session store#152
SVilgelm wants to merge 1 commit into
rust-mcp-stack:mainfrom
SVilgelm:feat/session-store-bounds

Conversation

@SVilgelm
Copy link
Copy Markdown
Contributor

📌 Summary

The in-memory session store was unbounded with no idle expiry, so anyone could fill it via repeated initialize requests and exhaust memory. The store now enforces a maximum session count (default 10,000) and an optional idle TTL, and the server rejects new sessions past the cap with 503 Service Unavailable.

🔍 Related Issues

✨ Changes Made

  • Add max_sessions and session_idle_ttl to HyperServerOptions and InMemorySessionStore::with_limits.
  • Track per-session last-access time; evict idle sessions lazily.
  • Add SessionStore::is_full and return 503 from both session-creation paths.
  • Add an integration test asserting 503 at capacity.

Add a max-session cap (default 10k) and optional idle TTL with lazy eviction. New sessions past the cap are rejected with 503, preventing memory exhaustion via repeated initialize requests.

Assisted-By: Claude Opus 4.7 <noreply@anthropic.com>
Signed-off-by: Sergey Vilgelm <sergey@vilgelm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant