Skip to main content
Glama

perp_close

Destructive

Close a perp position, full or partial (non-custodial).

close_pct in (0, 100]. Returns an UNSIGNED base64 tx to sign + broadcast, plus exit price + realized P&L estimate (incl funding). Past the daily free tier an x402 payment_header is required.

jurisdiction: closes are geo-gated too -- see perp_open_long.

idempotency_key (optional): a client-generated UUID. Retrying with the same key + same args replays the original result instead of re-closing the position.

signed_transaction / verify (two-phase execution): see perp_open_long -- re-call with the signed tx and Crank broadcasts it, confirms it on-chain, and re-reads the position.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ipNo
marketYes
verifyNo
caller_idNo
close_pctNo
position_idNo
jurisdictionNo
pay_in_crankNo
payment_headerNo
wallet_addressYes
idempotency_keyNo
signed_transactionNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changed
    • addedInput schema / properties / ip
      Added value: +{
      +  "default": "",
      +  "type": "string"
      +}
    • addedInput schema / properties / jurisdiction
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null
      +}
  2. Changed2 schema fields changed
    • addedInput schema / properties / signed_transaction
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null
      +}
    • addedInput schema / properties / verify
      Added value: +{
      +  "default": true,
      +  "type": "boolean"
      +}
  3. First observed

TDQS

A4/5.0
Behavior5/5

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

This is a strong area. With only destructiveHint=true and readOnlyHint=false available from annotations, the description compensates fully by disclosing that it returns an unsigned base64 tx, may require an x402 payment_header, supports replay via idempotency_key, and uses a signed_transaction/verify two-phase flow. It also flags jurisdiction geo-gating and realized P&L details.

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?

The description is dense but well-structured and front-loaded. The core purpose comes first, then each subsequent line adds one meaningful operational detail. Backticked parameter names and clear paragraphs make it easy to scan without waste.

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?

Given the tool's complexity, the description is quite complete: it covers the main return shape, fee requirements, jurisdiction gating, idempotency semantics, and two-phase execution with Crank. An output schema exists, so return-value documentation is mostly offloaded. The main gap is that positional parameters such as position_id and pay_in_crank are not contextualized, and the agent must infer their role from names alone.

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?

The schema has 0% property descriptions, so the description carries a key burden. It adds useful semantics for close_pct, idempotency_key, signed_transaction, verify, payment_header, and jurisdiction. However, it does not explain position_id selection, pay_in_crank, wallet_address, market, ip, or caller_id, even though some are core to correctly closing the intended position.

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?

The description clearly states the verb and resource: 'Close a perp position, full or partial'. The non-custodial and unsigned-transaction details help set it apart from a custodial close flow, but it does not explicitly contrast it with the sibling close_perp_position, so some sibling differentiation is left implicit.

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?

The description conveys context for using the tool — full/partial close, non-custodial, fee tiers, idempotency, and two-phase execution — and directionally references perp_open_long. However, it never says when NOT to use this tool or explicitly names alternatives such as close_perp_position, cancel_perp_order, or perp_modify.

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