Skip to main content
Glama
ethancod1ng

Bybit MCP Server

by ethancod1ng

place_order

Execute trading orders on Bybit for spot, linear, inverse, and option markets using market or limit order types with configurable parameters.

Instructions

Place a new order (⚠️ WARNING: Can use real funds on mainnet)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
categoryYes
symbolYes
sideYes
orderTypeYes
qtyYes
priceNo
timeInForceNo

Implementation Reference

  • The core handler function in BybitClient that executes the place_order tool by calling Bybit's submitOrder API endpoint.
    async placeOrder(params: {
      category: string;
      symbol: string;
      side: string;
      orderType: string;
      qty: string;
      price?: string;
      timeInForce?: string;
    }) {
      try {
        if (this.config.environment === 'mainnet') {
          console.error('⚠️  WARNING: Placing order on MAINNET with real funds!');
        }
    
        const response = await this.client.submitOrder({
          category: params.category as any,
          symbol: params.symbol,
          side: params.side as any,
          orderType: params.orderType as any,
          qty: params.qty,
          price: params.price,
          timeInForce: params.timeInForce as any
        });
        return response;
      } catch (error) {
        throw new Error(`Failed to place order: ${error instanceof Error ? error.message : JSON.stringify(error)}`);
      }
    }
  • Zod schema defining the input parameters for the place_order tool.
    export const PlaceOrderSchema = z.object({
      category: z.enum(['spot', 'linear', 'inverse', 'option']).describe('Product type'),
      symbol: z.string().describe('Trading symbol'),
      side: z.enum(['Buy', 'Sell']).describe('Order side'),
      orderType: z.enum(['Market', 'Limit']).describe('Order type'),
      qty: 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 (default: GTC)')
    });
  • src/tools.ts:88-95 (registration)
    Tool registration metadata including name, description, and input schema reference, included in the exported tools array used by the MCP server.
      name: 'place_order',
      description: 'Place a new order (⚠️ WARNING: Can use real funds on mainnet)',
      inputSchema: {
        type: 'object',
        properties: PlaceOrderSchema.shape,
        required: ['category', 'symbol', 'side', 'orderType', 'qty']
      }
    },
  • Dispatch handler in MCP server that routes 'place_order' tool calls to the BybitClient.placeOrder method.
    case 'place_order':
      result = await this.client.placeOrder({
        category: args.category as string,
        symbol: args.symbol as string,
        side: args.side as string,
        orderType: args.orderType as string,
        qty: args.qty as string,
        price: args.price as string,
        timeInForce: args.timeInForce as string,
      });
      break;

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

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