cancelTask
Stop an ongoing video processing task in Video Clip MCP by specifying its taskId. Ideal for managing active operations efficiently.
Instructions
取消指定的处理任务
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| taskId | Yes | 任务ID |
Implementation Reference
- src/mcp/server.ts:424-437 (handler)MCP server handler for cancelTask tool: delegates to batchManager.cancelTask and formats the MCP response.private 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)Registration of the cancelTask tool in getToolDefinitions(), including name, description, and input schema.{ name: 'cancelTask', description: '取消指定的处理任务', inputSchema: { type: 'object', properties: { taskId: { type: 'string', description: '任务ID' } }, required: ['taskId'] } },
- src/core/batch-manager.ts:72-115 (helper)Core cancelTask implementation in BatchManager: handles pending tasks by removing from queue, processing tasks by delegating to VideoEngine.public 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)Low-level cancelTask in VideoEngine: kills the FFmpeg process associated with the task ID.public cancelTask(taskId: string): boolean { const task = this.processingTasks.get(taskId); if (task) { task.kill('SIGKILL'); this.processingTasks.delete(taskId); return true; } return false; }
- src/types/mcp.ts:39-41 (schema)TypeScript interface definition for cancelTask input parameters in MCPToolParams.cancelTask: { taskId: string; };