Skip to content

MCP Async Blocking Error #2341

Closed
Closed
@pram

Description

@pram

Bug description
When calling a streaming chat client with MCP tooling enabled a blocking error is reporting.

2025-02-27T08:13:03.481-05:00 ERROR 1547148 --- [mcp-client] [or-http-epoll-4] o.s.ai.chat.model.MessageAggregator      : Aggregation Error

java.lang.IllegalStateException: block()/blockFirst()/blockLast() are blocking, which is not supported in thread reactor-http-epoll-4
	at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:87) ~[reactor-core-3.7.3.jar!/:3.7.3]
	at reactor.core.publisher.Mono.block(Mono.java:1779) ~[reactor-core-3.7.3.jar!/:3.7.3]
	at org.springframework.ai.mcp.AsyncMcpToolCallback.call(AsyncMcpToolCallback.java:110) ~[spring-ai-mcp-1.0.0-SNAPSHOT.jar!/:1.0.0-SNAPSHOT]
	at org.springframework.ai.tool.ToolCallback.call(ToolCallback.java:59) ~[spring-ai-core-1.0.0-SNAPSHOT.jar!/:1.0.0-SNAPSHOT]
	at org.springframework.ai.model.tool.DefaultToolCallingManager.executeToolCall(DefaultToolCallingManager.java:226) ~[spring-ai-core-1.0.0-SNAPSHOT.jar!/:1.0.0-SNAPSHOT]

Environment

Java - OpenJDK 64-Bit Server VM Temurin-21.0.4+7 (build 21.0.4+7-LTS, mixed mode, sharing)
Spring AI - 1.0.0-SNAPSHOT
MCP - 0.7.0-SNAPSHOT
Ollama - ollama version is 0.5.12
model - llama3.2:latest
OS - Ubuntu 24.04.2 LTS

Steps to reproduce
Check out the project https://github.com/pram/mcp-async-example

Start the server

cd mcp-async-example
./mvnw clean package
cd mcp-server/target
java -jar mcp-server-0.0.1-SNAPSHOT.jar

Open another window

cd mcp-async-example/mcp-client/target

There are three modes of operation

java -jar mcp-client-0.0.1-SNAPSHOT.jar --app.runner.mode=mcp - Uses MCP Client tooling to call the tool

Output:

Content: TextContent[audience=null, priority=null, type=text, text="Hello Mr Client MCP me old mucker"]

java -jar mcp-client-0.0.1-SNAPSHOT.jar --app.runner.mode=standard - Uses the sync Spring AI chat client

Output:

The function `calculateHello` takes a name as an input and returns a greeting message. Since the input is "James", the output is:

"Hello James, me old mucker!"

java -jar mcp-client-0.0.1-SNAPSHOT.jar --app.runner.mode=stream

Output:

The blocking error as shown above

Expected behavior

I would expect output of the form

Hello
James,
me
old
mucker!

Minimal Complete Reproducible example
https://github.com/pram/mcp-async-example

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions