Skip to main content
Glama

MCP Bitget Trading Server

by gagarinyury

placeOrder

Execute buy or sell orders on Bitget for spot and futures trading. Automatically detects market type, supports limit and market orders, and manages parameters like quantity, price, and time in force for efficient trading.

Instructions

Place a new buy or sell order (automatically detects spot vs futures)

Input Schema

NameRequiredDescriptionDefault
clientOrderIdNoClient order ID
marginCoinNoMargin coin for futures (default: USDT)
marginModeNoMargin mode for futures (default: crossed)
priceNoOrder price (required for limit orders)
quantityYesOrder quantity (in base currency for spot, in contracts for futures)
reduceOnlyNoReduce only flag for futures
sideYesOrder side
symbolYesTrading pair symbol (e.g., BTCUSDT for spot, BTCUSDT_UMCBL for futures)
timeInForceNoTime in force
typeYesOrder type

Input Schema (JSON Schema)

{ "properties": { "clientOrderId": { "description": "Client order ID", "type": "string" }, "marginCoin": { "description": "Margin coin for futures (default: USDT)", "type": "string" }, "marginMode": { "description": "Margin mode for futures (default: crossed)", "enum": [ "crossed", "isolated" ], "type": "string" }, "price": { "description": "Order price (required for limit orders)", "type": "string" }, "quantity": { "description": "Order quantity (in base currency for spot, in contracts for futures)", "type": "string" }, "reduceOnly": { "description": "Reduce only flag for futures", "type": "boolean" }, "side": { "description": "Order side", "enum": [ "buy", "sell" ], "type": "string" }, "symbol": { "description": "Trading pair symbol (e.g., BTCUSDT for spot, BTCUSDT_UMCBL for futures)", "type": "string" }, "timeInForce": { "description": "Time in force", "enum": [ "GTC", "IOC", "FOK" ], "type": "string" }, "type": { "description": "Order type", "enum": [ "market", "limit" ], "type": "string" } }, "required": [ "symbol", "side", "type", "quantity" ], "type": "object" }

Implementation Reference

  • MCP tool handler for placeOrder: parses input with PlaceOrderSchema, detects spot/futures, delegates to BitgetRestClient.placeOrder, returns result
    case 'placeOrder': { const orderParams = PlaceOrderSchema.parse(args); console.error('Received placeOrder request:', JSON.stringify(orderParams, null, 2)); // Determine if this is a futures order const isFutures = orderParams.symbol.includes('_UMCBL') || orderParams.symbol.includes('_'); console.error(`Order type detected: ${isFutures ? 'futures' : 'spot'}`); const order = await this.bitgetClient.placeOrder(orderParams); return { content: [ { type: 'text', text: `Order placed successfully (${isFutures ? 'futures' : 'spot'}):\\n${JSON.stringify(order, null, 2)}`, }, ], } as CallToolResult; }
  • Zod schema for validating placeOrder tool input parameters
    export const PlaceOrderSchema = z.object({ symbol: z.string().describe('Trading pair symbol'), side: z.enum(['buy', 'sell']).describe('Order side'), type: z.enum(['market', 'limit']).describe('Order type'), quantity: z.string().describe('Order quantity'), price: z.string().optional().describe('Order price (required for limit orders)'), timeInForce: z.enum(['GTC', 'IOC', 'FOK']).optional().describe('Time in force'), clientOrderId: z.string().optional().describe('Client order ID'), reduceOnly: z.boolean().optional().describe('Reduce only flag for futures'), marginMode: z.enum(['crossed', 'isolated']).optional().describe('Margin mode for futures (default: crossed)'), marginCoin: z.string().optional().describe('Margin coin for futures (default: USDT)') });
  • src/server.ts:161-180 (registration)
    Tool registration in ListTools response, including name, description, and input schema matching PlaceOrderSchema
    { name: 'placeOrder', description: 'Place a new buy or sell order (automatically detects spot vs futures)', inputSchema: { type: 'object', properties: { symbol: { type: 'string', description: 'Trading pair symbol (e.g., BTCUSDT for spot, BTCUSDT_UMCBL for futures)' }, side: { type: 'string', enum: ['buy', 'sell'], description: 'Order side' }, type: { type: 'string', enum: ['market', 'limit'], description: 'Order type' }, quantity: { type: 'string', description: 'Order quantity (in base currency for spot, in contracts for futures)' }, price: { type: 'string', description: 'Order price (required for limit orders)' }, timeInForce: { type: 'string', enum: ['GTC', 'IOC', 'FOK'], description: 'Time in force' }, clientOrderId: { type: 'string', description: 'Client order ID' }, reduceOnly: { type: 'boolean', description: 'Reduce only flag for futures' }, marginMode: { type: 'string', enum: ['crossed', 'isolated'], description: 'Margin mode for futures (default: crossed)' }, marginCoin: { type: 'string', description: 'Margin coin for futures (default: USDT)' } }, required: ['symbol', 'side', 'type', 'quantity'] }, },
  • Core placeOrder implementation in BitgetRestClient: dispatches to spot or futures order placement based on symbol
    async placeOrder(params: OrderParams): Promise<Order> { if (this.isFuturesSymbol(params.symbol)) { return this.placeFuturesOrder(params); } else { return this.placeSpotOrder(params); } }

Other Tools

Related 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/gagarinyury/MCP-bitget-trading'

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