Skip to content

Commit 054e524

Browse files
committed
BE: Handle Flux response bodies in MCP tool call results
1 parent bcb9d18 commit 054e524

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

api/src/main/java/io/kafbat/ui/service/mcp/McpSpecificationGenerator.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,12 @@ private Mono<CallToolResult> toCallResult(Object result) {
9393
private Mono<CallToolResult> reponseToCallResult(ResponseEntity<?> response) {
9494
HttpStatusCode statusCode = response.getStatusCode();
9595
if (statusCode.is2xxSuccessful() || statusCode.is1xxInformational()) {
96-
return Mono.just(this.callToolResult(response.getBody()));
96+
Object body = response.getBody();
97+
// Handle Flux response bodies by collecting them into a list
98+
if (body instanceof Flux<?> flux) {
99+
return flux.collectList().map(this::callToolResult);
100+
}
101+
return Mono.just(this.callToolResult(body));
97102
} else {
98103
try {
99104
return Mono.just(toErrorResult(objectMapper.writeValueAsString(response.getBody())));

0 commit comments

Comments
 (0)