You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Introduce a unified Virtual Threads friendly API #778
The MCP Java SDK team and myself would like to acknowledge the strong desire to evolve the MCP Java SDK to leverage Virtual Threads as a key building block.
This issue is about introducing a new unified Virtual Threads friendly API with the following characteristics:
Natively designed for Virtual Threads both in terms of idiomatic API and implementation
Designed with Structured Concurrency in mind but SC will not be required
Introduce a new way to expose streaming based features
Extensible design that should allow changing the implementation
No dependency on Reactor or Reactive Streams
No Sync or Async prefix
Technically could run on Java 21+ but Java 25+ (latest LTS version without the thread pinning issue) will be the recommended baseline
The Sync and Async API and implementation would remain close to what they are today for now, to not break existing use cases and remain fully compatible with Java 17+, while the new unified API would potentially mean a changed module hierarchy where Project Reactor is not a required dependency.
A prototype of this unified Virtual Threads friendly API, using the Sync API as the starting point but achieving the characteristics shared above, will be shared in this issue or via a related PR and discussed with the community to gather feedback and hopefully reach a consensus.
Reacted by James Ward, Suresh, Spencer Gibb, Julio Gómez Díaz, Josh Long, Alexei Brinza, Christian Tzolov, Olivier Lamy, Sam Brannen, Björn and 10 more
We've released stream-source 0.8.0 (announcement). It's a small library for streaming data in imperative style on virtual threads. A consumer reads items in a plain loop, and a producer can run on its own thread. Backpressure comes from blocking, and cancellation comes from closing the source. It covers the streaming part that the Virtual Threads friendly API in this issue needs.
To see how far that goes, I drafted a demo flavour of the MCP Java SDK built on it: stream-source-mcp
It has one variant of each type, with no Sync or Async prefix. Both the API and the implementation are blocking, and it doesn't depend on Reactor or Reactive Streams. A call returns its result and a failure is an exception. Streams are a Source you read in a loop. For example, a tool that reports progress before it answers:
try (Source<Notification> changes = client.listen().open()) {
while (changes.receiveNext()) {
Notificationchange = changes.next();
// refresh the list of tools
}
}
With a single blocking variant, the SDK becomes much simpler, both to use and to maintain.
It's a test-only proof of concept, not a usable implementation. It follows the shape of the stateless API for the 2026-07-28 revision, but it covers only tools/list, tools/call and subscriptions/listen, and it has no network transport and no JSON. DESIGN.md and FAQ.md in the repository explain the choices.
Like stream-source, it has a Java 17 baseline. With virtual threads, we recommend at least Java 24 to avoid pinning (JEP 491).
We plan to make this a breaking change in MCP Java SDK 3.0, which would offer only the stream-source based API in place of the Sync and Async variants.
Feedback is very welcome, either here or as issues on that repository.
Reacted by frederikb, Suresh, Sébastien Deleuze and Mandeep Gill
Activity
KlemenDEV commentedon May 12, 2026
Looking forward to this!
chemicL commentedon Dec 1, 2026
We've released stream-source 0.8.0 (announcement). It's a small library for streaming data in imperative style on virtual threads. A consumer reads items in a plain loop, and a producer can run on its own thread. Backpressure comes from blocking, and cancellation comes from closing the source. It covers the streaming part that the Virtual Threads friendly API in this issue needs.
To see how far that goes, I drafted a demo flavour of the MCP Java SDK built on it: stream-source-mcp
It has one variant of each type, with no
SyncorAsyncprefix. Both the API and the implementation are blocking, and it doesn't depend on Reactor or Reactive Streams. A call returns its result and a failure is an exception. Streams are aSourceyou read in a loop. For example, a tool that reports progress before it answers:And a client listening for changes:
With a single blocking variant, the SDK becomes much simpler, both to use and to maintain.
It's a test-only proof of concept, not a usable implementation. It follows the shape of the stateless API for the 2026-07-28 revision, but it covers only
tools/list,tools/callandsubscriptions/listen, and it has no network transport and no JSON.DESIGN.mdandFAQ.mdin the repository explain the choices.Like stream-source, it has a Java 17 baseline. With virtual threads, we recommend at least Java 24 to avoid pinning (JEP 491).
We plan to make this a breaking change in MCP Java SDK 3.0, which would offer only the stream-source based API in place of the Sync and Async variants.
Feedback is very welcome, either here or as issues on that repository.