Skip to content

Commit 0327165

Browse files
Kehrlanntzolov
authored andcommitted
Fix httpRequestCustomizer usage in HttpClientStreamableHttpTransport
- Closes #458 Signed-off-by: Daniel Garnier-Moiroux <[email protected]>
1 parent 110a8d1 commit 0327165

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

mcp/src/main/java/io/modelcontextprotocol/client/transport/HttpClientStreamableHttpTransport.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ public Mono<Void> sendMessage(McpSchema.JSONRPCMessage sentMessage) {
400400
.header("Cache-Control", "no-cache")
401401
.header(HttpHeaders.PROTOCOL_VERSION, MCP_PROTOCOL_VERSION)
402402
.POST(HttpRequest.BodyPublishers.ofString(jsonBody));
403-
return Mono.from(this.httpRequestCustomizer.customize(builder, "GET", uri, jsonBody));
403+
return Mono.from(this.httpRequestCustomizer.customize(builder, "POST", uri, jsonBody));
404404
}).flatMapMany(requestBuilder -> Flux.<ResponseEvent>create(responseEventSink -> {
405405

406406
// Create the async request with proper body subscriber selection

mcp/src/test/java/io/modelcontextprotocol/client/transport/HttpClientStreamableHttpTransportEmptyJsonResponseTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ void testNotificationInitialized() throws URISyntaxException {
8484
StepVerifier.create(transport.sendMessage(testMessage)).verifyComplete();
8585

8686
// Verify the customizer was called
87-
verify(mockRequestCustomizer, atLeastOnce()).customize(any(), eq("GET"), eq(uri), eq(
87+
verify(mockRequestCustomizer, atLeastOnce()).customize(any(), eq("POST"), eq(uri), eq(
8888
"{\"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\"}}}"));
8989

9090
}

mcp/src/test/java/io/modelcontextprotocol/client/transport/HttpClientStreamableHttpTransportTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ void testRequestCustomizer() throws URISyntaxException {
8080
StepVerifier.create(t.sendMessage(testMessage)).verifyComplete();
8181

8282
// Verify the customizer was called
83-
verify(mockRequestCustomizer, atLeastOnce()).customize(any(), eq("GET"), eq(uri), eq(
83+
verify(mockRequestCustomizer, atLeastOnce()).customize(any(), eq("POST"), eq(uri), eq(
8484
"{\"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\"}}}"));
8585
});
8686
}
@@ -107,7 +107,7 @@ void testAsyncRequestCustomizer() throws URISyntaxException {
107107
StepVerifier.create(t.sendMessage(testMessage)).verifyComplete();
108108

109109
// Verify the customizer was called
110-
verify(mockRequestCustomizer, atLeastOnce()).customize(any(), eq("GET"), eq(uri), eq(
110+
verify(mockRequestCustomizer, atLeastOnce()).customize(any(), eq("POST"), eq(uri), eq(
111111
"{\"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\"}}}"));
112112
});
113113
}

0 commit comments

Comments
 (0)