Skip to main content
Glama

list_orders

Retrieve open orders from supported cryptocurrency exchanges, with optional filtering by trading pair symbol to monitor active trades.

Instructions

List open orders on a supported exchange, optionally filtered by trading pair symbol

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
exchangeYesExchange to query. Supported: mexc, gateio, bitget, kraken
symbolNoOptional trading pair to filter by (e.g., BTC/USDT). Returns all if omitted.

Implementation Reference

  • Main handler implementation for the list_orders tool. Accepts exchange and optional symbol parameters, validates the exchange, retrieves the connector, fetches open orders, and returns formatted JSON response with orders array, total count, symbol (if provided), and exchange.
    server.tool(
      'list_orders',
      'List open orders on a supported exchange, optionally filtered by trading pair symbol',
      {
        exchange: ExchangeParam,
        symbol: OptionalSymbolParam,
      },
      async ({ exchange, symbol }) => {
        const validExchange = validateExchange(exchange);
    
        const connector = await getConnectorSafe(exchange);
        const orders = await connector.getOpenOrders(symbol);
    
        return {
          content: [
            {
              type: 'text' as const,
              text: JSON.stringify(
                {
                  orders,
                  totalOrders: orders.length,
                  ...(symbol ? { symbol } : {}),
                  exchange: validExchange,
                },
                null,
                2
              ),
            },
          ],
        };
      }
    );
  • Schema definitions for the tool's input parameters. ExchangeParam validates the exchange string (mexc, gateio, bitget, kraken), and OptionalSymbolParam defines an optional trading pair symbol filter.
    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)');
    
    export const OptionalSymbolParam = z
      .string()
      .optional()
      .describe('Optional trading pair to filter by (e.g., BTC/USDT). Returns all if omitted.');
  • Central tool registration function that calls registerAccountTools, which registers the list_orders tool along with other account-related tools like get_balance.
    export function registerTools(server: McpServer): void {
      registerMarketDataTools(server);
      registerAccountTools(server);
      registerTradingTools(server);
      registerCardanoTools(server);
      registerStrategyTools(server);
    }
  • Helper functions used by list_orders: validateExchange ensures the exchange parameter is supported, and getConnectorSafe safely creates and returns the exchange connector instance.
    export function validateExchange(exchange: string): SupportedExchange {
      const lower = exchange.toLowerCase();
      if (!(SUPPORTED_EXCHANGES as readonly string[]).includes(lower)) {
        throw new Error(
          `Unsupported exchange: ${exchange}. Supported: ${SUPPORTED_EXCHANGES.join(', ')}`
        );
      }
      return lower as SupportedExchange;
    }
    
    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}`);
      }
    }
  • src/worker.ts:26-41 (registration)
    Worker server card configuration that lists list_orders as one of the available tools in the MCP server's capabilities.
    capabilities: {
      tools: [
        { name: 'get_ticker' },
        { name: 'get_orderbook' },
        { name: 'get_trades' },
        { name: 'get_balance' },
        { name: 'list_orders' },
        { name: 'create_order' },
        { name: 'cancel_order' },
        { name: 'cancel_all_orders' },
        { name: 'start_grid_strategy' },
        { name: 'stop_strategy' },
        { name: 'get_strategy_status' },
        { name: 'get_cardano_price' },
        { name: 'discover_pools' },
      ],

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