Skip to main content
Glama

Close all agent-wallet positions

close_all_positions
Destructive

Close EVERY open perp position in YOUR agent wallet (requires the api:trade scope). REAL MONEY, in two calls. 1) Call with no arguments: nothing is closed; the answer lists the open positions (symbol, side, size, entry price, unrealized PnL) and confirm_echo.positions. Present that list to the human user. 2) Only after their explicit approval, call again with positions set to confirm_echo.positions exactly as returned. The server re-reads the live positions and refuses with 409 positions_changed unless they still match (then preview again); otherwise, for each position, it cancels that symbol's TP/SL orders and places a REDUCE-ONLY market close, which can only close, never open or flip. NEVER make the second call autonomously or chain it after the first. The answer lists each close with its own success in data.closed; if any close fails the call returns an error that names, per position, whether it closed — tell the user which positions are still open. Only the agent wallet is touched, never the main wallet.

Input Schema

NameRequiredDescriptionDefault
positionsNoONLY on the confirming call: confirm_echo.positions from the preview, unchanged

Schema Changelog

Changes observed during successful MCP inspections.

  1. Added

TDQS

A4.8/5.0
Behavior5/5

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

Annotations already declare destructiveHint=true and non-idempotency, but the description adds substantial context beyond them: the required api:trade scope, real-money warning, preview/confirm contract, live position re-read with 409 refusal, cancellation of TP/SL orders, REDUCE-ONLY market close that can never open or flip, and per-position success in data.closed including partial-failure reporting.

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-loaded with the core action and the money/scope warning, and every sentence carries operational weight for a destructive tool. It is a dense single block rather than bulleted steps, which slightly reduces scannability, but no sentence is wasted.

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?

With no output schema, the description compensates by describing the return shape (data.closed per position, error listing which positions closed) and the preview payload (symbol, side, size, entry price, unrealized PnL). An agent has everything needed to execute the confirm flow correctly.

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% and already documents positions as 'confirm_echo.positions from the preview, unchanged', so baseline is 3. The description adds genuine meaning beyond the schema by explaining why the field must match exactly (server re-reads live positions and refuses with 409 if they changed) and by describing what the preview response contains.

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 with explicit scope: 'Close EVERY open perp position in YOUR agent wallet.' It distinguishes itself from sibling tools like get_positions or adjust_margin by naming the wallet boundary (agent wallet, never the main wallet) and the scope (every position).

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?

Gives an explicit two-step protocol: first call closes nothing and returns a preview list, second call only after explicit human approval. It states the prohibition directly ('NEVER make the second call autonomously or chain it after the first') and the failure condition that forces re-previewing (409 positions_changed).

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