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'],
      },
    },
Behavior3/5

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

Declares the simulation/non-destructive nature ('Simulate', 'hypothetical'), which is critical behavioral context given no annotations. However, lacks disclosure about what the tool returns (margin totals, risk arrays, liquidation levels), calculation methodology, or any rate/authentication constraints.

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

Conciseness4/5

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

Single sentence is front-loaded and wastes no words. However, for a complex financial simulation tool with four parameters (including nested array objects), the extreme brevity makes it underspecified despite being technically concise.

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?

Inadequate for the domain complexity. No output schema exists, yet description gives no indication of return structure (e.g., margin total, maintenance requirements, currency breakdown). With 100% schema coverage handling inputs but zero behavioral annotations, the description fails to compensate for missing output documentation.

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 coverage is 100%, establishing baseline 3. Description mentions 'hypothetical portfolio' which loosely maps to the simulated_positions and simulated_collaterals arrays, but adds no specific guidance on parameter formats, valid asset names, or the distinction between Portfolio Margin (PM) and Standard Margin (SM) beyond what the schema enum already provides.

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?

States specific action 'Simulate' and resource 'margin requirements' clearly. Mentions 'hypothetical portfolio' which distinguishes from real-margin tools and aligns with 'simulated_' parameters. However, lacks explicit differentiation from sibling data-retrieval tools (e.g., get_instrument) and doesn't specify what margin types (PM/SM) represent beyond 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 Guidelines2/5

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

Provides no guidance on when to use this simulation tool versus retrieving actual margin data. No mention of prerequisites (e.g., understanding of portfolio margin vs standard margin) or when the simulation is appropriate versus using real position endpoints.

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

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