Skip to main content
Glama
aadarshvelu

Derive MCP Server

by aadarshvelu

get_margin

Calculate margin requirements for hypothetical portfolios by simulating positions and collaterals with Derive market data.

Instructions

Simulate margin requirements for a hypothetical portfolio

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
margin_typeYesMargin type: PM (Portfolio), PM2, or SM (Standard)
simulated_collateralsYesList of simulated collaterals
simulated_positionsYesList of simulated positions
marketNoMarket (required for Portfolio Margin)

Implementation Reference

  • Method in the DeriveClient class that performs the actual API call for 'get_margin'.
    getMargin(params: GetMarginParams): Promise<unknown> {
      return this.post('public/get_margin', params);
    }
  • src/tools.ts:177-212 (registration)
    Registration of the 'get_margin' tool with its input schema definition.
      name: 'get_margin',
      description: 'Simulate margin requirements for a hypothetical portfolio',
      inputSchema: {
        type: 'object',
        properties: {
          margin_type: { type: 'string', enum: MARGIN_TYPE_ENUM, description: 'Margin type: PM (Portfolio), PM2, or SM (Standard)' },
          simulated_collaterals: {
            type: 'array',
            items: {
              type: 'object',
              properties: {
                amount: { type: 'string', description: 'Collateral amount' },
                asset_name: { type: 'string', description: 'Asset name, e.g. USDC' },
              },
              required: ['amount', 'asset_name'],
            },
            description: 'List of simulated collaterals',
          },
          simulated_positions: {
            type: 'array',
            items: {
              type: 'object',
              properties: {
                amount: { type: 'string', description: 'Position size' },
                instrument_name: { type: 'string', description: 'Instrument name' },
                entry_price: { type: 'string', description: 'Entry price' },
              },
              required: ['amount', 'instrument_name'],
            },
            description: 'List of simulated positions',
          },
          market: { type: 'string', description: 'Market (required for Portfolio Margin)' },
        },
        required: ['margin_type', 'simulated_collaterals', 'simulated_positions'],
      },
    },

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/aadarshvelu/derive-mcp'

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