Skip to main content
Glama

set_margin_mode

Configure margin trading settings on Bybit exchange to manage risk exposure by setting isolated or cross margin modes with specific leverage for buying and selling positions.

Instructions

Set margin mode

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
categoryYesCategory (spot, linear, inverse, etc.)
symbolYesSymbol (e.g., BTCUSDT)
tradeModeYesTrading mode (0: Isolated, 1: Cross)
buyLeverageYesBuying leverage
sellLeverageYesSelling leverage

Implementation Reference

  • The core handler function implementing the set_margin_mode tool logic by calling the Bybit API endpoint /v5/account/set-margin-mode.
    async setMarginMode(
      category: string,
      symbol: string,
      tradeMode: number,
      buyLeverage: string,
      sellLeverage: string
    ): Promise<BybitResponse<any> | { error: string }> {
      return this.makeBybitRequest('/v5/account/set-margin-mode', 'POST', {
        category,
        symbol,
        tradeMode,
        buyLeverage,
        sellLeverage
      });
    }
  • The input schema defining parameters for the set_margin_mode tool: category, symbol, tradeMode, buyLeverage, sellLeverage.
    inputSchema: {
      type: 'object',
      properties: {
        category: {
          type: 'string',
          description: 'Category (spot, linear, inverse, etc.)',
        },
        symbol: {
          type: 'string',
          description: 'Symbol (e.g., BTCUSDT)',
        },
        tradeMode: {
          type: 'number',
          description: 'Trading mode (0: Isolated, 1: Cross)',
        },
        buyLeverage: {
          type: 'string',
          description: 'Buying leverage',
        },
        sellLeverage: {
          type: 'string',
          description: 'Selling leverage',
        },
      },
      required: ['category', 'symbol', 'tradeMode', 'buyLeverage', 'sellLeverage'],
  • src/index.ts:420-448 (registration)
    Tool registration in the listTools response, including name, description, and input schema.
      name: 'set_margin_mode',
      description: 'Set margin mode',
      inputSchema: {
        type: 'object',
        properties: {
          category: {
            type: 'string',
            description: 'Category (spot, linear, inverse, etc.)',
          },
          symbol: {
            type: 'string',
            description: 'Symbol (e.g., BTCUSDT)',
          },
          tradeMode: {
            type: 'number',
            description: 'Trading mode (0: Isolated, 1: Cross)',
          },
          buyLeverage: {
            type: 'string',
            description: 'Buying leverage',
          },
          sellLeverage: {
            type: 'string',
            description: 'Selling leverage',
          },
        },
        required: ['category', 'symbol', 'tradeMode', 'buyLeverage', 'sellLeverage'],
      },
    },
  • src/index.ts:908-924 (registration)
    Dispatch handler in the CallToolRequestSchema that routes set_margin_mode calls to BybitService.setMarginMode.
    case 'set_margin_mode': {
      const result = await this.bybitService.setMarginMode(
        typedArgs.category,
        typedArgs.symbol,
        typedArgs.tradeMode,
        typedArgs.buyLeverage,
        typedArgs.sellLeverage
      );
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(result, null, 2),
          },
        ],
      };
    }
Behavior1/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 but fails completely. 'Set margin mode' implies a configuration change but doesn't indicate whether this is a destructive operation, what permissions are required, whether changes are reversible, or what happens on success/failure. For a 5-parameter mutation tool with zero annotation coverage, this is dangerously inadequate.

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

Conciseness2/5

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

While technically concise with just three words, this represents under-specification rather than effective brevity. The description fails to provide any of the necessary context that would help an agent understand and use the tool correctly. Every sentence should earn its place, but here the single 'sentence' doesn't earn its place by adding value.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given this is a 5-parameter mutation tool with no annotations and no output schema, the description is completely inadequate. It doesn't explain what the tool does beyond the name, provides no behavioral context, and offers no guidance on usage. For a financial trading tool that likely modifies account/trading settings, this level of documentation is insufficient and potentially dangerous.

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 with reasonable clarity. The description adds zero additional parameter information beyond what's in the schema. According to scoring rules, when schema coverage is high (>80%), the baseline is 3 even with no param info in the description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose2/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Set margin mode' is essentially a tautology that restates the tool name without adding meaningful context. It doesn't specify what 'margin mode' refers to (e.g., isolated vs. cross margin, leverage settings) or what resource is being modified. While the verb 'set' is clear, the object 'margin mode' is too vague without the parameter context from the schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides absolutely no guidance on when to use this tool versus alternatives. It doesn't mention any prerequisites, appropriate contexts, or relationships to sibling tools like 'set_leverage' or 'set_trading_stop'. An agent would have no indication of when this operation is needed versus other configuration tools.

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

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