-
Notifications
You must be signed in to change notification settings - Fork 833
Description
Bug Description
All Servlet-based transports in the SDK (e.g., HttpServletStreamableServerTransportProvider, HttpServletSseServerTransportProvider, HttpServletStatelessServerTransport) call .block() on the Tomcat request thread when processing incoming HTTP requests.
Although AsyncContext is used to hold connections for SSE/streaming, the Tomcat thread remains parked until tool execution completes. As a result, the reactive/async architecture does not provide any real thread efficiency: the request thread stays blocked for the entire duration of the tool call.
With SyncToolSpecification and immediateExecution=false, the tool handler is executed on a separate thread (typically from the boundedElastic pool). This prevents blocking logic from running on the Tomcat thread itself, but the request thread still remains blocked waiting for completion.
With AsyncToolSpecification(via McpAsyncServer), handlers are expected to return fully asynchronous operations (e.g., non-blocking I/O). However, because the transport calls .block(), the HTTP request handling remains synchronous. The handler is not automatically scheduled on another thread unless the developer explicitly does so.
As a result, both SyncToolSpecification and AsyncToolSpecification ultimately block the Tomcat request thread until completion.
I’m not sure if this behavior is intentional. Based on the design of McpAsyncServer, I would expect the transport layer to release the Tomcat thread immediately and allow the reactive pipeline to complete asynchronously. (AsyncContext + subscribe).