Skip to main content
Glama
Derive MCP Server

Derive MCP Server

by yashhsm

check_multi_leg_margin

Simulate multi-leg strategy margin atomically and sequentially to catch Standard Margin failures where portfolio checks pass but leg-by-leg execution would fail.

Instructions

Pre-flight margin check for multi-leg strategies. Simulates BOTH as an atomic portfolio AND sequentially (leg-by-leg in execution order). CRITICAL for Standard Margin (SM) which does NOT net spreads — short options require full naked margin even with protective long legs. Returns warnings when portfolio simulation passes but sequential execution would fail. Execution order: buy legs first (lowest premium), then sell legs (highest margin). For atomic multi-leg execution, use RFQ instead of CLOB.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "legs": "<legs>"
    },
    "name": "check_multi_leg_margin"
  }
}

Input Schema

NameRequiredDescriptionDefault
legsYesLegs to simulate. Direction is REQUIRED for correct margin analysis.
subaccount_idNoSubaccount ID (defaults to configured)

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A4.6/5.0
Behavior5/5

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

With no annotations, the description carries the full burden and does so well: it discloses dual simulation modes, the SM non-netting caveat, the warning-return behavior on portfolio-vs-sequential divergence, and the execution order used for the sequential pass. This is unusually rich behavioral context for a margin-check tool.

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 purpose is front-loaded in the first sentence, and every subsequent sentence contributes distinct information (simulation modes, SM caveat, warning behavior, execution order, RFQ alternative). No filler or repetition.

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?

Given no output schema and no annotations, the description covers return behavior (warnings), safety-relevant caveats, and leg ordering, which is nearly everything an agent needs. It stops short of stating whether the call is read-only or describing the result payload shape beyond warnings, a minor gap.

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 useful meaning by explaining that legs are evaluated in execution order (buys first by lowest premium, then sells by highest margin), which affects how an agent should construct the legs array. It doesn't explain the string format expectations for amount/entry_price, so it falls short of a 5.

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?

States a specific verb and resource ('Pre-flight margin check for multi-leg strategies') and immediately differentiates itself by explaining it simulates BOTH atomic portfolio and sequential execution. It also distinguishes the tool's role from get_margin (single-margin lookup) and from RFQ-based atomic execution, so an agent can pick it from the sibling catalog.

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

Usage Guidelines4/5

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

Gives clear when-to-use context: pre-flight check before multi-leg orders, especially under Standard Margin. It also provides an explicit exclusion ('For atomic multi-leg execution, use RFQ instead of CLOB'), though it does not name sibling tools like get_margin or create_rfq directly, leaving the agent to map the concept to the catalog.

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