@@ -38,8 +38,6 @@ public class McpServerSession implements McpLoggableSession {
3838
3939 private final McpInitRequestHandler initRequestHandler ;
4040
41- private final InitNotificationHandler initNotificationHandler ;
42-
4341 private final Map <String , McpRequestHandler <?>> requestHandlers ;
4442
4543 private final Map <String , McpNotificationHandler > notificationHandlers ;
@@ -62,6 +60,27 @@ public class McpServerSession implements McpLoggableSession {
6260
6361 private volatile McpSchema .LoggingLevel minLoggingLevel = McpSchema .LoggingLevel .INFO ;
6462
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+
6584 /**
6685 * Creates a new server session with the given parameters and the transport to use.
6786 * @param id session id
@@ -74,7 +93,10 @@ public class McpServerSession implements McpLoggableSession {
7493 * received.
7594 * @param requestHandlers map of request handlers to use
7695 * @param notificationHandlers map of notification handlers to use
96+ * @deprecated Use
97+ * {@link #McpServerSession(String, Duration, McpServerTransport, McpInitRequestHandler, Map, Map)}
7798 */
99+ @ Deprecated
78100 public McpServerSession (String id , Duration requestTimeout , McpServerTransport transport ,
79101 McpInitRequestHandler initHandler , InitNotificationHandler initNotificationHandler ,
80102 Map <String , McpRequestHandler <?>> requestHandlers ,
@@ -83,7 +105,6 @@ public McpServerSession(String id, Duration requestTimeout, McpServerTransport t
83105 this .requestTimeout = requestTimeout ;
84106 this .transport = transport ;
85107 this .initRequestHandler = initHandler ;
86- this .initNotificationHandler = initNotificationHandler ;
87108 this .requestHandlers = requestHandlers ;
88109 this .notificationHandlers = notificationHandlers ;
89110 }
@@ -264,7 +285,6 @@ private Mono<Void> handleIncomingNotification(McpSchema.JSONRPCNotification noti
264285 // legacy SSE transport.
265286 exchangeSink .tryEmitValue (new McpAsyncServerExchange (this .id , this , clientCapabilities .get (),
266287 clientInfo .get (), McpTransportContext .EMPTY ));
267- return this .initNotificationHandler .handle ();
268288 }
269289
270290 var handler = notificationHandlers .get (notification .method ());
0 commit comments