Skip to content

Improve handling non-compliant Notification responses  #586

@hbsjz-swl

Description

@hbsjz-swl

Bug description
Line 505 of io.modelcontextprotocol.client.transport.HttpClientStreamableHttpTransport. If the result of responseEvent conversion is as follows: AggregateResponseEvent[responseInfo=jdk.internal.net.http.ResponseInfoImpl@67d15067, data=], the obtained data is an empty string. The Utils.hasText method does not recognize empty strings, resulting in an error:

io.modelcontextprotocol.spec.McpTransportException: Error deserializing JSON-RPC message: AggregateResponseEvent[responseInfo=jdk.internal.net.http.ResponseInfoImpl@5e431139, data=]
	at io.modelcontextprotocol.client.transport.HttpClientStreamableHttpTransport.lambda$sendMessage$27(HttpClientStreamableHttpTransport.java:515) ~[mcp-core-0.13.1.jar:0.13.1]
	at reactor.core.publisher.FluxFlatMap$FlatMapMain.onNext(FluxFlatMap.java:388) ~[reactor-core-3.7.9.jar:3.7.9]
	at reactor.core.publisher.MonoFlatMapMany$FlatMapManyInner.onNext(MonoFlatMapMany.java:251) ~[reactor-core-3.7.9.jar:3.7.9]
	at reactor.core.publisher.FluxCreate$BufferAsyncSink.drain(FluxCreate.java:880) ~[reactor-core-3.7.9.jar:3.7.9]
	at reactor.core.publisher.FluxCreate$BufferAsyncSink.next(FluxCreate.java:805) ~[reactor-core-3.7.9.jar:3.7.9]
	at reactor.core.publisher.FluxCreate$SerializedFluxSink.next(FluxCreate.java:163) ~[reactor-core-3.7.9.jar:3.7.9]
	at io.modelcontextprotocol.client.transport.ResponseSubscribers$AggregateSubscriber.hookOnComplete(ResponseSubscribers.java:263) ~[mcp-core-0.13.1.jar:0.13.1]
	at reactor.core.publisher.BaseSubscriber.onComplete(BaseSubscriber.java:197) ~[reactor-core-3.7.9.jar:3.7.9]

Environment
Mcp Client: SpringBoot 3.5.5 SpringAI 1.1.0-M2
Mcp Java SDK: 0.13.1
Mcp Server: Python FastMCP

Expected behavior
Hopefully, the Utils.hasText() method can be used to recognize empty strings and return Mono.empty() to avoid errors.

Image

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions