René's URL Explorer Experiment


Title: Stateful streamable server calls listRoots() unconditionally on roots/list_changed, blocking a servlet thread until requestTimeout when no roots consumer is registered · Issue #1061 · modelcontextprotocol/java-sdk · GitHub

Open Graph Title: Stateful streamable server calls listRoots() unconditionally on roots/list_changed, blocking a servlet thread until requestTimeout when no roots consumer is registered · Issue #1061 · modelcontextprotocol/java-sdk

X Title: Stateful streamable server calls listRoots() unconditionally on roots/list_changed, blocking a servlet thread until requestTimeout when no roots consumer is registered · Issue #1061 · modelcontextprotocol/java-sdk

Description: Stateful streamable server calls listRoots() unconditionally on roots/list_changed, blocking a servlet thread until requestTimeout when no roots consumer is registered Bug description When a McpAsyncServer / McpSyncServer uses the stream...

Open Graph Description: Stateful streamable server calls listRoots() unconditionally on roots/list_changed, blocking a servlet thread until requestTimeout when no roots consumer is registered Bug description When a McpAsy...

X Description: Stateful streamable server calls listRoots() unconditionally on roots/list_changed, blocking a servlet thread until requestTimeout when no roots consumer is registered Bug description When a McpAsy...

Opengraph URL: https://github.com/modelcontextprotocol/java-sdk/issues/1061

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Stateful streamable server calls listRoots() unconditionally on roots/list_changed, blocking a servlet thread until requestTimeout when no roots consumer is registered","articleBody":"# Stateful streamable server calls `listRoots()` unconditionally on `roots/list_changed`, blocking a servlet thread until `requestTimeout` when no roots consumer is registered\n\n## Bug description\n\nWhen a `McpAsyncServer` / `McpSyncServer` uses the streamable HTTP transport\n(`HttpServletStreamableServerTransportProvider`) and a client that advertises\n`capabilities.roots.listChanged` sends a `notifications/roots/list_changed`\nmessage, the server issues a **server→client `roots/list` request** back to the\nclient — even when the application registered **no** `rootsChangeConsumer`.\n\nThe transport handles the incoming notification by **blocking the servlet\n(request) thread** on that round-trip. If the client does not answer `roots/list`\n(many don't — it's a fire-and-forget notification from their side), the thread\nstays parked for the full `requestTimeout` and then fails with a\n`TimeoutException`. Every such notification pins one HTTP worker thread for the\nwhole timeout window; under multiple clients this degrades the server's request\npool.\n\nThis is the **stateful counterpart of the already-merged stateless fix in\n#835**. #835 made `roots/list_changed` a no-op for\n`HttpServletStatelessServerTransport`; the stateful streamable path\n(`McpAsyncServer.asyncRootsListChangedNotificationHandler`) was not touched and\nstill performs the unconditional round-trip — and here it doesn't just log a\nwarning, it blocks a thread.\n\n## Environment\n\n- `io.modelcontextprotocol.sdk:mcp-core` **2.0.0** (also present on `main`)\n- Transport: Streamable HTTP, `HttpServletStreamableServerTransportProvider`\n- Server: `McpServer.sync(...)`, servlet container (Jetty / Tomcat)\n- Client: any client that declares `roots.listChanged` and sends the\n  notification without answering the resulting `roots/list` (e.g. Claude Desktop\n  via `mcp-remote`)\n\n## Root cause\n\n**1. The notification handler calls `listRoots()` unconditionally.**\n\n`McpAsyncServer.prepareNotificationHandlers` substitutes a logging consumer when\nnone is registered (mcp-core 2.0.0, lines 199–201):\n\n```java\nif (Utils.isEmpty(rootsChangeConsumers)) {\n    rootsChangeConsumers = List.of((exchange, roots) -\u003e Mono.fromRunnable(() -\u003e logger\n        .warn(\"Roots list changed notification, but no consumers provided. Roots list changed: {}\", roots)));\n}\n```\n\nand `asyncRootsListChangedNotificationHandler` then calls\n`exchange.listRoots()` regardless (line 317):\n\n```java\nreturn (exchange, params) -\u003e exchange.listRoots()          // \u003c-- always sent, even to log-and-drop\n    .flatMap(listRootsResult -\u003e Flux.fromIterable(rootsChangeConsumers)\n        .flatMap(consumer -\u003e Mono.defer(() -\u003e consumer.apply(exchange, listRootsResult.roots())))\n        ...\n```\n\nSo a `roots/list` request goes out to the client to fetch a value that is only\nlogged.\n\n**2. The streamable transport blocks the servlet thread on the notification.**\n\n`HttpServletStreamableServerTransportProvider.doPost` handles a notification by\n`.block()`-ing (mcp-core 2.0.0, line 505):\n\n```java\nelse if (message instanceof McpSchema.JSONRPCNotification jsonrpcNotification) {\n    session.accept(jsonrpcNotification)\n        .contextWrite(ctx -\u003e ctx.put(McpTransportContext.KEY, transportContext))\n        .block();                                          // \u003c-- request thread parks here\n    response.setStatus(HttpServletResponse.SC_ACCEPTED);\n}\n```\n\n**3. The server→client request times out after `requestTimeout`.**\n\n`McpStreamableServerSession$McpStreamableServerSessionStream.sendRequest`\n(lines 404–412):\n\n```java\nreturn Mono.\u003cMcpSchema.JSONRPCResponse\u003ecreate(sink -\u003e {\n    this.pendingResponses.put(requestId, sink);\n    ...\n    this.transport.sendMessage(jsonrpcRequest, messageId).subscribe(v -\u003e {}, sink::error);\n}).timeout(requestTimeout)                                 // \u003c-- no answer → TimeoutException\n```\n\nBecause `McpServer.sync(...)` defaults `requestTimeout` to 10s (line 945) — and\nhigher if the app raised it — the thread is pinned for that entire window and\nthen logs:\n\n```\nERROR ... HttpServletStreamableServerTransportProvider: Error handling message:\n  java.util.concurrent.TimeoutException: Did not observe any item or terminal\n  signal within 10000ms in 'source(MonoCreate)'\n```\n\n## Steps to reproduce\n\nA stateful streamable `McpServer.sync(...)` on\n`HttpServletStreamableServerTransportProvider` with **no** `rootsChangeConsumer`\nregistered. Endpoint is `/mcp` below.\n\n```bash\n# 1. initialize, declaring roots.listChanged — capture the mcp-session-id from response headers\ncurl -sS -D - -o /dev/null -X POST http://localhost:8080/mcp \\\n  -H 'Content-Type: application/json' \\\n  -H 'Accept: application/json, text/event-stream' \\\n  -d '{\"jsonrpc\":\"2.0\",\"id\":0,\"method\":\"initialize\",\n       \"params\":{\"protocolVersion\":\"2025-11-25\",\n                 \"capabilities\":{\"roots\":{\"listChanged\":true}},\n                 \"clientInfo\":{\"name\":\"roots-repro\",\"version\":\"1.0.0\"}}}'\n\nSID=\u003cmcp-session-id from above\u003e\n\n# 2. complete the handshake\ncurl -sS -X POST http://localhost:8080/mcp \\\n  -H 'Content-Type: application/json' -H 'Accept: application/json, text/event-stream' \\\n  -H \"mcp-session-id: $SID\" \\\n  -d '{\"jsonrpc\":\"2.0\",\"method\":\"notifications/initialized\"}'\n\n# 3. open the listening GET SSE stream (REQUIRED — without it the server fails fast\n#    with \"Stream unavailable for session\" instead of stalling)\ncurl -sS -N http://localhost:8080/mcp -H 'Accept: text/event-stream' \\\n  -H \"mcp-session-id: $SID\" \u0026\n\n# 4. the trigger — this POST hangs for the full requestTimeout, then returns 500\ntime curl -sS -X POST http://localhost:8080/mcp \\\n  -H 'Content-Type: application/json' -H 'Accept: application/json, text/event-stream' \\\n  -H \"mcp-session-id: $SID\" \\\n  -d '{\"jsonrpc\":\"2.0\",\"method\":\"notifications/roots/list_changed\"}'\n```\n\nOn the listening stream from step 3 you will see the server push a\n`{\"method\":\"roots/list\",...}` request; nobody answers it, and step 4 blocks for\n`requestTimeout` seconds.\n\n## Expected behavior\n\n`notifications/roots/list_changed` should be acknowledged (202) promptly. When\nno `rootsChangeConsumer` is registered, the server should **not** send a\n`roots/list` request at all — there is nothing to deliver the result to. This\nmatches the stateless behavior already merged in #835.\n\n## Actual behavior\n\nThe server sends `roots/list`, the servlet thread blocks on it, and after\n`requestTimeout` it fails with the `MonoCreate` `TimeoutException` above. One\nHTTP worker thread is consumed per notification for the full timeout.\n\n## Impact\n\n- One pinned HTTP worker thread per `roots/list_changed`, for up to\n  `requestTimeout`; concurrent clients multiply it and degrade the request pool.\n- Recurring `ERROR`-level log noise.\n- Affects every client that declares `roots.listChanged` and doesn't answer the\n  unsolicited `roots/list` — which is spec-legal client behavior.\n\n## Proposed fix\n\nSkip the round-trip when there is nothing to consume — the stateful analog of\n#835:\n\n- In `asyncRootsListChangedNotificationHandler` (or\n  `prepareNotificationHandlers`), only call `exchange.listRoots()` when a real\n  `rootsChangeConsumer` was registered; otherwise treat the notification as a\n  no-op. Don't substitute a logging consumer that forces a client round-trip\n  purely to log the result.\n\nThis also aligns with the direction of #1003 (SEP-2260, \"require server requests\nto be associated with a client request\") and #1012 / #1053 (deprecate roots),\nwhere an unsolicited server→client `roots/list` triggered by a notification is\nbeing designed out of the spec.\n\n## Related\n\n- **#835** (merged) — same fix for the **stateless** transport\n  (`roots/list_changed` → no-op). This issue asks to extend that to the\n  **stateful** streamable path. Its parent #777 is the stateless \"Missing\n  handler\" symptom.\n- **#1003** (SEP-2260) and **#1012 / #1053** — spec work removing/deprecating\n  unsolicited server→client roots requests. Directional, not a current-SDK fix.\n- **#920** and **#1021** — separate streamable-transport robustness issues\n  (session eviction on write failure; CLOSE-WAIT thread exhaustion). Distinct\n  root causes, mentioned only to disambiguate.\n\n## Workaround\n\nA servlet filter in front of the MCP endpoint that answers\n`notifications/roots/list_changed` with `202 Accepted` and drops it, so it never\nreaches the SDK handler.\n","author":{"url":"https://github.com/mayur9991","@type":"Person","name":"mayur9991"},"datePublished":"2026-07-16T05:29:02.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/1061/java-sdk/issues/1061"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:587f712f-5837-405b-5c09-7b3c4b2298a7
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idDE3E:450CC:17E54A:1FC09D:6A5963A0
html-safe-nonce2fd6083ed466a02340ce4e7339195f63d0b748ff884718fc57d332dbe8355aed
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERTNFOjQ1MENDOjE3RTU0QToxRkMwOUQ6NkE1OTYzQTAiLCJ2aXNpdG9yX2lkIjoiMTU4NTQzNjkxNTEwMDM3ODAxNiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac6bb25bfd0774668dd6a383ba227d1378804404da3a776dd60601c36ef5672392
hovercard-subject-tagissue:4899002699
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/modelcontextprotocol/java-sdk/1061/issue_layout
twitter:imagehttps://opengraph.githubassets.com/93ce13a50a7d4a99200c5c60d4c5eb766be406019a72d685aea615ac51f17364/modelcontextprotocol/java-sdk/issues/1061
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/93ce13a50a7d4a99200c5c60d4c5eb766be406019a72d685aea615ac51f17364/modelcontextprotocol/java-sdk/issues/1061
og:image:altStateful streamable server calls listRoots() unconditionally on roots/list_changed, blocking a servlet thread until requestTimeout when no roots consumer is registered Bug description When a McpAsy...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamemayur9991
hostnamegithub.com
expected-hostnamegithub.com
Nonea540949572872b935b393b36db38922db390ae71c859537d741b8f3eb7e545b5
turbo-cache-controlno-preview
go-importgithub.com/modelcontextprotocol/java-sdk git https://github.com/modelcontextprotocol/java-sdk.git
octolytics-dimension-user_id182288589
octolytics-dimension-user_loginmodelcontextprotocol
octolytics-dimension-repository_id919609219
octolytics-dimension-repository_nwomodelcontextprotocol/java-sdk
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id919609219
octolytics-dimension-repository_network_root_nwomodelcontextprotocol/java-sdk
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release4aa391d605ba491481565840251a4b0fec3f4807
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/modelcontextprotocol/java-sdk/issues/1061#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmodelcontextprotocol%2Fjava-sdk%2Fissues%2F1061
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmodelcontextprotocol%2Fjava-sdk%2Fissues%2F1061
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=modelcontextprotocol%2Fjava-sdk
Reloadhttps://github.com/modelcontextprotocol/java-sdk/issues/1061
Reloadhttps://github.com/modelcontextprotocol/java-sdk/issues/1061
Reloadhttps://github.com/modelcontextprotocol/java-sdk/issues/1061
Please reload this pagehttps://github.com/modelcontextprotocol/java-sdk/issues/1061
modelcontextprotocol https://github.com/modelcontextprotocol
java-sdkhttps://github.com/modelcontextprotocol/java-sdk
Notifications https://github.com/login?return_to=%2Fmodelcontextprotocol%2Fjava-sdk
Fork 979 https://github.com/login?return_to=%2Fmodelcontextprotocol%2Fjava-sdk
Star 3.6k https://github.com/login?return_to=%2Fmodelcontextprotocol%2Fjava-sdk
Code https://github.com/modelcontextprotocol/java-sdk
Issues 131 https://github.com/modelcontextprotocol/java-sdk/issues
Pull requests 146 https://github.com/modelcontextprotocol/java-sdk/pulls
Discussions https://github.com/modelcontextprotocol/java-sdk/discussions
Actions https://github.com/modelcontextprotocol/java-sdk/actions
Projects https://github.com/modelcontextprotocol/java-sdk/projects
Models https://github.com/modelcontextprotocol/java-sdk/models
Security and quality 2 https://github.com/modelcontextprotocol/java-sdk/security
Insights https://github.com/modelcontextprotocol/java-sdk/pulse
Code https://github.com/modelcontextprotocol/java-sdk
Issues https://github.com/modelcontextprotocol/java-sdk/issues
Pull requests https://github.com/modelcontextprotocol/java-sdk/pulls
Discussions https://github.com/modelcontextprotocol/java-sdk/discussions
Actions https://github.com/modelcontextprotocol/java-sdk/actions
Projects https://github.com/modelcontextprotocol/java-sdk/projects
Models https://github.com/modelcontextprotocol/java-sdk/models
Security and quality https://github.com/modelcontextprotocol/java-sdk/security
Insights https://github.com/modelcontextprotocol/java-sdk/pulse
Stateful streamable server calls listRoots() unconditionally on roots/list_changed, blocking a servlet thread until requestTimeout when no roots consumer is registeredhttps://github.com/modelcontextprotocol/java-sdk/issues/1061#top
https://github.com/mayur9991
mayur9991https://github.com/mayur9991
on Jul 16, 2026https://github.com/modelcontextprotocol/java-sdk/issues/1061#issue-4899002699
#835https://github.com/modelcontextprotocol/java-sdk/pull/835
#835https://github.com/modelcontextprotocol/java-sdk/pull/835
#835https://github.com/modelcontextprotocol/java-sdk/pull/835
#835https://github.com/modelcontextprotocol/java-sdk/pull/835
#1003https://github.com/modelcontextprotocol/java-sdk/issues/1003
#1012https://github.com/modelcontextprotocol/java-sdk/issues/1012
#1053https://github.com/modelcontextprotocol/java-sdk/pull/1053
Remove invalid WARN message for missing notification handler in stateless servers #835https://github.com/modelcontextprotocol/java-sdk/pull/835
Missing handler for request type: notifications/initialized #777https://github.com/modelcontextprotocol/java-sdk/issues/777
SEP-2260: Require Server requests to be associated with a Client request #1003https://github.com/modelcontextprotocol/java-sdk/issues/1003
SEP-2577: Deprecate Roots, Sampling, and Logging #1012https://github.com/modelcontextprotocol/java-sdk/issues/1012
Deprecate roots, sampling, and logging APIs #1053https://github.com/modelcontextprotocol/java-sdk/pull/1053
HttpServletStreamableServerTransportProvider orphans sessions on first transient SSE write failure (no grace period) #920https://github.com/modelcontextprotocol/java-sdk/issues/920
[BUG] McpStreamableServerSession does not close server-side socket when client disconnects, causing CLOSE-WAIT leak and thread pool exhaustion #1021https://github.com/modelcontextprotocol/java-sdk/issues/1021
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.