Cancel All Active Orders
virtualsms_cancel_all_ordersCancel 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
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools.ts:1281-1336 (handler)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 ), }, ], }; } - src/tools.ts:64-64 (schema)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, }, }, - src/index.ts:153-155 (handler)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); - src/http-server.ts:139-140 (handler)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);