Skip to main content
Glama

ForexDemo.com

Margin and Leverage Calculator

calculate_margin
Read-onlyIdempotent

Margin needed to open a Forex or gold trade at a given leverage or margin percentage, and, with a balance, the free margin, margin level and the prices of the margin call and stop out. Same calculation as the Margin and Leverage Calculator page at https://forexdemo.com/forex-margin-calculator.html. Every input is optional unless marked required; left-out inputs use the page's defaults, which are listed in the reply.

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": "calculate_margin"
  }
}

Input Schema

NameRequiredDescriptionDefault
pairNoCurrency pair or gold (XAU/USD). EURUSD and eur-usd are accepted too.EUR/USD
rateNoOnly needed when the account currency is not in the pair: the price of the market pair that converts it (for example the GBP/USD price for EUR/GBP in a USD account). Leave it out to use the example price.
sideNobuy (long) or sell (short).buy
sizeNoTrade size, counted in sizeUnit.
priceNoPair price when the trade opens. Leave it out to use the example price.
balanceNoOptional account balance, for free margin, margin level and margin call prices.
currencyNoThe currency the trading account is held in.USD
leverageNoLeverage, such as 30 or 1:30.50
sizeUnitNoHow the size is given: standard (100,000 units), mini (10,000), micro (1,000), nano (100) lots, or units.standard
marginModeNoleverage: give leverage. percent: give the margin requirement as a percentage.leverage
stopOutLevelNoStop out level in percent.
marginPercentNoMargin requirement in percent (marginMode percent). Give 2 for 2%.
marginCallLevelNoMargin call level in percent.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A3.5/5.0
Behavior3/5

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

Annotations already establish readOnlyHint, idempotentHint, openWorldHint=false, so the safety profile is covered. The description adds genuinely useful behavior: every input is optional and omitted inputs fall back to the reference page's defaults, which are echoed in the reply. It does not describe output fields or numeric precision, and does not contradict any annotation.

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?

Front-loads the computation and its outputs in the first clause, then adds the optional-inputs rule. Nothing is repeated, though the URL citation is supporting context rather than essential information.

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 13-parameter, zero-required computational tool with no output schema, the description names the returned quantities (margin, free margin, margin level, call and stop-out prices) and explains the defaulting contract. Only the exact response shape and number formatting are left unspecified, which is minor for a pure calculator.

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 all 13 parameters are already documented at field level, and the schema already explains rate, marginMode, and sizeUnit. The description only adds the cross-cutting rule that inputs are optional with page defaults, giving baseline 3 credit without compensating for any gap.

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 a specific computation and enumerates the outputs: required margin, and with a balance the free margin, margin level, and margin call/stop out prices. It anchors the definition to a named reference page so the semantics are unambiguous. It does not, however, differentiate itself from sibling calculators such as calculate_position_size or calculate_profit.

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

Usage Guidelines3/5

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

Usage is only implied: the presence of a balance parameter signals that margin-call outputs require it. There is no explicit statement of when to prefer this over calculate_position_size or calculate_risk_reward, and no exclusions.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources