@@ -101,9 +101,12 @@ impl McpMuxGatewayHandler {
101101 client_id : & str ,
102102 session_id : Option < & str > ,
103103 root_for_prompt : Option < & str > ,
104+ request_machine_id : Option < uuid:: Uuid > ,
104105 ) {
105106 let resolver = & services. feature_set_resolver ;
106- match resolver. resolve ( session_id, Some ( client_id) ) . await {
107+ match resolver
108+ . resolve ( session_id, Some ( client_id) , request_machine_id)
109+ . await {
107110 Ok ( resolved) => {
108111 info ! (
109112 %client_id,
@@ -192,11 +195,12 @@ impl McpMuxGatewayHandler {
192195 & self ,
193196 session_id : Option < & str > ,
194197 client_id : & str ,
198+ request_machine_id : Option < uuid:: Uuid > ,
195199 ) -> Result < ( uuid:: Uuid , Vec < String > ) , McpError > {
196200 let resolved = self
197201 . services
198202 . authorization_service
199- . resolve ( session_id, Some ( client_id) )
203+ . resolve ( session_id, Some ( client_id) , request_machine_id )
200204 . await
201205 . map_err ( |e| McpError :: internal_error ( format ! ( "Failed to resolve: {e}" ) , None ) ) ?;
202206 let space_id = resolved. space_id . ok_or_else ( || {
@@ -226,6 +230,7 @@ impl McpMuxGatewayHandler {
226230 peer : & rmcp:: service:: Peer < RoleServer > ,
227231 session_id : Option < & str > ,
228232 client_id : & str ,
233+ request_machine_id : Option < uuid:: Uuid > ,
229234 ) {
230235 let Some ( sid) = session_id else { return } ;
231236 // Fast path: already have a definitive answer (Some(roots),
@@ -318,6 +323,7 @@ impl McpMuxGatewayHandler {
318323 & client_id,
319324 Some ( & session_id) ,
320325 root_for_prompt. as_deref ( ) ,
326+ request_machine_id,
321327 )
322328 . await ;
323329 } ) ;
@@ -532,6 +538,7 @@ impl ServerHandler for McpMuxGatewayHandler {
532538 let notifier = self . notification_bridge . clone ( ) ;
533539 let client_id_str = oauth_ctx. client_id . clone ( ) ;
534540 let session_id_for_task = session_id. clone ( ) ;
541+ let request_machine_id = oauth_ctx. request_machine_id ;
535542 tokio:: spawn ( async move {
536543 // Retry list_roots() on transport errors with bounded
537544 // backoff. Without roots a roots-capable session is
@@ -620,6 +627,7 @@ impl ServerHandler for McpMuxGatewayHandler {
620627 & client_id_str,
621628 Some ( & session_id_for_task) ,
622629 root_for_prompt. as_deref ( ) ,
630+ request_machine_id,
623631 )
624632 . await ;
625633 } ) ;
@@ -632,6 +640,7 @@ impl ServerHandler for McpMuxGatewayHandler {
632640 & oauth_ctx. client_id ,
633641 Some ( & session_id) ,
634642 None ,
643+ oauth_ctx. request_machine_id ,
635644 )
636645 . await ;
637646 }
@@ -671,6 +680,7 @@ impl ServerHandler for McpMuxGatewayHandler {
671680 let notifier = self . notification_bridge . clone ( ) ;
672681 let client_id_str = oauth_ctx. client_id . clone ( ) ;
673682 let session_id_for_task = session_id. clone ( ) ;
683+ let request_machine_id = oauth_ctx. request_machine_id ;
674684 tokio:: spawn ( async move {
675685 match peer. list_roots ( ) . await {
676686 Ok ( result) => {
@@ -702,6 +712,7 @@ impl ServerHandler for McpMuxGatewayHandler {
702712 & client_id_str,
703713 Some ( & session_id_for_task) ,
704714 root_for_prompt. as_deref ( ) ,
715+ request_machine_id,
705716 )
706717 . await ;
707718 }
@@ -734,13 +745,18 @@ impl ServerHandler for McpMuxGatewayHandler {
734745 & context. peer ,
735746 session_id_owned. as_deref ( ) ,
736747 & oauth_ctx. client_id ,
748+ oauth_ctx. request_machine_id ,
737749 )
738750 . await ;
739751 // Resolve routing once: the resolver returns the authoritative
740752 // (Space, FS) for this session — this may differ from oauth_ctx
741753 // when a WorkspaceBinding redirects to another space.
742754 let ( space_id, feature_set_ids) = self
743- . resolve_routing ( session_id_owned. as_deref ( ) , & oauth_ctx. client_id )
755+ . resolve_routing (
756+ session_id_owned. as_deref ( ) ,
757+ & oauth_ctx. client_id ,
758+ oauth_ctx. request_machine_id ,
759+ )
744760 . await ?;
745761
746762 // Get advertised (surfaced) tools only — full invokable set is reachable
@@ -810,14 +826,14 @@ impl ServerHandler for McpMuxGatewayHandler {
810826 // connection). Without the probe it resolves to empty FS ids and
811827 // fails "not allowed by the current grants" — breaking the
812828 // list==call invariant the list handlers already uphold.
813- self . ensure_roots_probed ( & context. peer , session_id, & oauth_ctx. client_id )
829+ self . ensure_roots_probed ( & context. peer , session_id, & oauth_ctx. client_id , oauth_ctx . request_machine_id )
814830 . await ;
815831
816832 // Resolve routing once — the binding's target space is authoritative
817833 // (may differ from oauth_ctx.space_id). Needed both to gate the
818834 // per-Space meta tools below and to route a normal tool call.
819835 let ( space_id, feature_set_ids) = self
820- . resolve_routing ( session_id, & oauth_ctx. client_id )
836+ . resolve_routing ( session_id, & oauth_ctx. client_id , oauth_ctx . request_machine_id )
821837 . await ?;
822838
823839 // Intercept meta tools (mcpmux_*) BEFORE feature-set filtering, gated
@@ -1032,10 +1048,15 @@ impl ServerHandler for McpMuxGatewayHandler {
10321048 & context. peer ,
10331049 session_id_owned. as_deref ( ) ,
10341050 & oauth_ctx. client_id ,
1051+ oauth_ctx. request_machine_id ,
10351052 )
10361053 . await ;
10371054 let ( space_id, feature_set_ids) = self
1038- . resolve_routing ( session_id_owned. as_deref ( ) , & oauth_ctx. client_id )
1055+ . resolve_routing (
1056+ session_id_owned. as_deref ( ) ,
1057+ & oauth_ctx. client_id ,
1058+ oauth_ctx. request_machine_id ,
1059+ )
10391060 . await ?;
10401061
10411062 // Get advertised (surfaced) prompts only — full fetchable set is reachable
@@ -1086,10 +1107,15 @@ impl ServerHandler for McpMuxGatewayHandler {
10861107 & context. peer ,
10871108 session_id_owned. as_deref ( ) ,
10881109 & oauth_ctx. client_id ,
1110+ oauth_ctx. request_machine_id ,
10891111 )
10901112 . await ;
10911113 let ( space_id, feature_set_ids) = self
1092- . resolve_routing ( session_id_owned. as_deref ( ) , & oauth_ctx. client_id )
1114+ . resolve_routing (
1115+ session_id_owned. as_deref ( ) ,
1116+ & oauth_ctx. client_id ,
1117+ oauth_ctx. request_machine_id ,
1118+ )
10931119 . await ?;
10941120
10951121 let ( server_id, prompt_name) = self
@@ -1180,10 +1206,15 @@ impl ServerHandler for McpMuxGatewayHandler {
11801206 & context. peer ,
11811207 session_id_owned. as_deref ( ) ,
11821208 & oauth_ctx. client_id ,
1209+ oauth_ctx. request_machine_id ,
11831210 )
11841211 . await ;
11851212 let ( space_id, feature_set_ids) = self
1186- . resolve_routing ( session_id_owned. as_deref ( ) , & oauth_ctx. client_id )
1213+ . resolve_routing (
1214+ session_id_owned. as_deref ( ) ,
1215+ & oauth_ctx. client_id ,
1216+ oauth_ctx. request_machine_id ,
1217+ )
11871218 . await ?;
11881219
11891220 // Get advertised (surfaced) resources only — full readable set is reachable
@@ -1232,10 +1263,15 @@ impl ServerHandler for McpMuxGatewayHandler {
12321263 & context. peer ,
12331264 session_id_owned. as_deref ( ) ,
12341265 & oauth_ctx. client_id ,
1266+ oauth_ctx. request_machine_id ,
12351267 )
12361268 . await ;
12371269 let ( space_id, feature_set_ids) = self
1238- . resolve_routing ( session_id_owned. as_deref ( ) , & oauth_ctx. client_id )
1270+ . resolve_routing (
1271+ session_id_owned. as_deref ( ) ,
1272+ & oauth_ctx. client_id ,
1273+ oauth_ctx. request_machine_id ,
1274+ )
12391275 . await ?;
12401276
12411277 let authorized_resources = self
0 commit comments