Skip to main content
Glama
virtualsms-io

VirtualSMS MCP Server

Cancel All Active Orders

virtualsms_cancel_all_orders
DestructiveIdempotent

Cancel every active order in your account to clean up after batch runs or test sessions. Returns the number of orders cancelled and any failures.

Instructions

Bulk-cancel every currently active order in your account. Returns the number of orders cancelled plus any failures. Useful for quick cleanup after a batch run or test session.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function for virtualsms_cancel_all_orders. Fetches all orders, filters for active ones (waiting/pending/sms_received/created), then cancels them all with Promise.allSettled. Returns counts of succeeded/failed cancellations with details.
    export async function handleCancelAllOrders(client: VirtualSMSClient) {
      const orders = await client.listOrders();
      const active = orders.filter((o) => ACTIVE_STATUSES.has(o.status));
    
      if (active.length === 0) {
        return {
          content: [
            {
              type: 'text' as const,
              text: JSON.stringify(
                { cancelled: 0, failed: 0, message: 'No active orders to cancel.' },
                null,
                2
              ),
            },
          ],
        };
      }
    
      const results = await Promise.allSettled(
        active.map((o) =>
          client.cancelOrder(o.order_id).then((res) => ({ order_id: o.order_id, ...res }))
        )
      );
    
      const succeeded: Array<{ order_id: string; refunded: boolean }> = [];
      const failed: Array<{ order_id: string; error: string }> = [];
    
      results.forEach((r, i) => {
        const orderId = active[i].order_id;
        if (r.status === 'fulfilled') {
          succeeded.push({ order_id: orderId, refunded: r.value.refunded });
        } else {
          failed.push({ order_id: orderId, error: (r.reason as Error)?.message ?? String(r.reason) });
        }
      });
    
      return {
        content: [
          {
            type: 'text' as const,
            text: JSON.stringify(
              {
                cancelled: succeeded.length,
                failed: failed.length,
                total_active: active.length,
                cancelled_orders: succeeded,
                failures: failed,
              },
              null,
              2
            ),
          },
        ],
      };
    }
  • Input schema for CancelAllOrdersInput — an empty Zod object (no arguments required).
    export const CancelAllOrdersInput = z.object({});
  • src/tools.ts:427-445 (registration)
    Tool definition registered in TOOL_DEFINITIONS array, with name 'virtualsms_cancel_all_orders', title 'Cancel All Active Orders', destructive annotation, and empty input schema.
    {
      name: 'virtualsms_cancel_all_orders',
      title: 'Cancel All Active Orders',
      description:
        'Bulk-cancel every currently active order in your account. Returns the number of orders ' +
        'cancelled plus any failures. Useful for quick cleanup after a batch run or test session.',
      inputSchema: {
        type: 'object' as const,
        properties: {},
        required: [],
      },
      annotations: {
        title: 'Cancel All Active Orders',
        readOnlyHint: false,
        destructiveHint: true,
        idempotentHint: true,
        openWorldHint: true,
      },
    },
  • Switch-case dispatcher in the main MCP handler that routes 'virtualsms_cancel_all_orders' to handleCancelAllOrders(client).
    case 'virtualsms_cancel_all_orders':
      return await handleCancelAllOrders(client);
  • Switch-case dispatcher in the HTTP server handler that routes 'virtualsms_cancel_all_orders' to handleCancelAllOrders(client).
    case 'virtualsms_cancel_all_orders':
      return await handleCancelAllOrders(client);
Behavior4/5

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

Annotations already indicate destructiveHint=true and readOnlyHint=false, so the description's job is lighter. It adds value by specifying return values ('number of orders cancelled plus any failures'), which informs the agent of the outcome. It could mention the irreversible nature, but overall it adds useful context.

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 two sentences, front-loaded with the action, and includes a usage hint. Every sentence adds value with no redundancy.

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?

Given no output schema, the description compensates by mentioning return values. Annotations cover destruction. It could mention what happens to other resources or confirmation steps, but it is mostly complete for a zero-parameter bulk action.

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

Parameters4/5

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

The tool has zero parameters, so per guidelines the baseline is 4. The description rightly includes no parameter details, and the schema covers everything.

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 clearly states the action: 'Bulk-cancel every currently active order in your account.' It uses a specific verb ('bulk-cancel') and resource ('every active order'), and distinguishes itself from the sibling tool 'virtualsms_cancel_order' which cancels a single order.

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 provides context for when to use this tool: 'Useful for quick cleanup after a batch run or test session.' While it doesn't explicitly exclude other scenarios or name alternatives, the sibling tools (e.g., 'virtualsms_cancel_order') imply the singular use case, and the context is sufficient.

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

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