cancelTask
Stop a video processing task in Video Clip MCP by providing the task ID to halt clipping, merging, or splitting operations.
Instructions
取消指定的处理任务
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| taskId | Yes | 任务ID |
Implementation Reference
- src/mcp/server.ts:424-438 (handler)MCP tool handler for cancelTask: calls batchManager.cancelTask and returns formatted resultprivate async handleCancelTask(args: MCPToolParams['cancelTask']) { const success = this.batchManager.cancelTask(args.taskId); const result: MCPToolResults['cancelTask'] = { success, message: success ? '任务已取消' : '任务取消失败或任务不存在' }; return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; }
- src/mcp/server.ts:311-324 (registration)Tool registration/definition for cancelTask in getToolDefinitions() method, including name, description, and input schema{ name: 'cancelTask', description: '取消指定的处理任务', inputSchema: { type: 'object', properties: { taskId: { type: 'string', description: '任务ID' } }, required: ['taskId'] } },
- src/types/mcp.ts:38-41 (schema)TypeScript interface definition for cancelTask input parameters (MCPToolParams['cancelTask'])// 取消任务工具参数 cancelTask: { taskId: string; };
- src/types/mcp.ts:64-67 (schema)TypeScript interface definition for cancelTask output result (MCPToolResults['cancelTask'])cancelTask: { success: boolean; message: string; };
- src/core/batch-manager.ts:72-115 (helper)BatchManager.cancelTask: handles cancelling pending tasks by removing from queue or processing tasks by calling videoEngine.cancelTaskpublic cancelTask(taskId: string): boolean { const task = this.tasks.get(taskId); if (!task) { return false; } if (task.status === 'pending') { // 从队列中移除 const queueIndex = this.processingQueue.indexOf(taskId); if (queueIndex > -1) { this.processingQueue.splice(queueIndex, 1); } task.status = 'failed'; task.result = { success: false, outputPaths: [], duration: 0, error: '任务已取消' }; task.completedAt = new Date(); return true; } if (task.status === 'processing') { // 尝试取消正在处理的任务 const videoEngine = VideoEngine.getInstance(); const cancelled = videoEngine.cancelTask(taskId); if (cancelled) { task.status = 'failed'; task.result = { success: false, outputPaths: [], duration: Date.now() - (task.startedAt?.getTime() || 0), error: '任务已取消' }; task.completedAt = new Date(); this.currentProcessingCount--; this.processQueue(); // 继续处理队列 return true; } } return false; }
- src/core/video-engine.ts:299-307 (helper)VideoEngine.cancelTask: kills the running FFmpeg process for the task if foundpublic cancelTask(taskId: string): boolean { const task = this.processingTasks.get(taskId); if (task) { task.kill('SIGKILL'); this.processingTasks.delete(taskId); return true; } return false; }