Description
Bug description
I can see the tool call request was sent in the log below with request id '7391134d-2'. But when response came back, it could not find the id. ConcurrentHashMap<Object, MonoSink<McpSchema.JSONRPCResponse>> pendingResponses
is expected to be thread safe, but it seems to show that it can NOT see the values put by other thread(which is strange)?
2025-05-19 13:25:33.353 [boundedElastic-1] INFO McpClientSession - Sending request: (method: tools/call, name: echo, requestId: 7391134d-1) -
2025-05-19 13:25:33.353 [boundedElastic-4] INFO McpClientSession - Sending request: (method: tools/call, name: get_current_weather, requestId: 7391134d-2) -
...
2025-05-19 13:25:33.365 [HttpClient-1-Worker-2] WARN McpClientSession - Unexpected response for unknown id 7391134d-2 -
I inserted logging code here to print out the first two logs.
The third warning was from here.
Environment
Please provide as many details as possible: Spring MCP version, Java version, which vector store you use if any, etc
java version: 21.0.3-tem
spring-ai-mcp: 1.0.0-M8
mcp-spring-webflux: 0.8.1
mcp: 0.9.0
Steps to reproduce
Flux.fromIterable(functionCalls)
// .parallel(1) // there is no problem with this sequential call.
.parallel(3)
.runOn(Schedulers.boundedElastic())
.map { functionCall =>
mcpClient.call(functionCall)
}.sequential()
.collectList()
Expected behavior
Expect single McpClient can handle multiple tool calls simultaneously. But at the moment with parallel calls, id in the pendingResponses can NOT be found sometimes.
Minimal Complete Reproducible example
Will require some time to prepare. If the issue can be located without it, that would be great. Thanks.