File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -223,7 +223,23 @@ export class MCPConnectionManager extends ConnectionManager {
223223 return this . currentConnectionState ;
224224 }
225225
226- return Promise . resolve ( { tag : "disconnected" } ) ;
226+ if ( this . currentConnectionState . tag === "connected" || this . currentConnectionState . tag === "connecting" ) {
227+ try {
228+ if ( this . currentConnectionState . tag === "connected" ) {
229+ await this . currentConnectionState . serviceProvider ?. close ( ) ;
230+ }
231+ if ( this . currentConnectionState . tag === "connecting" ) {
232+ const serviceProvider = await this . currentConnectionState . serviceProvider ;
233+ await serviceProvider . close ( ) ;
234+ }
235+ } finally {
236+ this . changeState ( "connection-close" , {
237+ tag : "disconnected" ,
238+ } ) ;
239+ }
240+ }
241+
242+ return { tag : "disconnected" } ;
227243 }
228244
229245 private onOidcAuthFailed ( error : unknown ) : void {
You can’t perform that action at this time.
0 commit comments