Skip to content

Commit 35bd171

Browse files
committed
fix(agent-tars): mcp servers cleanup when windows all closed
1 parent 492a487 commit 35bd171

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

apps/agent-tars/src/main/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { app, shell, BrowserWindow, ipcMain } from 'electron';
2+
import { mapClientRef } from '@main/mcp/client';
23
import { join } from 'path';
34
import { registerIpcMain } from '@ui-tars/electron-ipc/main';
45
import { electronApp, optimizer, is } from '@electron-toolkit/utils';
@@ -133,11 +134,16 @@ app.whenReady().then(async () => {
133134
// Quit when all windows are closed, except on macOS. There, it's common
134135
// for applications and their menu bar to stay active until the user quits
135136
// explicitly with Cmd + Q.
136-
app.on('window-all-closed', () => {
137+
app.on('window-all-closed', async () => {
137138
logger.info('All windows closed');
138139
if (process.platform !== 'darwin') {
139140
app.quit();
140141
}
142+
logger.info('mcp cleanup');
143+
// Deactivate all MCP servers
144+
await mapClientRef.current?.cleanup().catch((err) => {
145+
logger.error('Error during cleanup of MCP servers:', err);
146+
});
141147
});
142148

143149
// In this file you can include the rest of your app's specific main process

0 commit comments

Comments
 (0)