You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Mcp-Session-Id is the strongest signal that we're in streamable HTTP mode
@@ -511,11 +501,15 @@ class McpHTTPHandle extends Disposable {
511
501
headers['Last-Event-ID']=lastEventId;
512
502
}
513
503
514
-
res=awaitfetch(this._launch.uri.toString(true),{
515
-
method: 'GET',
516
-
signal: this._abortCtrl.signal,
517
-
headers,
518
-
});
504
+
res=awaitthis._fetchWithAuthRetry(
505
+
this._launch.uri.toString(true),
506
+
{
507
+
method: 'GET',
508
+
signal: this._abortCtrl.signal,
509
+
headers,
510
+
},
511
+
headers
512
+
);
519
513
}catch(e){
520
514
this._log(LogLevel.Info,`Error connecting to ${this._launch.uri} for async notifications, will retry`);
521
515
continue;
@@ -559,11 +553,15 @@ class McpHTTPHandle extends Disposable {
559
553
560
554
letres: Response;
561
555
try{
562
-
res=awaitfetch(this._launch.uri.toString(true),{
563
-
method: 'GET',
564
-
signal: this._abortCtrl.signal,
565
-
headers,
566
-
});
556
+
res=awaitthis._fetchWithAuthRetry(
557
+
this._launch.uri.toString(true),
558
+
{
559
+
method: 'GET',
560
+
signal: this._abortCtrl.signal,
561
+
headers,
562
+
},
563
+
headers
564
+
);
567
565
if(res.status>=300){
568
566
this._proxy.$onDidChangeState(this._id,{state: McpConnectionState.Kind.Error,message: `${res.status} status connecting to ${this._launch.uri} as SSE: ${awaitthis._getErrText(res)}`});
569
567
return;
@@ -666,6 +664,29 @@ class McpHTTPHandle extends Disposable {
666
664
returnres.statusText;
667
665
}
668
666
}
667
+
668
+
/**
669
+
* Helper method to perform fetch with 401 authentication retry logic.
670
+
* If the initial request returns 401 and we don't have auth metadata,
671
+
* it will populate the auth metadata and retry once.
0 commit comments