Skip to main content
Glama

create_order

Place limit or market orders on supported cryptocurrency exchanges like MEXC, Gate.io, Bitget, and Kraken for trading pairs such as BTC/USDT.

Instructions

Create a new order (limit or market) 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)
typeYesOrder type: limit or market
sideYesOrder side: buy or sell
amountYesOrder amount in base currency
priceNoOrder price (required for limit orders, ignored for market orders)

Implementation Reference

  • The main handler function that executes the create_order tool logic. It validates inputs, gets the exchange connector, calls connector.createOrder(), and returns the order result as JSON.
    async ({ exchange, symbol, type, side, amount, price }) => {
      const validExchange = validateExchange(exchange);
      const validSymbol = validateSymbol(symbol);
    
      if (type === 'limit' && price === undefined) {
        throw new Error('Price is required for limit orders');
      }
    
      const connector = await getConnectorSafe(exchange);
      const order = await connector.createOrder(validSymbol, type, side, amount, price);
    
      return {
        content: [
          {
            type: 'text' as const,
            text: JSON.stringify(
              {
                order,
                exchange: validExchange,
              },
              null,
              2
            ),
          },
        ],
      };
    }
  • The input validation schema for create_order using zod. Defines exchange, symbol, type (limit/market), side (buy/sell), amount, and optional price parameters.
    {
      exchange: ExchangeParam,
      symbol: SymbolParam,
      type: z.enum(['limit', 'market']).describe('Order type: limit or market'),
      side: z.enum(['buy', 'sell']).describe('Order side: buy or sell'),
      amount: z.number().positive().describe('Order amount in base currency'),
      price: z
        .number()
        .positive()
        .optional()
        .describe('Order price (required for limit orders, ignored for market orders)'),
    },
  • The tool registration call using server.tool() that registers create_order with the MCP server, including the tool name, description, schema, and handler function.
    server.tool(
      'create_order',
      'Create a new order (limit or market) on a supported exchange',
      {
        exchange: ExchangeParam,
        symbol: SymbolParam,
        type: z.enum(['limit', 'market']).describe('Order type: limit or market'),
        side: z.enum(['buy', 'sell']).describe('Order side: buy or sell'),
        amount: z.number().positive().describe('Order amount in base currency'),
        price: z
          .number()
          .positive()
          .optional()
          .describe('Order price (required for limit orders, ignored for market orders)'),
      },
      async ({ exchange, symbol, type, side, amount, price }) => {
        const validExchange = validateExchange(exchange);
        const validSymbol = validateSymbol(symbol);
    
        if (type === 'limit' && price === undefined) {
          throw new Error('Price is required for limit orders');
        }
    
        const connector = await getConnectorSafe(exchange);
        const order = await connector.createOrder(validSymbol, type, side, amount, price);
    
        return {
          content: [
            {
              type: 'text' as const,
              text: JSON.stringify(
                {
                  order,
                  exchange: validExchange,
                },
                null,
                2
              ),
            },
          ],
        };
      }
    );
  • Helper schemas used by create_order: ExchangeParam (validates exchange name) and SymbolParam (validates trading pair symbol format).
    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)');
  • The validateSymbol helper function used in the create_order handler to validate and normalize the trading pair symbol (converts to uppercase, checks format).
    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;
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions the tool creates orders but fails to describe critical behaviors like authentication needs, rate limits, whether the order is executed immediately, error handling, or what the response contains. This leaves significant gaps for an agent to understand how to use it effectively.

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 ('Create a new order') and includes essential details (order types and context) without any wasted words. Every part of the sentence contributes directly to understanding the tool's purpose.

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 complexity of a financial order creation tool with no annotations and no output schema, the description is insufficient. It lacks details on authentication, execution behavior, error cases, and return values, which are critical for an agent to invoke this tool correctly in a trading context.

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 schema fully documents all parameters. The description adds no additional meaning beyond what's in the schema, such as explaining parameter interactions (e.g., 'price' is ignored for market orders, which is already in the schema). Baseline 3 is appropriate as the schema does the heavy lifting.

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

Purpose4/5

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

The description clearly states the action ('Create a new order') and specifies the resource ('order') with types ('limit or market') and context ('on a supported exchange'), making the purpose unambiguous. However, it doesn't differentiate from sibling tools like 'cancel_order' or 'list_orders' beyond the creation aspect.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives like 'cancel_order' or 'list_orders', nor does it mention prerequisites such as authentication or balance requirements. It only states what the tool does without contextual usage instructions.

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