File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ import { useToast } from "@/lib/hooks/useToast";
3737import { z } from "zod" ;
3838import { ConnectionStatus } from "../constants" ;
3939import { Notification , StdErrNotificationSchema } from "../notificationTypes" ;
40- import { auth } from "@modelcontextprotocol/sdk/client/auth.js" ;
40+ import { auth , discoverOAuthProtectedResourceMetadata } from "@modelcontextprotocol/sdk/client/auth.js" ;
4141import {
4242 clearClientInformationFromSessionStorage ,
4343 InspectorOAuthClientProvider ,
@@ -317,9 +317,19 @@ export function useConnection({
317317 if ( is401Error ( error ) ) {
318318 const serverAuthProvider = new InspectorOAuthClientProvider ( sseUrl ) ;
319319
320+ let scope = oauthScope ;
321+ try {
322+ const resourceMetadata = await discoverOAuthProtectedResourceMetadata ( sseUrl ) ;
323+ if ( resourceMetadata ?. scopes_supported ) {
324+ scope = resourceMetadata . scopes_supported . join ( " " ) ;
325+ }
326+ } catch {
327+ // Continue without scope if discovery fails
328+ }
329+
320330 const result = await auth ( serverAuthProvider , {
321331 serverUrl : sseUrl ,
322- scope : oauthScope ,
332+ scope,
323333 } ) ;
324334 return result === "AUTHORIZED" ;
325335 }
You can’t perform that action at this time.
0 commit comments