@@ -393,11 +393,22 @@ export function useConnection({
393393 saveScopeToSessionStorage ( sseUrl , scope ) ;
394394 const serverAuthProvider = new InspectorOAuthClientProvider ( sseUrl ) ;
395395
396- const result = await auth ( serverAuthProvider , {
397- serverUrl : sseUrl ,
398- scope,
399- } ) ;
400- return result === "AUTHORIZED" ;
396+ try {
397+ const result = await auth ( serverAuthProvider , {
398+ serverUrl : sseUrl ,
399+ scope,
400+ } ) ;
401+ return result === "AUTHORIZED" ;
402+ } catch ( authError ) {
403+ // Show user-friendly error message for OAuth failures
404+ toast ( {
405+ title : "OAuth Authentication Failed" ,
406+ description :
407+ authError instanceof Error ? authError . message : String ( authError ) ,
408+ variant : "destructive" ,
409+ } ) ;
410+ return false ;
411+ }
401412 }
402413
403414 return false ;
@@ -534,6 +545,7 @@ export function useConnection({
534545 requestHeaders [ "Accept" ] = "text/event-stream" ;
535546 requestHeaders [ "content-type" ] = "application/json" ;
536547 transportOptions = {
548+ authProvider : serverAuthProvider ,
537549 fetch : async (
538550 url : string | URL | globalThis . Request ,
539551 init ?: RequestInit ,
@@ -555,6 +567,7 @@ export function useConnection({
555567
556568 case "streamable-http" :
557569 transportOptions = {
570+ authProvider : serverAuthProvider ,
558571 fetch : async (
559572 url : string | URL | globalThis . Request ,
560573 init ?: RequestInit ,
@@ -643,6 +656,7 @@ export function useConnection({
643656 ) ;
644657 }
645658 transportOptions = {
659+ authProvider : serverAuthProvider ,
646660 eventSourceInit : {
647661 fetch : (
648662 url : string | URL | globalThis . Request ,
@@ -664,6 +678,7 @@ export function useConnection({
664678 mcpProxyServerUrl = new URL ( `${ getMCPProxyAddress ( config ) } /mcp` ) ;
665679 mcpProxyServerUrl . searchParams . append ( "url" , sseUrl ) ;
666680 transportOptions = {
681+ authProvider : serverAuthProvider ,
667682 eventSourceInit : {
668683 fetch : (
669684 url : string | URL | globalThis . Request ,
0 commit comments