Skip to content

Add MCP Streamable HTTP session limit properties - #7193

Open
liotur wants to merge 1 commit into
spring-projects:mainfrom
liotur:mcp-streamable-session-limits
Open

liotur wants to merge 1 commit into
spring-projects:mainfrom
liotur:mcp-streamable-session-limits

Conversation

@liotur

@liotur liotur commented Oct 17, 2026

Copy link
Copy Markdown

The Streamable HTTP transport providers support maxSessions and sessionIdleTimeout (#6760), but McpServerStreamableHttpWebMvcAutoConfiguration and McpServerStreamableHttpWebFluxAutoConfiguration don't set them. They can only be changed by defining a custom transport provider bean, and with the auto-configured providers idle sessions are never evicted. #6860 reports sessions that stay open after clients disconnect without sending DELETE.

This adds two properties and applies them to both providers:

  • spring.ai.mcp.server.streamable-http.max-sessions, default 100000 (the transport's default)
  • spring.ai.mcp.server.streamable-http.session-idle-timeout, not set by default, so idle sessions are only evicted when it is configured

The transport's check that the idle timeout must be greater than the keep-alive interval is enforced at startup. The reference docs describe both properties in a new Session Limits section.

See #6760

The Streamable HTTP transport providers can limit the number of
sessions and evict idle sessions (spring-projects#6760), but the auto-configuration
does not pass these settings to them. Users have to define their own
transport provider bean to change them, and with the auto-configured
providers idle sessions are never evicted.

Add the spring.ai.mcp.server.streamable-http.max-sessions and
spring.ai.mcp.server.streamable-http.session-idle-timeout properties
and apply them to the WebMvc and WebFlux transport providers.

See spring-projects#6760

Signed-off-by: Armen Petrosyan <liotur.mail@gmail.com>
@liotur
liotur force-pushed the mcp-streamable-session-limits branch from bbf553c to ef02ab3 Compare November 27, 2026 15:43
@liotur

liotur commented Nov 27, 2026

Copy link
Copy Markdown
Author

Rebased on current main. The transport provider beans now take an
ObjectProvider<McpServerCustomizer<...Builder>>, so the two property calls moved onto the builder
variable and sit before the customizers run — a customizer can still override either value, which
seems the right order.

@since is now 2.1.1 rather than 2.1.0, since 2.1.0 has shipped.

19/19 in both the WebMvc and WebFlux autoconfiguration ITs; reverting the two builder calls fails 3
of them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants