Skip to main content
Glama
ReverseCentaurAI

ReverseCentaur

Official

Cancel Task

cancel_task
Destructive

Cancel a posted task and receive a full refund if no worker is assigned; pay a cancellation fee if work has started. This action is irreversible.

Instructions

Cancel a previously posted task. Use when the task is no longer needed or was posted in error. If no worker has been assigned, the full budget is refunded. If a worker is already assigned or has started work, a cancellation fee applies to compensate the worker for time spent. The response includes the exact refund amount and any fees. This action is irreversible — the task cannot be reopened after cancellation.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
task_idYesThe task ID to cancel
reasonNoOptional reason for cancellation

Implementation Reference

  • Main handler function that registers the 'cancel_task' tool with the MCP server. Takes task_id (required) and reason (optional, max 500 chars). Calls either the API client's cancelTask method or the mock fallback. Returns refund amount and cancellation fee details.
    export function registerCancelTask(
      server: McpServer,
      client: ApiClient | null,
    ): void {
      server.registerTool(
        'cancel_task',
        {
          title: 'Cancel Task',
          description:
            'Cancel a previously posted task. Use when the task is no longer needed or was posted in error. ' +
            'If no worker has been assigned, the full budget is refunded. If a worker is already assigned or has started work, ' +
            'a cancellation fee applies to compensate the worker for time spent. The response includes the exact refund amount and any fees. ' +
            'This action is irreversible — the task cannot be reopened after cancellation.',
          inputSchema: z.object({
            task_id: z.string().describe('The task ID to cancel'),
            reason: z
              .string()
              .max(500)
              .optional()
              .describe('Optional reason for cancellation'),
          }),
          annotations: { readOnlyHint: false, destructiveHint: true },
        },
        async (args) => {
          try {
            const result = client
              ? await client.cancelTask(args.task_id, args.reason)
              : mockCancelTask(args.task_id, args.reason);
    
            return {
              content: [
                {
                  type: 'text' as const,
                  text: [
                    result.message,
                    `Refund: $${result.refund_usd.toFixed(2)}`,
                    result.cancellation_fee_usd > 0
                      ? `Cancellation fee: $${result.cancellation_fee_usd.toFixed(2)}`
                      : 'No cancellation fee.',
                  ].join('\n'),
                },
              ],
            };
          } catch (error) {
            return toolError(error);
          }
        },
      );
    }
  • Type definition for the CancelTask response, including task_id, status (always 'cancelled'), refund_usd, cancellation_fee_usd, and a message string.
    export interface CancelTaskResponse {
      task_id: string;
      status: 'cancelled';
      refund_usd: number;
      cancellation_fee_usd: number;
      message: string;
    }
  • src/server.ts:57-62 (registration)
    Registration call that wires the cancel_task tool into the MCP server at startup.
    registerPostTask(server, client);
    registerCheckTask(server, client);
    registerListCapabilities(server, client);
    registerCancelTask(server, client);
    registerSendTaskMessage(server, client);
    registerListTaskMessages(server, client);
  • Mock implementation of cancelTask for when no API client is available. Returns a hardcoded $5.00 refund with no fee.
    export function mockCancelTask(taskId: string, _reason?: string): CancelTaskResponse {
      mockTasks.delete(taskId);
      return {
        task_id: taskId,
        status: 'cancelled',
        refund_usd: 5.0,
        cancellation_fee_usd: 0,
        message: `Task ${taskId} cancelled successfully (mock mode).`,
      };
    }
  • API client method that sends a POST request to /v1/tasks/{taskId}/cancel with an optional reason body.
    async cancelTask(taskId: string, reason?: string): Promise<CancelTaskResponse> {
      return this.request<CancelTaskResponse>(
        'POST',
        `/v1/tasks/${encodeURIComponent(taskId)}/cancel`,
        reason ? { reason } : undefined,
      );
    }
Behavior5/5

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

Annotations provide destructiveHint=true, but the description adds substantial context: detailed refund/fee logic based on assignment status, and explicitly states the action is irreversible. This fully informs the agent of the tool's behavioral traits.

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 four sentences, each earning its place: purpose, usage condition, behavioral detail, and irreversibility. No redundant or irrelevant content.

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

Completeness4/5

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

The description covers key return information (refund amount and fees) and irreversibility, but does not mention potential error cases (e.g., invalid task_id or already cancelled). Given the tool's moderate complexity, it is largely adequate.

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%, so the description does not need to add parameter details. It adds no extra meaning beyond the schema, resulting in the baseline score of 3.

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

Purpose5/5

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

The description begins with 'Cancel a previously posted task,' which directly states the action (cancel) and resource (task). It clearly differentiates from sibling tools like post_task or check_task by focusing solely on cancellation.

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

Usage Guidelines4/5

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

The description explicitly states when to use the tool ('when the task is no longer needed or was posted in error') and explains behavior under different conditions (refund vs fee). It does not mention alternatives or when not to use, but the context is clear.

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/ReverseCentaurAI/mcp-server'

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