Skip to main content
Glama

Close a position

close_position

Close all or part of an open perpetual position with a reduce-only MARKET order. Reads the current position, flips the side automatically (LONG→SELL, SHORT→BUY) and sizes the close. percent defaults to 100 (full close); a partial close is floored to the market step size. The close is bounded at oracle ± slippageBps mirrored by side (closing a SHORT buys up to oracle×(1+slip), closing a LONG sells down to oracle×(1−slip); default 500 bps = 5%). Returns the verified confirmation outcome — if it is unfilled or partially_filled, the book was thinner than the cap: re-run with a larger slippageBps to sweep deeper. Errors NOT_FOUND if there is no open position in the market.

Input Schema

NameRequiredDescriptionDefault
marketYesMarket ticker, e.g. BTC-USD
confirmNo
percentNoPortion of the position to close (default 100).
slippageBpsNoMax slippage vs oracle, in bps (default 500). Raise to sweep a thin book.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • addedInput schema / properties / market / pattern
      Added value: +"^[A-Z0-9]{1,20}-[A-Z0-9]{1,20}$"
  2. Changed1 schema field changed
    • changedInput schema / properties / slippageBps / description
      Previous value: -"Max slippage vs oracle, in bps"New value: +"Max slippage vs oracle, in bps (default 500). Raise to sweep a thin book."
  3. Added

TDQS

A4.6/5.0
Behavior5/5

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

Goes well beyond the annotations (which only say non-readonly, non-idempotent, non-destructive) by disclosing side-flipping logic, step-size flooring, oracle±slippage bounds with a concrete 5% default, the returned confirmation outcome, remediation for unfilled/partially_filled, and the NOT_FOUND error. This is unusually rich behavioral context.

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 core action and then layers mechanics efficiently, with no filler sentences. It is dense but every clause carries operational information; slightly long for a single paragraph but justified by the tool's complexity.

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 mutation tool with no output schema, the description covers the return outcome (confirmation), failure remediation, and error conditions, which is exactly what an agent needs to call and recover. Nothing essential is missing.

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 75% and already describes percent and slippageBps, but the description adds real meaning: percent defaults to 100, partial closes are floored to the market step size, and slippageBps is mirrored by side with a 500 bps default. The undocumented `confirm` parameter is left unexplained, keeping it below 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 (close) and resource (perpetual position) with the exact mechanism (reduce-only MARKET order). It is clearly distinguishable from siblings like close_all_positions or place_market_order because it scopes to a single market and a specific reduce-only semantics.

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?

Explains when to use it (closing all or part of an open position, partial close behavior) and documents the error path when no position exists. It does not explicitly name or contrast with close_all_positions, so the 'vs alternative' guidance is implied rather than stated.

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