diff --git a/src/main/services/MCPService.ts b/src/main/services/MCPService.ts index a7f907f65f..679bfd9b35 100644 --- a/src/main/services/MCPService.ts +++ b/src/main/services/MCPService.ts @@ -21,7 +21,6 @@ import { CancelledNotificationSchema, type GetPromptResult, LoggingMessageNotificationSchema, - ProgressNotificationSchema, PromptListChangedNotificationSchema, ResourceListChangedNotificationSchema, ResourceUpdatedNotificationSchema, @@ -432,15 +431,6 @@ class McpService { this.clearResourceCaches(serverKey) }) - // Set up progress notification handler - client.setNotificationHandler(ProgressNotificationSchema, async (notification) => { - logger.debug(`Progress notification received for server: ${server.name}`, notification.params) - const mainWindow = windowService.getMainWindow() - if (mainWindow) { - mainWindow.webContents.send('mcp-progress', notification.params.progress / (notification.params.total || 1)) - } - }) - // Set up cancelled notification handler client.setNotificationHandler(CancelledNotificationSchema, async (notification) => { logger.debug(`Operation cancelled for server: ${server.name}`, notification.params) @@ -629,6 +619,11 @@ class McpService { const result = await client.callTool({ name, arguments: args }, undefined, { onprogress: (process) => { logger.debug(`Progress: ${process.progress / (process.total || 1)}`) + logger.debug(`Progress notification received for server: ${server.name}`, process) + const mainWindow = windowService.getMainWindow() + if (mainWindow) { + mainWindow.webContents.send('mcp-progress', process.progress / (process.total || 1)) + } }, timeout: server.timeout ? server.timeout * 1000 : 60000, // Default timeout of 1 minute, // 需要服务端支持: https://modelcontextprotocol.io/specification/2025-06-18/basic/lifecycle#timeouts