Skip to main content
Glama
gagarinyury

MCP Bitget Trading Server

by gagarinyury

cancelOrder

Cancel open trading orders on Bitget exchange by specifying order ID and trading pair symbol. This tool manages active positions in cryptocurrency spot and futures markets.

Instructions

Cancel an existing order

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
orderIdYesOrder ID to cancel
symbolYesTrading pair symbol

Implementation Reference

  • MCP server handler for the 'cancelOrder' tool. Parses input arguments using CancelOrderSchema, calls the BitgetRestClient.cancelOrder method, and returns a success or failure message.
    case 'cancelOrder': {
      const { orderId, symbol } = CancelOrderSchema.parse(args);
      const success = await this.bitgetClient.cancelOrder(orderId, symbol);
      return {
        content: [
          {
            type: 'text',
            text: success ? `Order ${orderId} cancelled successfully` : `Failed to cancel order ${orderId}`,
          },
        ],
      } as CallToolResult;
    }
  • Zod schema defining the input parameters for the cancelOrder tool: orderId and symbol.
    export const CancelOrderSchema = z.object({
      orderId: z.string().describe('Order ID to cancel'),
      symbol: z.string().describe('Trading pair symbol')
    });
  • src/server.ts:182-192 (registration)
    Registration of the 'cancelOrder' tool in the MCP server's listTools response, including name, description, and input schema matching the Zod schema.
      name: 'cancelOrder',
      description: 'Cancel an existing order',
      inputSchema: {
        type: 'object',
        properties: {
          orderId: { type: 'string', description: 'Order ID to cancel' },
          symbol: { type: 'string', description: 'Trading pair symbol' }
        },
        required: ['orderId', 'symbol']
      },
    },
  • Core implementation of cancelOrder in BitgetRestClient. Determines if spot or futures based on symbol, then calls the appropriate private cancel method using Bitget API endpoints.
    async cancelOrder(orderId: string, symbol: string): Promise<boolean> {
      if (this.isFuturesSymbol(symbol)) {
        return this.cancelFuturesOrder(orderId, symbol);
      } else {
        return this.cancelSpotOrder(orderId, symbol);
      }
    }
    
    /**
     * Cancel a spot order
     */
    private async cancelSpotOrder(orderId: string, symbol: string): Promise<boolean> {
      const response = await this.request<any>('POST', '/api/v2/spot/trade/cancel-order', {
        orderId,
        symbol
      }, true);
    
      return response.code === '00000';
    }
    
    /**
     * Cancel a futures order
     */
    private async cancelFuturesOrder(orderId: string, symbol: string): Promise<boolean> {
      // Remove _UMCBL suffix for v1 API
      const cleanSymbol = symbol.replace('_UMCBL', '');
      
      const response = await this.request<any>('POST', '/api/v2/mix/order/cancel-order', {
        orderId,
        symbol: cleanSymbol,
        productType: 'USDT-FUTURES',
        marginCoin: 'USDT'
      }, true);
    
      return response.code === '00000';
    }
Behavior2/5

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

With no annotations provided, the description carries full burden but only states the basic action without disclosing critical behavioral traits. It doesn't mention if cancellation is reversible, requires specific permissions, has rate limits, affects account balance, or returns confirmation details, leaving significant gaps for a mutation tool.

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 with zero wasted words, making it easy to parse and front-loaded with the core purpose. It's appropriately sized for a simple tool, though this conciseness comes at the cost of completeness in other dimensions.

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?

For a mutation tool with no annotations and no output schema, the description is incomplete. It lacks details on behavioral aspects like side effects, error conditions, or return values, which are crucial for safe and effective use in a trading context with sibling tools like 'placeOrder' and 'getOrders'.

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 both parameters ('orderId' and 'symbol') adequately. The description adds no additional meaning beyond what the schema provides, such as explaining why both parameters are required or their interaction, but this is acceptable given the high schema coverage.

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 ('Cancel') and target resource ('an existing order'), which is specific and unambiguous. However, it doesn't differentiate from sibling tools like 'placeOrder' or 'getOrders' beyond the obvious verb difference, missing explicit distinction in scope or context.

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?

No guidance is provided on when to use this tool versus alternatives or under what conditions it's appropriate. For example, it doesn't specify prerequisites like order status or timing constraints, nor does it mention sibling tools like 'getOrders' for verification before cancellation.

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

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