Skip to content

fix(mcp): keep 256 replay events per session as Protean does - #120

Merged
htcom-code merged 1 commit into
mainfrom
fix/mcp-replay-buffer
Nov 29, 2026
Merged

htcom-code merged 1 commit into
mainfrom
fix/mcp-replay-buffer

Conversation

@htcom-code

Copy link
Copy Markdown
Owner

Summary

Protean keeps up to protean.mcp.session.replay-buffer (default 256) recent events per MCP session for Last-Event-ID replay and drops the oldest first (McpConfiguration.java:113, McpSession.java:99-100). Protrus hard-coded 100.

  • McpSessionStore now defaults the replay buffer to 256 (MCP_SESSION_REPLAY_BUFFER) with the same eviction order.
  • Embedders can change it with McpSessionStore::set_session_replay_buffer (0 keeps none), mirroring set_session_idle_timeout from fix(mcp): bind sessions to their principal and reclaim idle ones #115.
  • Design 17 §2.1 records that the key, like the idle timeout, is not in Java's ConfigRegistry and so stays out of the config registry: the standalone host uses 256.

Tests

  • New mcp_sessions_replay_the_newest_events_up_to_the_buffer_cap: default 256, oldest dropped first, a smaller cap trims on the next event, 0 keeps none.
  • cargo test --workspace --locked: 412 passed, 0 failed, 6 ignored.

Closes #119

Each MCP session buffers recent server events so a GET stream that
reconnects with Last-Event-ID gets what it missed. Protean sizes that
buffer with protean.mcp.session.replay-buffer, default 256, and drops the
oldest first; Protrus hard-coded 100, so a reconnecting client lost
events Protean would still replay.

The buffer now defaults to 256 with the same eviction order, and
embedders can change it through McpSessionStore::set_session_replay_buffer
(0 keeps none). Like the idle timeout, the key is not in Java's
ConfigRegistry, so it stays out of the config registry; design 17 records
this.

Closes #119

Tags: fix, mcp
Co-Authored-By: htjulia <htjulia1@gmail.com>
@htcom-code
htcom-code merged commit 7f6efa2 into main Nov 29, 2026
4 checks passed
@htcom-code
htcom-code deleted the fix/mcp-replay-buffer branch November 29, 2026 14:14
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.

MCP session replay buffer keeps 100 events where Protean keeps 256

1 participant