Fix httpRequestCustomizer usage in HttpClientStreamableHttpTransport

- Closes #458

Signed-off-by: Daniel Garnier-Moiroux <git@garnier.wf>
This commit is contained in:
Daniel Garnier-Moiroux 2025-08-07 09:32:40 +02:00 • committed by Christian Tzolov
commit 032716546c
3 changed files with 4 additions and 4 deletions

View file

@ -400,7 +400,7 @@ public class HttpClientStreamableHttpTransport implements McpClientTransport {
.header("Cache-Control", "no-cache")
.header(HttpHeaders.PROTOCOL_VERSION, MCP_PROTOCOL_VERSION)
.POST(HttpRequest.BodyPublishers.ofString(jsonBody));
return Mono.from(this.httpRequestCustomizer.customize(builder, "GET", uri, jsonBody));
return Mono.from(this.httpRequestCustomizer.customize(builder, "POST", uri, jsonBody));
}).flatMapMany(requestBuilder -> Flux.<ResponseEvent>create(responseEventSink -> {
// Create the async request with proper body subscriber selection

View file

@ -84,7 +84,7 @@ public class HttpClientStreamableHttpTransportEmptyJsonResponseTest {
StepVerifier.create(transport.sendMessage(testMessage)).verifyComplete();
// Verify the customizer was called
verify(mockRequestCustomizer, atLeastOnce()).customize(any(), eq("GET"), eq(uri), eq(
verify(mockRequestCustomizer, atLeastOnce()).customize(any(), eq("POST"), eq(uri), eq(
"{\"jsonrpc\":\"2.0\",\"method\":\"initialize\",\"id\":\"test-id\",\"params\":{\"protocolVersion\":\"2025-03-26\",\"capabilities\":{\"roots\":{\"listChanged\":true}},\"clientInfo\":{\"name\":\"Spring AI MCP Client\",\"version\":\"0.3.1\"}}}"));
}

View file

@ -80,7 +80,7 @@ class HttpClientStreamableHttpTransportTest {
StepVerifier.create(t.sendMessage(testMessage)).verifyComplete();
// Verify the customizer was called
verify(mockRequestCustomizer, atLeastOnce()).customize(any(), eq("GET"), eq(uri), eq(
verify(mockRequestCustomizer, atLeastOnce()).customize(any(), eq("POST"), eq(uri), eq(
"{\"jsonrpc\":\"2.0\",\"method\":\"initialize\",\"id\":\"test-id\",\"params\":{\"protocolVersion\":\"2025-03-26\",\"capabilities\":{\"roots\":{\"listChanged\":true}},\"clientInfo\":{\"name\":\"Spring AI MCP Client\",\"version\":\"0.3.1\"}}}"));
});
}
@ -107,7 +107,7 @@ class HttpClientStreamableHttpTransportTest {
StepVerifier.create(t.sendMessage(testMessage)).verifyComplete();
// Verify the customizer was called
verify(mockRequestCustomizer, atLeastOnce()).customize(any(), eq("GET"), eq(uri), eq(
verify(mockRequestCustomizer, atLeastOnce()).customize(any(), eq("POST"), eq(uri), eq(
"{\"jsonrpc\":\"2.0\",\"method\":\"initialize\",\"id\":\"test-id\",\"params\":{\"protocolVersion\":\"2025-03-26\",\"capabilities\":{\"roots\":{\"listChanged\":true}},\"clientInfo\":{\"name\":\"Spring AI MCP Client\",\"version\":\"0.3.1\"}}}"));
});
}