Skip to content

Commit 9863cbd

Browse files
#115157 - emit the value separately for proxy session (#5)
1 parent 4f96662 commit 9863cbd

7 files changed

Lines changed: 24 additions & 6 deletions

File tree

‎mcp-bom/pom.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>io.modelcontextprotocol.sdk</groupId>
99
<artifactId>mcp-parent</artifactId>
10-
<version>1.1.0</version>
10+
<version>1.2.0</version>
1111
</parent>
1212

1313
<artifactId>mcp-bom</artifactId>

‎mcp-spring/mcp-spring-webflux/pom.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>io.modelcontextprotocol.sdk</groupId>
88
<artifactId>mcp-parent</artifactId>
9-
<version>1.1.0</version>
9+
<version>1.2.0</version>
1010
<relativePath>../../pom.xml</relativePath>
1111
</parent>
1212
<artifactId>mcp-spring-webflux</artifactId>

‎mcp-spring/mcp-spring-webmvc/pom.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>io.modelcontextprotocol.sdk</groupId>
88
<artifactId>mcp-parent</artifactId>
9-
<version>1.1.0</version>
9+
<version>1.2.0</version>
1010
<relativePath>../../pom.xml</relativePath>
1111
</parent>
1212
<artifactId>mcp-spring-webmvc</artifactId>

‎mcp-test/pom.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>io.modelcontextprotocol.sdk</groupId>
88
<artifactId>mcp-parent</artifactId>
9-
<version>1.1.0</version>
9+
<version>1.2.0</version>
1010
</parent>
1111
<artifactId>mcp-test</artifactId>
1212
<packaging>jar</packaging>

‎mcp/pom.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>io.modelcontextprotocol.sdk</groupId>
88
<artifactId>mcp-parent</artifactId>
9-
<version>1.1.0</version>
9+
<version>1.2.0</version>
1010
</parent>
1111
<artifactId>mcp</artifactId>
1212
<packaging>jar</packaging>

‎mcp/src/main/java/io/modelcontextprotocol/spec/McpServerSession.java‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ public class McpServerSession implements McpSession {
5252

5353
private Authentication authentication;
5454

55+
private boolean proxySession = false;
56+
57+
boolean isExchangeEmitted = false;
58+
5559
private static final int STATE_UNINITIALIZED = 0;
5660

5761
private static final int STATE_INITIALIZING = 1;
@@ -107,6 +111,14 @@ public McpServerTransport getTransport() {
107111
return transport;
108112
}
109113

114+
public boolean isProxySession() {
115+
return proxySession;
116+
}
117+
118+
public void setProxySession(boolean proxySession) {
119+
this.proxySession = proxySession;
120+
}
121+
110122
/**
111123
* Called upon successful initialization sequence between the client and the server
112124
* with the client capabilities and information.
@@ -240,6 +252,11 @@ private Mono<McpSchema.JSONRPCResponse> handleIncomingRequest(McpSchema.JSONRPCR
240252
error.message(), error.data())));
241253
}
242254

255+
if (proxySession && !isExchangeEmitted) {
256+
exchangeSink
257+
.tryEmitValue(new McpAsyncServerExchange(this, clientCapabilities.get(), clientInfo.get()));
258+
isExchangeEmitted = true;
259+
}
243260
resultMono = this.exchangeSink.asMono().flatMap(exchange -> handler.handle(exchange, request.params()));
244261
}
245262
return resultMono
@@ -261,6 +278,7 @@ private Mono<Void> handleIncomingNotification(McpSchema.JSONRPCNotification noti
261278
if (McpSchema.METHOD_NOTIFICATION_INITIALIZED.equals(notification.method())) {
262279
this.state.lazySet(STATE_INITIALIZED);
263280
exchangeSink.tryEmitValue(new McpAsyncServerExchange(this, clientCapabilities.get(), clientInfo.get()));
281+
isExchangeEmitted = true;
264282
return this.initNotificationHandler.handle();
265283
}
266284

‎pom.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>io.modelcontextprotocol.sdk</groupId>
88
<artifactId>mcp-parent</artifactId>
9-
<version>1.1.0</version>
9+
<version>1.2.0</version>
1010

1111
<packaging>pom</packaging>
1212
<url>https://github.com/modelcontextprotocol/java-sdk</url>

0 commit comments

Comments
 (0)