Skip to content

Commit 6f83109

Browse files
committed
Client HTTP transports: use McpTransportSession interface instead of concrete types
Signed-off-by: Daniel Garnier-Moiroux <git@garnier.wf>
1 parent 2ee5853 commit 6f83109

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public class HttpClientStreamableHttpTransport implements McpClientTransport {
118118

119119
private final McpAsyncHttpClientRequestCustomizer httpRequestCustomizer;
120120

121-
private final AtomicReference<DefaultMcpTransportSession> activeSession = new AtomicReference<>();
121+
private final AtomicReference<McpTransportSession<Disposable>> activeSession = new AtomicReference<>();
122122

123123
private final AtomicReference<Function<Mono<McpSchema.JSONRPCMessage>, Mono<McpSchema.JSONRPCMessage>>> handler = new AtomicReference<>();
124124

@@ -163,7 +163,7 @@ public Mono<Void> connect(Function<Mono<McpSchema.JSONRPCMessage>, Mono<McpSchem
163163
});
164164
}
165165

166-
private DefaultMcpTransportSession createTransportSession() {
166+
private McpTransportSession<Disposable> createTransportSession() {
167167
Function<String, Publisher<Void>> onClose = sessionId -> sessionId == null ? Mono.empty()
168168
: createDelete(sessionId);
169169
return new DefaultMcpTransportSession(onClose);
@@ -210,9 +210,9 @@ private void handleException(Throwable t) {
210210
public Mono<Void> closeGracefully() {
211211
return Mono.defer(() -> {
212212
logger.debug("Graceful close triggered");
213-
DefaultMcpTransportSession currentSession = this.activeSession.getAndSet(createTransportSession());
213+
McpTransportSession<Disposable> currentSession = this.activeSession.getAndSet(createTransportSession());
214214
if (currentSession != null) {
215-
return currentSession.closeGracefully();
215+
return Mono.from(currentSession.closeGracefully());
216216
}
217217
return Mono.empty();
218218
});

mcp-spring/mcp-spring-webflux/src/main/java/io/modelcontextprotocol/client/transport/WebClientStreamableHttpTransport.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public class WebClientStreamableHttpTransport implements McpClientTransport {
9898

9999
private final boolean resumableStreams;
100100

101-
private final AtomicReference<DefaultMcpTransportSession> activeSession = new AtomicReference<>();
101+
private final AtomicReference<McpTransportSession<Disposable>> activeSession = new AtomicReference<>();
102102

103103
private final AtomicReference<Function<Mono<McpSchema.JSONRPCMessage>, Mono<McpSchema.JSONRPCMessage>>> handler = new AtomicReference<>();
104104

@@ -143,7 +143,7 @@ public Mono<Void> connect(Function<Mono<McpSchema.JSONRPCMessage>, Mono<McpSchem
143143
});
144144
}
145145

146-
private DefaultMcpTransportSession createTransportSession() {
146+
private McpTransportSession<Disposable> createTransportSession() {
147147
Function<String, Publisher<Void>> onClose = sessionId -> sessionId == null ? Mono.empty()
148148
: webClient.delete()
149149
.uri(this.endpoint)
@@ -182,9 +182,9 @@ private void handleException(Throwable t) {
182182
public Mono<Void> closeGracefully() {
183183
return Mono.defer(() -> {
184184
logger.debug("Graceful close triggered");
185-
DefaultMcpTransportSession currentSession = this.activeSession.getAndSet(createTransportSession());
185+
McpTransportSession<Disposable> currentSession = this.activeSession.getAndSet(createTransportSession());
186186
if (currentSession != null) {
187-
return currentSession.closeGracefully();
187+
return Mono.from(currentSession.closeGracefully());
188188
}
189189
return Mono.empty();
190190
});

0 commit comments

Comments
 (0)