Skip to main content
Glama

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
NameRequiredDescriptionDefault
taskIdYes任务ID

Implementation Reference

  • 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), }, ], };
  • 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'] } },
  • 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; }
  • 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; }
  • TypeScript interface definition for cancelTask input parameters in MCPToolParams.
    cancelTask: { taskId: string; };

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/pickstar-2002/video-clip-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server