Skip to main content
Glama
Derive MCP Server

Derive MCP Server

by yashhsm

get_margin

Retrieve current margin and optionally simulate position or collateral changes to validate trade impact and amount constraints before placing orders.

Instructions

Get current margin. Optionally simulate position/collateral changes before trading. Validates simulated amounts against instrument minimum_amount and amount_step — if amounts violate constraints, returns is_valid_trade=false with violations (the real order would reject). CRITICAL: Simulation evaluates all positions ATOMICALLY as a portfolio — but orders execute LEG BY LEG. A multi-leg spread may show is_valid_trade=true in simulation but FAIL on execution because each leg is margined independently. For multi-leg strategies: simulate EACH sell/short leg INDIVIDUALLY against current positions to verify it passes margin alone. Standard Margin (SM) does NOT net spreads — short options require full naked margin. Portfolio Margin (PM/PM2) does net spreads. Always check margin_type from get_subaccount before placing short option orders.

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "get_margin"
  }
}

Input Schema

NameRequiredDescriptionDefault
subaccount_idNoSubaccount ID (defaults to configured)
simulated_position_changesNoSimulate position changes to check margin impact
simulated_collateral_changesNoSimulate collateral changes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A4.5/5.0
Behavior4/5

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

With no annotations, the description carries the full burden and largely succeeds: it discloses the atomic-portfolio simulation versus leg-by-leg execution mismatch, the SM versus PM/PM2 netting difference, validation against minimum_amount and amount_step, and the is_valid_trade=false plus violations return on rejection. The only unstated behavior is an explicit declaration that the call is non-mutating and places no orders, which is implied by 'simulate' but never said outright.

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?

It is long for a single tool, but it is front-loaded with purpose then the critical caveat, and the capitalization of CRITICAL makes the highest-risk warning scannable. Nearly every sentence carries decision-relevant content, though the SM/PM netting and the leg-by-leg warnings overlap in intent and could be tightened.

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

Completeness4/5

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

For a read/simulate tool with three optional parameters and no output schema, the description covers the failure and rejection semantics well, including the is_valid_trade and violations fields. It does not describe the margin figures actually returned in the success case (used versus available margin, per-position breakdowns), which is the one area an agent still has to infer.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3, but the description adds real meaning beyond the schema: simulated_position_changes are checked against instrument minimum_amount and amount_step, and the atomic-portfolio evaluation semantics apply to the whole simulated set. It stops short of clarifying units, price semantics of entry_price, or how absent subaccount_id defaults resolve beyond the schema note.

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

Purpose5/5

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

The opening sentence states a specific verb and resource ('Get current margin') and immediately extends it to the simulate-before-trading use case. The scope is bounded enough that an agent can distinguish a margin read/simulation from a position or portfolio listing tool without opening 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 Guidelines5/5

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

The description gives explicit conditional guidance: simulate position/collateral changes 'before trading', simulate each sell/short leg individually for multi-leg strategies, and cross-references get_subaccount to check margin_type before short option orders. It states both when the tool applies and how to avoid the failure mode it warns about, which is well beyond typical guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.