Skip to content

Commit b1ad3a4

Browse files
committed
chore: revert the disconnect function change
1 parent db1b2f4 commit b1ad3a4

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/common/connectionManager.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff 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 {

0 commit comments

Comments
 (0)