Skip to main content
Glama

close_position

Destructive

Closes a coin's entire open position immediately with one full-size market order; partial closes are unsupported. Use when the user asks to exit now, then cancel stale stop and target orders.

Instructions

LIVE MONEY: acts on the real account. Close a coin's entire open position now with one market order for the full size; partial closes are not supported, and like any market order it pays the spread and slippage of the book. A flat coin returns ok=true with noop already_flat and sends nothing. Closes are never refused for a delisted coin. Afterwards run sweep_brackets on the coin to cancel the stop and target that no longer protect anything. Use when the user asks to exit now; to exit at a price instead, move the level with set_stop or set_target. Needs a trading key. Returns {ok, result: {total_sz, avg_px}} or {error} with isError true.

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": {
      "coin": "<coin>"
    },
    "name": "close_position"
  }
}

Input Schema

NameRequiredDescriptionDefault
coinYesCoin: a main-dex perp by name (BTC, ETH) or a HIP-3 perp as dex:SYMBOL (xyz:GOLD, xyz:BRENTOIL).

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.6.1
    • changedInput schema / properties / coin / description
      Previous value: -"Coin ticker (e.g. BTC, ETH)"New value: +"Coin: a main-dex perp by name (BTC, ETH) or a HIP-3 perp as dex:SYMBOL (xyz:GOLD, xyz:BRENTOIL)."
  2. First observedv0.1.0

TDQS

A4.7/5.0
Behavior5/5

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

The annotations only give destructiveHint=true, and the description carries everything else: live-money risk, no partial closes, spread/slippage cost, the no-op path ('a flat coin returns ok=true with noop already_flat and sends nothing'), delisted-coin behavior, trading-key requirement, and the response shape.

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?

Front-loaded with the 'LIVE MONEY' warning, then mechanism, edge cases, follow-up, and alternatives. Dense but every sentence conveys a distinct operational fact with no filler.

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 single-parameter destructive action with no output schema, it supplies the return shape ({ok, result:{total_sz, avg_px}} or {error} with isError true), auth needs, no-op semantics, and the cleanup step. Nothing an agent needs to call and follow up correctly is missing.

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?

There is one parameter and schema coverage is 100%, so the schema already explains the coin naming convention (main-dex name or dex:SYMBOL). The description adds no additional meaning about the coin argument, which is the expected baseline 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?

States a specific verb and resource ('Close a coin's entire open position') plus the exact mechanism ('one market order for the full size'), which immediately separates it from level-editing siblings like set_stop and set_target.

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?

Explicit routing: 'Use when the user asks to exit now; to exit at a price instead, move the level with set_stop or set_target,' plus a required follow-up ('Afterwards run sweep_brackets'). Both the when and the when-not are named with the alternative tool.

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