@@ -102,14 +102,14 @@ impl ServerHandler for McpMuxGatewayHandler {
102102 protocol_version : Default :: default ( ) ,
103103 capabilities : ServerCapabilities :: builder ( )
104104 . enable_tools_with ( ToolsCapability {
105- list_changed : Some ( false ) , // Stateless mode - no notifications
105+ list_changed : Some ( true ) ,
106106 } )
107107 . enable_prompts_with ( PromptsCapability {
108- list_changed : Some ( false ) , // Stateless mode - no notifications
108+ list_changed : Some ( true ) ,
109109 } )
110110 . enable_resources_with ( ResourcesCapability {
111111 subscribe : Some ( false ) ,
112- list_changed : Some ( false ) , // Stateless mode - no notifications
112+ list_changed : Some ( true ) ,
113113 } )
114114 . build ( ) ,
115115 server_info : Implementation {
@@ -150,19 +150,34 @@ impl ServerHandler for McpMuxGatewayHandler {
150150 }
151151
152152 async fn on_initialized ( & self , context : NotificationContext < RoleServer > ) {
153- // Silently process - entry already logged in oauth_middleware
154- let _oauth_ctx = match self . get_oauth_context ( & context. extensions ) {
153+ let oauth_ctx = match self . get_oauth_context ( & context. extensions ) {
155154 Ok ( ctx) => ctx,
156155 Err ( e) => {
157- warn ! ( "Failed to extract OAuth context: {}" , e) ;
156+ warn ! ( "Failed to extract OAuth context on_initialized : {}" , e) ;
158157 return ;
159158 }
160159 } ;
161160
162- // In stateless mode:
163- // - No session tracking
164- // - No notification registration
165- // - Each request is independent
161+ // Register peer with MCPNotifier for list_changed notification delivery
162+ let peer = std:: sync:: Arc :: new ( context. peer ) ;
163+ self . notification_bridge
164+ . register_peer ( oauth_ctx. client_id . clone ( ) , peer) ;
165+
166+ // Mark the client stream as active immediately - RMCP's session transport
167+ // handles SSE streaming and message caching internally
168+ self . notification_bridge
169+ . mark_client_stream_active ( & oauth_ctx. client_id ) ;
170+
171+ // Pre-populate feature hashes to prevent spurious first notifications
172+ self . notification_bridge
173+ . prime_hashes_for_space ( oauth_ctx. space_id )
174+ . await ;
175+
176+ info ! (
177+ client_id = %oauth_ctx. client_id,
178+ space_id = %oauth_ctx. space_id,
179+ "Client initialized - peer registered for notifications"
180+ ) ;
166181 }
167182
168183 async fn list_tools (
0 commit comments