@@ -38,8 +38,6 @@ public class McpServerSession implements McpLoggableSession {
38
38
39
39
private final McpInitRequestHandler initRequestHandler ;
40
40
41
- private final InitNotificationHandler initNotificationHandler ;
42
-
43
41
private final Map <String , McpRequestHandler <?>> requestHandlers ;
44
42
45
43
private final Map <String , McpNotificationHandler > notificationHandlers ;
@@ -62,6 +60,27 @@ public class McpServerSession implements McpLoggableSession {
62
60
63
61
private volatile McpSchema .LoggingLevel minLoggingLevel = McpSchema .LoggingLevel .INFO ;
64
62
63
+ /**
64
+ * Creates a new server session with the given parameters and the transport to use.
65
+ * @param id session id
66
+ * @param transport the transport to use
67
+ * @param initHandler called when a
68
+ * {@link io.modelcontextprotocol.spec.McpSchema.InitializeRequest} is received by the
69
+ * server
70
+ * @param requestHandlers map of request handlers to use
71
+ * @param notificationHandlers map of notification handlers to use
72
+ */
73
+ public McpServerSession (String id , Duration requestTimeout , McpServerTransport transport ,
74
+ McpInitRequestHandler initHandler , Map <String , McpRequestHandler <?>> requestHandlers ,
75
+ Map <String , McpNotificationHandler > notificationHandlers ) {
76
+ this .id = id ;
77
+ this .requestTimeout = requestTimeout ;
78
+ this .transport = transport ;
79
+ this .initRequestHandler = initHandler ;
80
+ this .requestHandlers = requestHandlers ;
81
+ this .notificationHandlers = notificationHandlers ;
82
+ }
83
+
65
84
/**
66
85
* Creates a new server session with the given parameters and the transport to use.
67
86
* @param id session id
@@ -74,7 +93,10 @@ public class McpServerSession implements McpLoggableSession {
74
93
* received.
75
94
* @param requestHandlers map of request handlers to use
76
95
* @param notificationHandlers map of notification handlers to use
96
+ * @deprecated Use
97
+ * {@link #McpServerSession(String, Duration, McpServerTransport, McpInitRequestHandler, Map, Map)}
77
98
*/
99
+ @ Deprecated
78
100
public McpServerSession (String id , Duration requestTimeout , McpServerTransport transport ,
79
101
McpInitRequestHandler initHandler , InitNotificationHandler initNotificationHandler ,
80
102
Map <String , McpRequestHandler <?>> requestHandlers ,
@@ -83,7 +105,6 @@ public McpServerSession(String id, Duration requestTimeout, McpServerTransport t
83
105
this .requestTimeout = requestTimeout ;
84
106
this .transport = transport ;
85
107
this .initRequestHandler = initHandler ;
86
- this .initNotificationHandler = initNotificationHandler ;
87
108
this .requestHandlers = requestHandlers ;
88
109
this .notificationHandlers = notificationHandlers ;
89
110
}
@@ -264,7 +285,6 @@ private Mono<Void> handleIncomingNotification(McpSchema.JSONRPCNotification noti
264
285
// legacy SSE transport.
265
286
exchangeSink .tryEmitValue (new McpAsyncServerExchange (this .id , this , clientCapabilities .get (),
266
287
clientInfo .get (), McpTransportContext .EMPTY ));
267
- return this .initNotificationHandler .handle ();
268
288
}
269
289
270
290
var handler = notificationHandlers .get (notification .method ());
0 commit comments