Skip to main content
Glama
ethancod1ng

Binance MCP Server

by ethancod1ng

place_order

Execute buy or sell orders on Binance exchange using market or limit order types with specified trading pairs and quantities.

Instructions

下单交易 - 支持主网和测试网(主网将使用真实资金)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
priceNo价格,LIMIT订单必需
quantityYes数量
sideYes买卖方向
symbolYes交易对符号,如 BTCUSDT
typeYes订单类型

Implementation Reference

  • The core handler function for the 'place_order' tool. It validates the input using PlaceOrderSchema, constructs the order parameters for the Binance API, executes the order, handles errors with handleBinanceError, and returns a detailed order result object.
    handler: async (binanceClient: any, args: unknown) => {
      const networkMode = validateAndWarnMainnet();
      
      const input = validateInput(PlaceOrderSchema, args);
      validateSymbol(input.symbol);
      validateQuantity(input.quantity);
    
      if (input.type === 'LIMIT' && !input.price) {
        throw new Error('Price is required for LIMIT orders');
      }
    
      if (input.price) {
        validatePrice(input.price);
      }
    
      try {
        const orderParams: any = {
          symbol: input.symbol,
          side: input.side,
          type: input.type,
          quantity: input.quantity,
        };
    
        if (input.type === 'LIMIT' && input.price) {
          orderParams.price = input.price;
          orderParams.timeInForce = 'GTC';
        }
    
        const orderResult = await binanceClient.order(orderParams);
    
        return {
          symbol: orderResult.symbol,
          orderId: orderResult.orderId,
          orderListId: orderResult.orderListId,
          clientOrderId: orderResult.clientOrderId,
          transactTime: orderResult.transactTime,
          price: orderResult.price,
          origQty: orderResult.origQty,
          executedQty: orderResult.executedQty,
          cummulativeQuoteQty: orderResult.cummulativeQuoteQty,
          status: orderResult.status,
          timeInForce: orderResult.timeInForce,
          type: orderResult.type,
          side: orderResult.side,
          fills: orderResult.fills || [],
          timestamp: Date.now(),
          network: networkMode,
        };
      } catch (error) {
        handleBinanceError(error);
      }
    },
  • Zod schema definition for PlaceOrder input validation, defining properties for symbol, side, type, quantity, and optional price with descriptions.
    export const PlaceOrderSchema = z.object({
      symbol: z.string().describe('交易对符号'),
      side: z.enum(['BUY', 'SELL']).describe('买卖方向'),
      type: z.enum(['MARKET', 'LIMIT']).describe('订单类型'),
      quantity: z.string().describe('数量'),
      price: z.string().optional().describe('价格,LIMIT单必需'),
    });
  • Registration of the 'place_order' tool in the tradingTools array export. Includes name, description, JSON inputSchema matching the Zod schema, and references the handler function. This array is imported and used in server.ts for MCP tool setup.
    {
      name: 'place_order',
      description: '下单交易 - 支持主网和测试网(主网将使用真实资金)',
      inputSchema: {
        type: 'object',
        properties: {
          symbol: {
            type: 'string',
            description: '交易对符号,如 BTCUSDT',
          },
          side: {
            type: 'string',
            enum: ['BUY', 'SELL'],
            description: '买卖方向',
          },
          type: {
            type: 'string',
            enum: ['MARKET', 'LIMIT'],
            description: '订单类型',
          },
          quantity: {
            type: 'string',
            description: '数量',
          },
          price: {
            type: 'string',
            description: '价格,LIMIT订单必需',
          },
        },
        required: ['symbol', 'side', 'type', 'quantity'],
      },
      handler: async (binanceClient: any, args: unknown) => {
        const networkMode = validateAndWarnMainnet();
        
        const input = validateInput(PlaceOrderSchema, args);
        validateSymbol(input.symbol);
        validateQuantity(input.quantity);
    
        if (input.type === 'LIMIT' && !input.price) {
          throw new Error('Price is required for LIMIT orders');
        }
    
        if (input.price) {
          validatePrice(input.price);
        }
    
        try {
          const orderParams: any = {
            symbol: input.symbol,
            side: input.side,
            type: input.type,
            quantity: input.quantity,
          };
    
          if (input.type === 'LIMIT' && input.price) {
            orderParams.price = input.price;
            orderParams.timeInForce = 'GTC';
          }
    
          const orderResult = await binanceClient.order(orderParams);
    
          return {
            symbol: orderResult.symbol,
            orderId: orderResult.orderId,
            orderListId: orderResult.orderListId,
            clientOrderId: orderResult.clientOrderId,
            transactTime: orderResult.transactTime,
            price: orderResult.price,
            origQty: orderResult.origQty,
            executedQty: orderResult.executedQty,
            cummulativeQuoteQty: orderResult.cummulativeQuoteQty,
            status: orderResult.status,
            timeInForce: orderResult.timeInForce,
            type: orderResult.type,
            side: orderResult.side,
            fills: orderResult.fills || [],
            timestamp: Date.now(),
            network: networkMode,
          };
        } catch (error) {
          handleBinanceError(error);
        }
      },
    },
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 mentions that mainnet uses real funds, which is a critical safety warning, but lacks other important details: it doesn't specify authentication requirements, rate limits, whether the order is immediate or queued, what happens on failure, or the response format. For a financial transaction tool with zero annotation coverage, this is a significant gap.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose ('下单交易') and adds a useful contextual note about networks. There's no wasted verbiage, and it's appropriately sized for the tool's complexity. However, it could be slightly more structured by separating the network warning into a distinct clause for clarity.

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 high complexity (financial transactions with real funds), lack of annotations, and no output schema, the description is incomplete. It misses critical behavioral details like authentication, error handling, and response format. The network warning is helpful but insufficient to cover the gaps, making it inadequate for safe and effective use by an AI agent.

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 already documents all 5 parameters thoroughly with descriptions and enums. The description adds no additional parameter semantics beyond what's in the schema (e.g., it doesn't explain price/quantity formats beyond 'string', or clarify symbol conventions). With high schema coverage, the baseline score of 3 is appropriate as the description doesn't compensate but doesn't detract either.

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 tool's purpose as '下单交易' (place order), which is a specific verb+resource combination. It distinguishes this from sibling tools like cancel_order or get_open_orders by indicating it's for creating orders rather than managing or querying them. However, it doesn't explicitly differentiate from all siblings (e.g., it doesn't mention this is for order creation vs. price checking like get_price).

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 provides some usage context by mentioning support for mainnet and testnet, with the note that mainnet uses real funds. This implies when to use testnet vs. mainnet. However, it doesn't offer explicit guidance on when to use this tool versus alternatives like market vs. limit orders (though the schema covers this), nor does it mention prerequisites or exclusions relative to siblings.

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/ethancod1ng/binance-mcp-server'

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