Title: session_idle_timeout is not exposed via streamable_http_app() and can cancel active requests · Issue #2455 · modelcontextprotocol/python-sdk · GitHub
Open Graph Title: session_idle_timeout is not exposed via streamable_http_app() and can cancel active requests · Issue #2455 · modelcontextprotocol/python-sdk
X Title: session_idle_timeout is not exposed via streamable_http_app() and can cancel active requests · Issue #2455 · modelcontextprotocol/python-sdk
Description: Summary The session_idle_timeout feature currently has two linked problems: it is implemented on StreamableHTTPSessionManager but not exposed through the canonical streamable_http_app() API surface it can terminate a session while a requ...
Open Graph Description: Summary The session_idle_timeout feature currently has two linked problems: it is implemented on StreamableHTTPSessionManager but not exposed through the canonical streamable_http_app() API surface...
X Description: Summary The session_idle_timeout feature currently has two linked problems: it is implemented on StreamableHTTPSessionManager but not exposed through the canonical streamable_http_app() API surface...
Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/issues/2455
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"session_idle_timeout is not exposed via streamable_http_app() and can cancel active requests","articleBody":"## Summary\n\nThe `session_idle_timeout` feature currently has two linked problems:\n\n1. it is implemented on `StreamableHTTPSessionManager` but not exposed through the canonical `streamable_http_app()` API surface\n2. it can terminate a session while a request is actively in flight\n\n## Why this looks like a bug\n\nPR #1994 / #2022 describe `session_idle_timeout` as a way to reap sessions that receive **no HTTP requests** for the configured duration.\n\nThat implies two things:\n\n- users of the high-level StreamableHTTP API should be able to configure it without dropping down to manual session-manager wiring\n- a request that is currently being processed should not count as an idle session\n\nToday neither of those expectations holds.\n\n## Problem 1: not exposed by `streamable_http_app()`\n\n`StreamableHTTPSessionManager(...)` accepts `session_idle_timeout`, but:\n\n- `mcp.server.lowlevel.server.Server.streamable_http_app(...)` does not\n- `mcp.server.mcpserver.server.MCPServer.streamable_http_app(...)` does not\n\nSo the recommended high-level API cannot configure a supported session-manager feature.\n\n### Reproduction\n\n```python\nfrom mcp.server import Server\n\napp = Server(\"demo\")\napp.streamable_http_app(session_idle_timeout=30)\n```\n\n### Observed behavior\n\n```python\nTypeError: Server.streamable_http_app() got an unexpected keyword argument 'session_idle_timeout'\n```\n\n## Problem 2: active requests can be cancelled by the idle timeout\n\nWith a short idle timeout and a handler that takes longer than that timeout, the session can be reaped mid-request and the client waits until timeout / session termination rather than receiving the tool result.\n\n### Reproduction outline\n\n- configure `StreamableHTTPSessionManager(app=..., session_idle_timeout=...)`\n- make a tool handler sleep longer than the timeout\n- call the tool over StreamableHTTP\n\n### Observed behavior\n\nOn current `main`, the active request can be terminated before the handler finishes, and the client fails instead of receiving the result.\n\n## Expected behavior\n\n- `streamable_http_app()` should expose `session_idle_timeout`\n- idle reaping should only happen when the session has no in-flight requests\n- once the last active request finishes, the idle deadline can resume normally\n\n## Validation\n\nI reproduced both behaviors locally against current `main`.\n\nI also verified that a minimal patch can fix both together by:\n\n1. threading `session_idle_timeout` through the low-level + MCPServer `streamable_http_app()` wrappers\n2. suspending idle reaping while at least one request is in flight\n3. restoring the idle deadline after the last active request completes\n\nA focused regression suite in `tests/server/test_streamable_http_manager.py` can cover:\n\n- passthrough from `streamable_http_app(session_idle_timeout=...)`\n- active request longer than the timeout still completes successfully\n- existing idle-session reaping still works once requests are finished\n","author":{"url":"https://github.com/shaun0927","@type":"Person","name":"shaun0927"},"datePublished":"2026-04-16T15:38:12.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/2455/python-sdk/issues/2455"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:39af9d74-cc30-88ea-90dc-a0d3e8a02d6e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E97A:2BBB15:C38EFB:1048859:6A5B9878 |
| html-safe-nonce | a2d3e2ec20d434ad14bc0e4674e7690640f9ff4c01b2cf3e7315f29fb1a2e6d7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFOTdBOjJCQkIxNTpDMzhFRkI6MTA0ODg1OTo2QTVCOTg3OCIsInZpc2l0b3JfaWQiOiI1MzczMTIxMDUzOTI0NzU5NjcyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 8b7162a25d51603484170bbde5afeacb467b699952e4051384a6198f525f2659 |
| hovercard-subject-tag | issue:4276802631 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/modelcontextprotocol/python-sdk/2455/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2159044ebee0df80438129ba3966725c89f91764c119390dbad587913caa7767/modelcontextprotocol/python-sdk/issues/2455 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2159044ebee0df80438129ba3966725c89f91764c119390dbad587913caa7767/modelcontextprotocol/python-sdk/issues/2455 |
| og:image:alt | Summary The session_idle_timeout feature currently has two linked problems: it is implemented on StreamableHTTPSessionManager but not exposed through the canonical streamable_http_app() API surface... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | shaun0927 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5290d7e14309ad1e76106a9c4237bd1041517e83ea182c8ab756752cb0c6940b |
| turbo-cache-control | no-preview |
| go-import | github.com/modelcontextprotocol/python-sdk git https://github.com/modelcontextprotocol/python-sdk.git |
| octolytics-dimension-user_id | 182288589 |
| octolytics-dimension-user_login | modelcontextprotocol |
| octolytics-dimension-repository_id | 862584018 |
| octolytics-dimension-repository_nwo | modelcontextprotocol/python-sdk |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 862584018 |
| octolytics-dimension-repository_network_root_nwo | modelcontextprotocol/python-sdk |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9c975978430e9ad293956f2bbdaf153b1bd84a99 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width