Skip to content

Commit 98eb323

Browse files
committed
Rename *HttpRequestCustomizer -> *HttpClientRequestCustomizer
Signed-off-by: Daniel Garnier-Moiroux <[email protected]>
1 parent c2ed1b7 commit 98eb323

13 files changed

+69
-67
lines changed

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

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
import com.fasterxml.jackson.core.type.TypeReference;
2323
import com.fasterxml.jackson.databind.ObjectMapper;
2424

25-
import io.modelcontextprotocol.client.transport.customizer.McpAsyncHttpRequestCustomizer;
26-
import io.modelcontextprotocol.client.transport.customizer.McpSyncHttpRequestCustomizer;
25+
import io.modelcontextprotocol.client.transport.customizer.McpAsyncHttpClientRequestCustomizer;
26+
import io.modelcontextprotocol.client.transport.customizer.McpSyncHttpClientRequestCustomizer;
2727
import io.modelcontextprotocol.client.transport.ResponseSubscribers.ResponseEvent;
2828
import io.modelcontextprotocol.common.McpTransportContext;
2929
import io.modelcontextprotocol.spec.McpClientTransport;
@@ -115,7 +115,7 @@ public class HttpClientSseClientTransport implements McpClientTransport {
115115
/**
116116
* Customizer to modify requests before they are executed.
117117
*/
118-
private final McpAsyncHttpRequestCustomizer httpRequestCustomizer;
118+
private final McpAsyncHttpClientRequestCustomizer httpRequestCustomizer;
119119

120120
/**
121121
* Creates a new transport instance with default HTTP client and object mapper.
@@ -189,7 +189,7 @@ public HttpClientSseClientTransport(HttpClient.Builder clientBuilder, HttpReques
189189
@Deprecated(forRemoval = true)
190190
HttpClientSseClientTransport(HttpClient httpClient, HttpRequest.Builder requestBuilder, String baseUri,
191191
String sseEndpoint, ObjectMapper objectMapper) {
192-
this(httpClient, requestBuilder, baseUri, sseEndpoint, objectMapper, McpAsyncHttpRequestCustomizer.NOOP);
192+
this(httpClient, requestBuilder, baseUri, sseEndpoint, objectMapper, McpAsyncHttpClientRequestCustomizer.NOOP);
193193
}
194194

195195
/**
@@ -205,7 +205,7 @@ public HttpClientSseClientTransport(HttpClient.Builder clientBuilder, HttpReques
205205
* @throws IllegalArgumentException if objectMapper, clientBuilder, or headers is null
206206
*/
207207
HttpClientSseClientTransport(HttpClient httpClient, HttpRequest.Builder requestBuilder, String baseUri,
208-
String sseEndpoint, ObjectMapper objectMapper, McpAsyncHttpRequestCustomizer httpRequestCustomizer) {
208+
String sseEndpoint, ObjectMapper objectMapper, McpAsyncHttpClientRequestCustomizer httpRequestCustomizer) {
209209
Assert.notNull(objectMapper, "ObjectMapper must not be null");
210210
Assert.hasText(baseUri, "baseUri must not be empty");
211211
Assert.hasText(sseEndpoint, "sseEndpoint must not be empty");
@@ -249,7 +249,7 @@ public static class Builder {
249249

250250
private HttpRequest.Builder requestBuilder = HttpRequest.newBuilder();
251251

252-
private McpAsyncHttpRequestCustomizer httpRequestCustomizer = McpAsyncHttpRequestCustomizer.NOOP;
252+
private McpAsyncHttpClientRequestCustomizer httpRequestCustomizer = McpAsyncHttpClientRequestCustomizer.NOOP;
253253

254254
private Duration connectTimeout = Duration.ofSeconds(10);
255255

@@ -355,16 +355,17 @@ public Builder objectMapper(ObjectMapper objectMapper) {
355355
* executing them.
356356
* <p>
357357
* This overrides the customizer from
358-
* {@link #asyncHttpRequestCustomizer(McpAsyncHttpRequestCustomizer)}.
358+
* {@link #asyncHttpRequestCustomizer(McpAsyncHttpClientRequestCustomizer)}.
359359
* <p>
360-
* Do NOT use a blocking {@link McpSyncHttpRequestCustomizer} in a non-blocking
361-
* context. Use {@link #asyncHttpRequestCustomizer(McpAsyncHttpRequestCustomizer)}
360+
* Do NOT use a blocking {@link McpSyncHttpClientRequestCustomizer} in a
361+
* non-blocking context. Use
362+
* {@link #asyncHttpRequestCustomizer(McpAsyncHttpClientRequestCustomizer)}
362363
* instead.
363364
* @param syncHttpRequestCustomizer the request customizer
364365
* @return this builder
365366
*/
366-
public Builder httpRequestCustomizer(McpSyncHttpRequestCustomizer syncHttpRequestCustomizer) {
367-
this.httpRequestCustomizer = McpAsyncHttpRequestCustomizer.fromSync(syncHttpRequestCustomizer);
367+
public Builder httpRequestCustomizer(McpSyncHttpClientRequestCustomizer syncHttpRequestCustomizer) {
368+
this.httpRequestCustomizer = McpAsyncHttpClientRequestCustomizer.fromSync(syncHttpRequestCustomizer);
368369
return this;
369370
}
370371

@@ -373,13 +374,13 @@ public Builder httpRequestCustomizer(McpSyncHttpRequestCustomizer syncHttpReques
373374
* executing them.
374375
* <p>
375376
* This overrides the customizer from
376-
* {@link #httpRequestCustomizer(McpSyncHttpRequestCustomizer)}.
377+
* {@link #httpRequestCustomizer(McpSyncHttpClientRequestCustomizer)}.
377378
* <p>
378379
* Do NOT use a blocking implementation in a non-blocking context.
379380
* @param asyncHttpRequestCustomizer the request customizer
380381
* @return this builder
381382
*/
382-
public Builder asyncHttpRequestCustomizer(McpAsyncHttpRequestCustomizer asyncHttpRequestCustomizer) {
383+
public Builder asyncHttpRequestCustomizer(McpAsyncHttpClientRequestCustomizer asyncHttpRequestCustomizer) {
383384
this.httpRequestCustomizer = asyncHttpRequestCustomizer;
384385
return this;
385386
}

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

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
import com.fasterxml.jackson.core.type.TypeReference;
2626
import com.fasterxml.jackson.databind.ObjectMapper;
2727

28-
import io.modelcontextprotocol.client.transport.customizer.McpAsyncHttpRequestCustomizer;
29-
import io.modelcontextprotocol.client.transport.customizer.McpSyncHttpRequestCustomizer;
28+
import io.modelcontextprotocol.client.transport.customizer.McpAsyncHttpClientRequestCustomizer;
29+
import io.modelcontextprotocol.client.transport.customizer.McpSyncHttpClientRequestCustomizer;
3030
import io.modelcontextprotocol.client.transport.ResponseSubscribers.ResponseEvent;
3131
import io.modelcontextprotocol.common.McpTransportContext;
3232
import io.modelcontextprotocol.spec.DefaultMcpTransportSession;
@@ -116,7 +116,7 @@ public class HttpClientStreamableHttpTransport implements McpClientTransport {
116116

117117
private final boolean resumableStreams;
118118

119-
private final McpAsyncHttpRequestCustomizer httpRequestCustomizer;
119+
private final McpAsyncHttpClientRequestCustomizer httpRequestCustomizer;
120120

121121
private final AtomicReference<DefaultMcpTransportSession> activeSession = new AtomicReference<>();
122122

@@ -126,7 +126,7 @@ public class HttpClientStreamableHttpTransport implements McpClientTransport {
126126

127127
private HttpClientStreamableHttpTransport(ObjectMapper objectMapper, HttpClient httpClient,
128128
HttpRequest.Builder requestBuilder, String baseUri, String endpoint, boolean resumableStreams,
129-
boolean openConnectionOnStartup, McpAsyncHttpRequestCustomizer httpRequestCustomizer) {
129+
boolean openConnectionOnStartup, McpAsyncHttpClientRequestCustomizer httpRequestCustomizer) {
130130
this.objectMapper = objectMapper;
131131
this.httpClient = httpClient;
132132
this.requestBuilder = requestBuilder;
@@ -605,7 +605,7 @@ public static class Builder {
605605

606606
private HttpRequest.Builder requestBuilder = HttpRequest.newBuilder();
607607

608-
private McpAsyncHttpRequestCustomizer httpRequestCustomizer = McpAsyncHttpRequestCustomizer.NOOP;
608+
private McpAsyncHttpClientRequestCustomizer httpRequestCustomizer = McpAsyncHttpClientRequestCustomizer.NOOP;
609609

610610
private Duration connectTimeout = Duration.ofSeconds(10);
611611

@@ -716,16 +716,17 @@ public Builder openConnectionOnStartup(boolean openConnectionOnStartup) {
716716
* executing them.
717717
* <p>
718718
* This overrides the customizer from
719-
* {@link #asyncHttpRequestCustomizer(McpAsyncHttpRequestCustomizer)}.
719+
* {@link #asyncHttpRequestCustomizer(McpAsyncHttpClientRequestCustomizer)}.
720720
* <p>
721-
* Do NOT use a blocking {@link McpSyncHttpRequestCustomizer} in a non-blocking
722-
* context. Use {@link #asyncHttpRequestCustomizer(McpAsyncHttpRequestCustomizer)}
721+
* Do NOT use a blocking {@link McpSyncHttpClientRequestCustomizer} in a
722+
* non-blocking context. Use
723+
* {@link #asyncHttpRequestCustomizer(McpAsyncHttpClientRequestCustomizer)}
723724
* instead.
724725
* @param syncHttpRequestCustomizer the request customizer
725726
* @return this builder
726727
*/
727-
public Builder httpRequestCustomizer(McpSyncHttpRequestCustomizer syncHttpRequestCustomizer) {
728-
this.httpRequestCustomizer = McpAsyncHttpRequestCustomizer.fromSync(syncHttpRequestCustomizer);
728+
public Builder httpRequestCustomizer(McpSyncHttpClientRequestCustomizer syncHttpRequestCustomizer) {
729+
this.httpRequestCustomizer = McpAsyncHttpClientRequestCustomizer.fromSync(syncHttpRequestCustomizer);
729730
return this;
730731
}
731732

@@ -734,13 +735,13 @@ public Builder httpRequestCustomizer(McpSyncHttpRequestCustomizer syncHttpReques
734735
* executing them.
735736
* <p>
736737
* This overrides the customizer from
737-
* {@link #httpRequestCustomizer(McpSyncHttpRequestCustomizer)}.
738+
* {@link #httpRequestCustomizer(McpSyncHttpClientRequestCustomizer)}.
738739
* <p>
739740
* Do NOT use a blocking implementation in a non-blocking context.
740741
* @param asyncHttpRequestCustomizer the request customizer
741742
* @return this builder
742743
*/
743-
public Builder asyncHttpRequestCustomizer(McpAsyncHttpRequestCustomizer asyncHttpRequestCustomizer) {
744+
public Builder asyncHttpRequestCustomizer(McpAsyncHttpClientRequestCustomizer asyncHttpRequestCustomizer) {
744745
this.httpRequestCustomizer = asyncHttpRequestCustomizer;
745746
return this;
746747
}
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@
1515
import reactor.core.publisher.Mono;
1616

1717
/**
18-
* Composable {@link McpAsyncHttpRequestCustomizer} that applies multiple customizers, in
19-
* order.
18+
* Composable {@link McpAsyncHttpClientRequestCustomizer} that applies multiple
19+
* customizers, in order.
2020
*
2121
* @author Daniel Garnier-Moiroux
2222
*/
23-
public class DelegatingMcpAsyncHttpRequestCustomizer implements McpAsyncHttpRequestCustomizer {
23+
public class DelegatingMcpAsyncHttpClientRequestCustomizer implements McpAsyncHttpClientRequestCustomizer {
2424

25-
private final List<McpAsyncHttpRequestCustomizer> customizers;
25+
private final List<McpAsyncHttpClientRequestCustomizer> customizers;
2626

27-
public DelegatingMcpAsyncHttpRequestCustomizer(List<McpAsyncHttpRequestCustomizer> customizers) {
27+
public DelegatingMcpAsyncHttpClientRequestCustomizer(List<McpAsyncHttpClientRequestCustomizer> customizers) {
2828
Assert.notNull(customizers, "Customizers must not be null");
2929
this.customizers = customizers;
3030
}
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@
1212
import io.modelcontextprotocol.util.Assert;
1313

1414
/**
15-
* Composable {@link McpSyncHttpRequestCustomizer} that applies multiple customizers, in
16-
* order.
15+
* Composable {@link McpSyncHttpClientRequestCustomizer} that applies multiple
16+
* customizers, in order.
1717
*
1818
* @author Daniel Garnier-Moiroux
1919
*/
20-
public class DelegatingMcpSyncHttpRequestCustomizer implements McpSyncHttpRequestCustomizer {
20+
public class DelegatingMcpSyncHttpClientRequestCustomizer implements McpSyncHttpClientRequestCustomizer {
2121

22-
private final List<McpSyncHttpRequestCustomizer> delegates;
22+
private final List<McpSyncHttpClientRequestCustomizer> delegates;
2323

24-
public DelegatingMcpSyncHttpRequestCustomizer(List<McpSyncHttpRequestCustomizer> customizers) {
24+
public DelegatingMcpSyncHttpClientRequestCustomizer(List<McpSyncHttpClientRequestCustomizer> customizers) {
2525
Assert.notNull(customizers, "Customizers must not be null");
2626
this.delegates = customizers;
2727
}

mcp/src/main/java/io/modelcontextprotocol/client/transport/customizer/McpAsyncHttpRequestCustomizer.java renamed to mcp/src/main/java/io/modelcontextprotocol/client/transport/customizer/McpAsyncHttpClientRequestCustomizer.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,27 @@
2222
*
2323
* @author Daniel Garnier-Moiroux
2424
*/
25-
public interface McpAsyncHttpRequestCustomizer {
25+
public interface McpAsyncHttpClientRequestCustomizer {
2626

2727
Publisher<HttpRequest.Builder> customize(HttpRequest.Builder builder, String method, URI endpoint,
2828
@Nullable String body, McpTransportContext context);
2929

30-
McpAsyncHttpRequestCustomizer NOOP = new Noop();
30+
McpAsyncHttpClientRequestCustomizer NOOP = new Noop();
3131

3232
/**
3333
* Wrap a sync implementation in an async wrapper.
3434
* <p>
3535
* Do NOT wrap a blocking implementation for use in a non-blocking context. For a
3636
* blocking implementation, consider using {@link Schedulers#boundedElastic()}.
3737
*/
38-
static McpAsyncHttpRequestCustomizer fromSync(McpSyncHttpRequestCustomizer customizer) {
38+
static McpAsyncHttpClientRequestCustomizer fromSync(McpSyncHttpClientRequestCustomizer customizer) {
3939
return (builder, method, uri, body, context) -> Mono.fromSupplier(() -> {
4040
customizer.customize(builder, method, uri, body, context);
4141
return builder;
4242
});
4343
}
4444

45-
class Noop implements McpAsyncHttpRequestCustomizer {
45+
class Noop implements McpAsyncHttpClientRequestCustomizer {
4646

4747
@Override
4848
public Publisher<HttpRequest.Builder> customize(HttpRequest.Builder builder, String method, URI endpoint,

mcp/src/main/java/io/modelcontextprotocol/client/transport/customizer/McpSyncHttpRequestCustomizer.java renamed to mcp/src/main/java/io/modelcontextprotocol/client/transport/customizer/McpSyncHttpClientRequestCustomizer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*
2121
* @author Daniel Garnier-Moiroux
2222
*/
23-
public interface McpSyncHttpRequestCustomizer {
23+
public interface McpSyncHttpClientRequestCustomizer {
2424

2525
void customize(HttpRequest.Builder builder, String method, URI endpoint, @Nullable String body,
2626
McpTransportContext context);

mcp/src/test/java/io/modelcontextprotocol/client/HttpClientStreamableHttpSyncClientTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import org.testcontainers.containers.wait.strategy.Wait;
1414

1515
import io.modelcontextprotocol.client.transport.HttpClientStreamableHttpTransport;
16-
import io.modelcontextprotocol.client.transport.customizer.McpSyncHttpRequestCustomizer;
16+
import io.modelcontextprotocol.client.transport.customizer.McpSyncHttpClientRequestCustomizer;
1717
import io.modelcontextprotocol.common.McpTransportContext;
1818
import io.modelcontextprotocol.spec.McpClientTransport;
1919

@@ -37,7 +37,7 @@ public class HttpClientStreamableHttpSyncClientTests extends AbstractMcpSyncClie
3737
.withExposedPorts(3001)
3838
.waitingFor(Wait.forHttp("/").forStatusCode(404));
3939

40-
private final McpSyncHttpRequestCustomizer requestCustomizer = mock(McpSyncHttpRequestCustomizer.class);
40+
private final McpSyncHttpClientRequestCustomizer requestCustomizer = mock(McpSyncHttpClientRequestCustomizer.class);
4141

4242
@Override
4343
protected McpClientTransport createMcpTransport() {

mcp/src/test/java/io/modelcontextprotocol/client/HttpSseMcpSyncClientTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import org.testcontainers.containers.wait.strategy.Wait;
1414

1515
import io.modelcontextprotocol.client.transport.HttpClientSseClientTransport;
16-
import io.modelcontextprotocol.client.transport.customizer.McpSyncHttpRequestCustomizer;
16+
import io.modelcontextprotocol.client.transport.customizer.McpSyncHttpClientRequestCustomizer;
1717
import io.modelcontextprotocol.common.McpTransportContext;
1818
import io.modelcontextprotocol.spec.McpClientTransport;
1919

@@ -43,7 +43,7 @@ class HttpSseMcpSyncClientTests extends AbstractMcpSyncClientTests {
4343
.withExposedPorts(3001)
4444
.waitingFor(Wait.forHttp("/").forStatusCode(404));
4545

46-
private final McpSyncHttpRequestCustomizer requestCustomizer = mock(McpSyncHttpRequestCustomizer.class);
46+
private final McpSyncHttpClientRequestCustomizer requestCustomizer = mock(McpSyncHttpClientRequestCustomizer.class);
4747

4848
@Override
4949
protected McpClientTransport createMcpTransport() {

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
import com.fasterxml.jackson.databind.ObjectMapper;
1818

19-
import io.modelcontextprotocol.client.transport.customizer.McpAsyncHttpRequestCustomizer;
20-
import io.modelcontextprotocol.client.transport.customizer.McpSyncHttpRequestCustomizer;
19+
import io.modelcontextprotocol.client.transport.customizer.McpAsyncHttpClientRequestCustomizer;
20+
import io.modelcontextprotocol.client.transport.customizer.McpSyncHttpClientRequestCustomizer;
2121
import io.modelcontextprotocol.common.McpTransportContext;
2222
import io.modelcontextprotocol.spec.McpSchema;
2323
import io.modelcontextprotocol.spec.McpSchema.JSONRPCRequest;
@@ -79,7 +79,7 @@ static class TestHttpClientSseClientTransport extends HttpClientSseClientTranspo
7979
public TestHttpClientSseClientTransport(final String baseUri) {
8080
super(HttpClient.newBuilder().version(HttpClient.Version.HTTP_1_1).build(),
8181
HttpRequest.newBuilder().header("Content-Type", "application/json"), baseUri, "/sse",
82-
new ObjectMapper(), McpAsyncHttpRequestCustomizer.NOOP);
82+
new ObjectMapper(), McpAsyncHttpClientRequestCustomizer.NOOP);
8383
}
8484

8585
public int getInboundMessageCount() {
@@ -396,7 +396,7 @@ void testChainedCustomizations() {
396396

397397
@Test
398398
void testRequestCustomizer() {
399-
var mockCustomizer = mock(McpSyncHttpRequestCustomizer.class);
399+
var mockCustomizer = mock(McpSyncHttpClientRequestCustomizer.class);
400400

401401
// Create a transport with the customizer
402402
var customizedTransport = HttpClientSseClientTransport.builder(host)
@@ -437,7 +437,7 @@ void testRequestCustomizer() {
437437

438438
@Test
439439
void testAsyncRequestCustomizer() {
440-
var mockCustomizer = mock(McpAsyncHttpRequestCustomizer.class);
440+
var mockCustomizer = mock(McpAsyncHttpClientRequestCustomizer.class);
441441
when(mockCustomizer.customize(any(), any(), any(), any(), any()))
442442
.thenAnswer(invocation -> Mono.just(invocation.getArguments()[0]));
443443

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
import com.sun.net.httpserver.HttpServer;
2424

25-
import io.modelcontextprotocol.client.transport.customizer.McpSyncHttpRequestCustomizer;
25+
import io.modelcontextprotocol.client.transport.customizer.McpSyncHttpClientRequestCustomizer;
2626
import io.modelcontextprotocol.server.transport.TomcatTestUtil;
2727
import io.modelcontextprotocol.spec.McpSchema;
2828
import io.modelcontextprotocol.spec.ProtocolVersions;
@@ -71,7 +71,7 @@ static void stopContainer() {
7171
void testNotificationInitialized() throws URISyntaxException {
7272

7373
var uri = new URI(host + "/mcp");
74-
var mockRequestCustomizer = mock(McpSyncHttpRequestCustomizer.class);
74+
var mockRequestCustomizer = mock(McpSyncHttpClientRequestCustomizer.class);
7575
var transport = HttpClientStreamableHttpTransport.builder(host)
7676
.httpRequestCustomizer(mockRequestCustomizer)
7777
.build();

0 commit comments

Comments
 (0)