Skip to main content
Glama

Close Positions

close_positions
Destructive

Close open positions on a Connections account (all asset classes, all brokers). ONE call closes every matching position or ticket: omit symbol to flatten the account, or pass symbol to close every ticket for it (e.g. all TradeLocker XAUUSD tickets). Never loop over tickets one at a time to close a stack. If the agent requires confirmation (HITL) and several positions match, the first call returns status=confirmation_required with positions_to_close: show them, then repeat the call with confirm_close_all=true. Fully autonomous agents (AITL) close in the first call. Use position_id only when the user wants ONE specific ticket. May return pending_confirmation when HITL is on.

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

Input Schema

NameRequiredDescriptionDefault
sideNoOptional; required when multiple sides (long/short or yes/no) exist for the symbol.
symbolNoOptional — omit to close all positions on the account.
quantityNoOptional partial close; omit for full position. Requires symbol.
position_idNoOptional — only to close ONE specific ticket from get_positions. Omit it to close all tickets for the symbol in one call.
broker_account_idNoaccount_ref from list_brokers (e.g. "alpaca-paper-93461"). Required when more than one enabled account exists.
confirm_close_allNoHITL agents only: set true on the repeat call after a confirmation_required response (show positions_to_close first). Ignored for fully autonomous (AITL) agents.

Output Schema

NameRequiredDescriptionDefault
errorNo
messageNo
successNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changed
    • changedInput schema / properties / confirm_close_all / description
      Previous value: -"Required true when closing more than one position. Show positions_to_close from a prior response first."New value: +"HITL agents only: set true on the repeat call after a confirmation_required response (show positions_to_close first). Ignored for fully autonomous (AITL) agents."
    • changedInput schema / properties / position_id / description
      Previous value: -"Optional broker ticket / position id from get_positions to close exactly one ticket."New value: +"Optional — only to close ONE specific ticket from get_positions. Omit it to close all tickets for the symbol in one call."
  2. Changed3 schema fields changed
    • changedInput schema / properties / broker_account_id / description
      Previous value: -"Integer id from list_brokers. Required when more than one enabled account exists."New value: +"account_ref from list_brokers (e.g. \"alpaca-paper-93461\"). Required when more than one enabled account exists."
    • changedInput schema / properties / broker_account_id / type
      Previous value: -"integer"New value: +"string"
    • addedInput schema / properties / position_id
      Added value: +{
      +  "description": "Optional broker ticket / position id from get_positions to close exactly one ticket.",
      +  "type": "string"
      +}
  3. Changed2 schema fields changed
    • changedOutput schema / description
      Previous value: -"Structured Gogi result. Error responses include error and message fields."New value: +"Structured result. Error responses include error and message."
    • addedOutput schema / properties
      Added value: +{
      +  "error": {
      +    "type": "string"
      +  },
      +  "message": {
      +    "type": "string"
      +  },
      +  "success": {
      +    "type": "boolean"
      +  }
      +}
  4. Changed1 schema field changed
    • changedOutput schema / (root)
      Previous value: -nullNew value: +{
      +  "additionalProperties": true,
      +  "description": "Structured Gogi result. Error responses include error and message fields.",
      +  "type": "object"
      +}
  5. First observed

TDQS

A4.8/5.0
Behavior5/5

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

Beyond the destructive/openWorld annotations, the description discloses the full HITL confirmation protocol: the first call returns status=confirmation_required with positions_to_close, and the agent must repeat with confirm_close_all=true, while AITL agents close immediately. It also warns about a possible pending_confirmation return, which is behavior an agent cannot infer from the schema or annotations.

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 front-loaded with the core action and scope, then moves down to branching and confirmation flow. The parenthetical example ('e.g. all TradeLocker XAUUSD tickets') earns its place as a disambiguator, but a few clauses could be tightened without losing meaning.

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

Completeness5/5

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

For a destructive, open-world, non-idempotent multi-asset close tool, the description covers scope, granularity, confirmation handling, and the pending_confirmation case. An output schema exists, so it need not explain return payloads in general, and the one return shape that matters (positions_to_close) is described.

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 workflow meaning the schema does not: the symbol-vs-position_id tradeoff, and the confirm_close_all repeat-call sequence tied to the confirmation_required response. The side parameter's multiple-sides condition is only covered by the schema, so it is not fully elaborated here.

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 first sentence gives a specific verb and resource plus scope: 'Close open positions on a Connections account (all asset classes, all brokers).' The next sentence defines the granularity of the operation (one call closes every matching position or ticket), which separates it cleanly from siblings like get_positions, cancel_pending_trade, and execute_trade.

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?

It gives explicit branching rules: omit symbol to flatten the account, pass symbol to close every ticket for it, and use position_id only when the user wants one specific ticket. It also states an anti-pattern ('Never loop over tickets one at a time') and names the sibling source for position_id (get_positions), so an agent knows both when to use this tool and when not to.

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