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;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but only states the action without behavioral details. It doesn't disclose if cancellation is reversible, requires specific permissions, affects other tasks, has rate limits, or what happens on success/failure (e.g., partial rollback). This is inadequate for a mutation tool with zero annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero wasted words. It's appropriately sized for a simple tool and front-loaded with the core action, though it could benefit from more context.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a mutation tool with no annotations and no output schema, the description is incomplete. It lacks crucial context like behavioral effects, error conditions, or return values. Given the server context (video processing tools), it should clarify what 'cancel' entails (e.g., stops processing, deletes partial files).

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100% with one parameter ('taskId') documented in the schema. The description adds no additional meaning beyond implying 'taskId' identifies the task to cancel, which is already clear from the schema. Baseline 3 is appropriate as the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description '取消指定的处理任务' clearly states the action (cancel) and target (specified processing task). It uses a specific verb and resource, though it doesn't explicitly differentiate from sibling tools like 'getTaskStatus' or 'batchProcess' which might involve task management.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., task must be running), exclusions (e.g., cannot cancel completed tasks), or refer to sibling tools like 'getTaskStatus' for checking task state before cancellation.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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