mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-02 10:29:02 +08:00
fix(mcp): enhance progress event structure to include callId for specific tool tracking (#9946)
* fix(mcp): enhance progress event structure to include callId for specific tool tracking * refactor(mcp): add MCP progress event with callId and progress percentage
This commit is contained in:
parent
469b29c941
commit
86e3776fff
@ -83,7 +83,7 @@ export enum IpcChannel {
|
||||
Mcp_UploadDxt = 'mcp:upload-dxt',
|
||||
Mcp_AbortTool = 'mcp:abort-tool',
|
||||
Mcp_GetServerVersion = 'mcp:get-server-version',
|
||||
|
||||
Mcp_Progress = 'mcp:progress',
|
||||
// Python
|
||||
Python_Execute = 'python:execute',
|
||||
|
||||
|
||||
@ -17,3 +17,8 @@ export type FileChangeEvent = {
|
||||
filePath: string
|
||||
watchPath: string
|
||||
}
|
||||
|
||||
export type MCPProgressEvent = {
|
||||
callId: string
|
||||
progress: number // 0-1 range
|
||||
}
|
||||
|
||||
@ -27,6 +27,8 @@ import {
|
||||
ToolListChangedNotificationSchema
|
||||
} from '@modelcontextprotocol/sdk/types.js'
|
||||
import { nanoid } from '@reduxjs/toolkit'
|
||||
import { MCPProgressEvent } from '@shared/config/types'
|
||||
import { IpcChannel } from '@shared/IpcChannel'
|
||||
import {
|
||||
BuiltinMCPServerNames,
|
||||
type GetResourceResponse,
|
||||
@ -689,7 +691,10 @@ class McpService {
|
||||
})
|
||||
const mainWindow = windowService.getMainWindow()
|
||||
if (mainWindow) {
|
||||
mainWindow.webContents.send('mcp-progress', process.progress / (process.total || 1))
|
||||
mainWindow.webContents.send(IpcChannel.Mcp_Progress, {
|
||||
callId: toolCallId,
|
||||
progress: process.progress / (process.total || 1)
|
||||
} as MCPProgressEvent)
|
||||
}
|
||||
},
|
||||
timeout: server.timeout ? server.timeout * 1000 : 60000, // Default timeout of 1 minute,
|
||||
|
||||
@ -7,6 +7,8 @@ import { useTimer } from '@renderer/hooks/useTimer'
|
||||
import type { ToolMessageBlock } from '@renderer/types/newMessage'
|
||||
import { isToolAutoApproved } from '@renderer/utils/mcp-tools'
|
||||
import { cancelToolAction, confirmToolAction } from '@renderer/utils/userConfirmation'
|
||||
import { MCPProgressEvent } from '@shared/config/types'
|
||||
import { IpcChannel } from '@shared/IpcChannel'
|
||||
import {
|
||||
Button,
|
||||
Collapse,
|
||||
@ -85,16 +87,19 @@ const MessageMcpTool: FC<Props> = ({ block }) => {
|
||||
|
||||
useEffect(() => {
|
||||
const removeListener = window.electron.ipcRenderer.on(
|
||||
'mcp-progress',
|
||||
(_event: Electron.IpcRendererEvent, value: number) => {
|
||||
setProgress(value)
|
||||
IpcChannel.Mcp_Progress,
|
||||
(_event: Electron.IpcRendererEvent, data: MCPProgressEvent) => {
|
||||
// Only update progress if this event is for our specific tool call
|
||||
if (data.callId === id) {
|
||||
setProgress(data.progress)
|
||||
}
|
||||
}
|
||||
)
|
||||
return () => {
|
||||
setProgress(0)
|
||||
removeListener()
|
||||
}
|
||||
}, [])
|
||||
}, [id])
|
||||
|
||||
const cancelCountdown = () => {
|
||||
if (timer.current) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user