Servlet transports block Tomcat thread
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 48/100
Direção de pesquisa
Comece com HttpServletStreamableServerTransportProvider, HttpServletSseServerTransportProvider e HttpServletStatelessServerTransport, rastreando onde as requisições recebidas chamam .block() e como AsyncContext é usado. Compare os caminhos de SyncToolSpecification e AsyncToolSpecification e, em seguida, verifique se as threads das requisições são liberadas enquanto a operação reativa continua e é concluída com sucesso.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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
- Linguagem predominante
- Java
- Estrelas
- 3.7k
- Forks
- 1.1k
- Merge médio
- 1d 15h
- PRs com merge (30d)
- 9
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de modelcontextprotocol/java-sdk
-
area/transport bug P2
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
modelcontextprotocol/java-sdk#1136 ·
-
area/client bug P2
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
modelcontextprotocol/java-sdk#1124 · 1 comentário ·
-
ServerCapabilities.logging is added unconditionally, overriding the caller's explicit capabilities Abertabug P2 ready for work
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
modelcontextprotocol/java-sdk#1086 · 1 comentário ·
-
enhancement good first issue P3
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
modelcontextprotocol/java-sdk#1067 ·
-
bug P2 ready for work
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 74/100
modelcontextprotocol/java-sdk#898 · 1 comentário ·
Todas as issues de modelcontextprotocol/java-sdk
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
-
bug needs triage
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 94/100
objectionary/hone-maven-plugin#1061 ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
spring-projects/spring-modulith#1895 ·