Skip to main content
Glama

cancel_all_orders

Cancel all open orders for a trading pair on supported cryptocurrency exchanges to manage positions and reduce risk.

Instructions

Cancel all open orders for a trading pair on a supported exchange

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
exchangeYesExchange to query. Supported: mexc, gateio, bitget, kraken
symbolYesTrading pair symbol (e.g., BTC/USDT, INDY/USDT)

Implementation Reference

  • Main handler implementation for 'cancel_all_orders' tool. Registers the tool with MCP server, validates exchange and symbol parameters, and calls connector.cancelAllOrders() to cancel all open orders for a trading pair.
    server.tool(
      'cancel_all_orders',
      'Cancel all open orders for a trading pair on a supported exchange',
      {
        exchange: ExchangeParam,
        symbol: SymbolParam,
      },
      async ({ exchange, symbol }) => {
        const validExchange = validateExchange(exchange);
        const validSymbol = validateSymbol(symbol);
    
        const connector = await getConnectorSafe(exchange);
        const result = await connector.cancelAllOrders(validSymbol);
    
        return {
          content: [
            {
              type: 'text' as const,
              text: JSON.stringify(
                {
                  cancelled: result,
                  symbol: validSymbol,
                  exchange: validExchange,
                },
                null,
                2
              ),
            },
          ],
        };
      }
    );
  • Schema definitions for ExchangeParam and SymbolParam used by the cancel_all_orders tool. ExchangeParam validates exchange (mexc, gateio, bitget, kraken) and SymbolParam validates trading pair symbols like BTC/USDT.
    export const ExchangeParam = z
      .string()
      .describe('Exchange to query. Supported: mexc, gateio, bitget, kraken');
    
    export const SymbolParam = z.string().describe('Trading pair symbol (e.g., BTC/USDT, INDY/USDT)');
  • Helper function validateSymbol() that normalizes and validates trading pair symbols, converting to uppercase and ensuring correct format (e.g., BTC/USDT).
    export function validateSymbol(symbol: string): string {
      if (!symbol) {
        throw new Error('Symbol is required');
      }
      const upper = symbol.toUpperCase();
      if (!/^[A-Z]+\/[A-Z]+$/.test(upper) && !/^[A-Z]+[A-Z]+$/.test(upper)) {
        throw new Error(`Invalid symbol format: ${symbol}. Expected: BTC/USDT or BTCUSDT`);
      }
      return upper;
    }
  • Related 'stop_strategy' tool that also calls connector.cancelAllOrders() to stop a running grid strategy by cancelling all open orders for a trading pair.
    server.tool(
      'stop_strategy',
      'Cancel all open orders for a trading pair, effectively stopping any running grid strategy',
      {
        exchange: ExchangeParam,
        symbol: SymbolParam,
      },
      async ({ exchange, symbol }) => {
        const validExchange = validateExchange(exchange);
        const validSymbol = validateSymbol(symbol);
    
        const connector = await getConnectorSafe(exchange);
        const openOrders = await connector.getOpenOrders(validSymbol);
        const result = await connector.cancelAllOrders(validSymbol);
    
        return {
          content: [
            {
              type: 'text' as const,
              text: JSON.stringify(
                {
                  status: 'stopped',
                  cancelledOrders: openOrders.length,
                  result,
                  exchange: validExchange,
                  symbol: validSymbol,
                  timestamp: new Date().toISOString(),
                },
                null,
                2
              ),
            },
          ],
        };
      }
    );
  • Helper function getConnectorSafe() that validates exchange and returns a BaseExchangeConnector instance which provides the cancelAllOrders() method used by the tool.
    export async function getConnectorSafe(exchange: string): Promise<BaseExchangeConnector> {
      const validExchange = validateExchange(exchange);
      const { ExchangeFactory } = await import('@3rd-eye-labs/openmm');
      try {
        return await ExchangeFactory.getExchange(validExchange as any);
      } catch (error) {
        const message = error instanceof Error ? error.message : String(error);
        throw new Error(`Failed to connect to ${validExchange}: ${message}`);
      }
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the action ('cancel') but does not describe what 'cancel' entails (e.g., immediate vs. queued, irreversible effects), authentication requirements, rate limits, error conditions, or response format. For a mutation tool with zero annotation coverage, this is a significant gap in behavioral 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 a single, efficient sentence that front-loads the core action and scope without unnecessary words. Every part of the sentence contributes directly to understanding the tool's purpose, making it highly concise and well-structured.

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?

Given the tool's complexity (a mutation operation with potential side effects), lack of annotations, and no output schema, the description is incomplete. It does not address critical aspects like what happens after cancellation (e.g., confirmation, error handling), security requirements, or limitations, leaving significant gaps for an AI agent to understand the tool fully.

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 both parameters ('exchange' and 'symbol') well-documented in the schema. The description does not add any additional meaning beyond what the schema provides (e.g., no extra details on exchange support or symbol formats). Baseline 3 is appropriate as the schema handles the parameter documentation adequately.

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 specific action ('cancel all open orders') and target resource ('for a trading pair on a supported exchange'), distinguishing it from sibling tools like 'cancel_order' (which likely cancels individual orders) and 'list_orders' (which lists rather than cancels). The verb 'cancel' is precise and the scope 'all open orders' is explicitly defined.

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

Usage Guidelines3/5

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

The description implies usage when needing to cancel all open orders for a specific trading pair and exchange, but it does not explicitly state when to use this tool versus alternatives like 'cancel_order' or provide exclusions (e.g., no guidance on prerequisites such as authentication or rate limits). The context is clear but lacks explicit alternatives or when-not-to-use details.

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/QBT-Labs/openmm-mcp'

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