Skip to main content
Glama

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

Implementation Reference

  • MCP tool handler for cancelTask: calls batchManager.cancelTask and returns formatted result
    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),
          },
        ],
      };
    }
  • 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']
      }
    },
  • TypeScript interface definition for cancelTask input parameters (MCPToolParams['cancelTask'])
    // 取消任务工具参数
    cancelTask: {
      taskId: string;
    };
  • TypeScript interface definition for cancelTask output result (MCPToolResults['cancelTask'])
    cancelTask: {
      success: boolean;
      message: string;
    };
  • BatchManager.cancelTask: handles cancelling pending tasks by removing from queue or processing tasks by calling videoEngine.cancelTask
    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;
    }
  • VideoEngine.cancelTask: kills the running FFmpeg process for the task if found
    public cancelTask(taskId: string): boolean {
      const task = this.processingTasks.get(taskId);
      if (task) {
        task.kill('SIGKILL');
        this.processingTasks.delete(taskId);
        return true;
      }
      return false;
    }

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