Servlet transports block Tomcat thread
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 48/100
Línea de trabajo
Comienza con HttpServletStreamableServerTransportProvider, HttpServletSseServerTransportProvider y HttpServletStatelessServerTransport, rastreando dónde las solicitudes entrantes llaman a .block() y cómo se utiliza AsyncContext. Compara las rutas de SyncToolSpecification y AsyncToolSpecification y, después, verifica que los hilos de las solicitudes se liberan mientras la operación reactiva continúa y se completa correctamente.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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).
@pratik2294
- Lenguaje dominante
- Java
- Estrellas
- 3.7k
- Forks
- 1.1k
- Merge medio
- 1 d 15 h
- PR fusionados (30 d)
- 9
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de modelcontextprotocol/java-sdk
-
area/transport bug P2
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
modelcontextprotocol/java-sdk#1136 ·
-
area/client bug P2
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
modelcontextprotocol/java-sdk#1124 · 1 comentario ·
-
ServerCapabilities.logging is added unconditionally, overriding the caller's explicit capabilities Abiertobug P2 ready for work
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
modelcontextprotocol/java-sdk#1086 · 1 comentario ·
-
enhancement good first issue P3
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
modelcontextprotocol/java-sdk#1067 ·
-
bug P2 ready for work
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
modelcontextprotocol/java-sdk#898 · 1 comentario ·
Todos los issues de modelcontextprotocol/java-sdk
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
-
bug needs triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 94/100
objectionary/hone-maven-plugin#1061 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
spring-projects/spring-modulith#1895 ·