Skip to main content
Glama
gagarinyury

MCP Bitget Trading Server

by gagarinyury

setLeverage

Adjust leverage levels for futures trading positions on Bitget to manage risk exposure and trading strategy execution.

Instructions

Set leverage for futures trading

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolYesTrading pair symbol
leverageYesLeverage value (1-125)

Implementation Reference

  • MCP tool handler for setLeverage: parses input using schema, calls BitgetRestClient.setLeverage, and returns success message
    case 'setLeverage': {
      const { symbol, leverage } = SetLeverageSchema.parse(args);
      const success = await this.bitgetClient.setLeverage(symbol, leverage);
      return {
        content: [
          {
            type: 'text',
            text: success 
              ? `Leverage set to ${leverage}x for ${symbol}` 
              : `Failed to set leverage for ${symbol}`,
          },
        ],
      } as CallToolResult;
    }
  • Zod input schema for setLeverage tool validation
    export const SetLeverageSchema = z.object({
      symbol: z.string().describe('Trading pair symbol'),
      leverage: z.number().min(1).max(125).describe('Leverage value (1-125)')
    });
  • BitgetRestClient method implementing the setLeverage logic by calling Bitget's REST API endpoint
    async setLeverage(symbol: string, leverage: number): Promise<boolean> {
      // Remove _UMCBL suffix for v2 API (like in candles)
      const cleanSymbol = symbol.replace('_UMCBL', '');
      
      const response = await this.request<any>('POST', '/api/v2/mix/account/set-leverage', {
        symbol: cleanSymbol,
        productType: 'USDT-FUTURES',
        marginCoin: 'USDT',  // Required parameter!
        leverage: leverage.toString(),
        holdSide: 'long'
      }, true);
    
      return response.code === '00000';
    }
  • src/server.ts:217-227 (registration)
    Tool registration/definition in the ListTools response, including name, description, and input schema
      name: 'setLeverage',
      description: 'Set leverage for futures trading',
      inputSchema: {
        type: 'object',
        properties: {
          symbol: { type: 'string', description: 'Trading pair symbol' },
          leverage: { type: 'number', minimum: 1, maximum: 125, description: 'Leverage value (1-125)' }
        },
        required: ['symbol', 'leverage']
      },
    },
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. 'Set leverage for futures trading' implies a mutation operation that could affect risk and margin requirements, but it doesn't disclose critical behaviors: whether changes apply immediately or at next trade, if there are rate limits, permission requirements, or confirmation of success. This leaves significant gaps for safe agent operation.

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 states the core function without unnecessary words. It's front-loaded with the essential action and resource, making it easy to parse. Every word earns its place, with no redundant information or structural issues.

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 trading mutation tool with no annotations and no output schema, the description is incomplete. It lacks information on success/failure responses, error conditions, side effects (e.g., margin calls), and operational constraints. For a tool that modifies risk parameters, this leaves the agent under-informed about critical execution 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%, with both parameters (symbol and leverage) well-documented in the schema itself. The description adds no additional parameter semantics beyond what's already in the schema—it doesn't explain format examples for 'symbol' or implications of leverage values. This meets the baseline for high schema coverage but doesn't enhance understanding.

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 ('Set') and resource ('leverage for futures trading'), making the purpose immediately understandable. It distinguishes from siblings like placeOrder or getMarginInfo by focusing on leverage configuration rather than order execution or information retrieval. However, it doesn't specify if this applies to existing positions or new ones, leaving some ambiguity.

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. It doesn't mention prerequisites (e.g., needing an open futures position or account permissions), timing considerations, or relationships to other tools like getMarginInfo for checking current leverage. The agent must infer usage from context alone.

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