File tree Expand file tree Collapse file tree 2 files changed +25
-7
lines changed
Expand file tree Collapse file tree 2 files changed +25
-7
lines changed Original file line number Diff line number Diff line change @@ -153,15 +153,22 @@ export class InspectorOAuthClientProvider implements OAuthClientProvider {
153153 }
154154
155155 get clientMetadata ( ) : OAuthClientMetadata {
156- return {
156+ const metadata : OAuthClientMetadata = {
157157 redirect_uris : this . redirect_uris ,
158158 token_endpoint_auth_method : "none" ,
159159 grant_types : [ "authorization_code" , "refresh_token" ] ,
160160 response_types : [ "code" ] ,
161161 client_name : "MCP Inspector" ,
162162 client_uri : "https://github.com/modelcontextprotocol/inspector" ,
163- scope : this . scope ?? "" ,
164163 } ;
164+
165+ // Only include scope if it's defined and non-empty
166+ // Per OAuth spec, omit the scope field entirely if no scopes are requested
167+ if ( this . scope ) {
168+ metadata . scope = this . scope ;
169+ }
170+
171+ return metadata ;
165172 }
166173
167174 state ( ) : string | Promise < string > {
Original file line number Diff line number Diff line change @@ -389,11 +389,22 @@ export function useConnection({
389389 saveScopeToSessionStorage ( sseUrl , scope ) ;
390390 const serverAuthProvider = new InspectorOAuthClientProvider ( sseUrl ) ;
391391
392- const result = await auth ( serverAuthProvider , {
393- serverUrl : sseUrl ,
394- scope,
395- } ) ;
396- return result === "AUTHORIZED" ;
392+ try {
393+ const result = await auth ( serverAuthProvider , {
394+ serverUrl : sseUrl ,
395+ scope,
396+ } ) ;
397+ return result === "AUTHORIZED" ;
398+ } catch ( authError ) {
399+ // Show user-friendly error message for OAuth failures
400+ toast ( {
401+ title : "OAuth Authentication Failed" ,
402+ description :
403+ authError instanceof Error ? authError . message : String ( authError ) ,
404+ variant : "destructive" ,
405+ } ) ;
406+ return false ;
407+ }
397408 }
398409
399410 return false ;
You can’t perform that action at this time.
0 commit comments