Skip to main content
Glama

Build your refund

build_refund
Idempotent

Build the UNSIGNED refund for a leg (available after its timelock expires). Acting for a person with no wallet here? Give them the swap's dealUrl to refund there instead. Same signing shapes as build_claim, except that on Solana only the leg's refund (funder) key can sign; for Bitcoin, omit preimageHex when broadcasting so the refund branch is taken.

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": {
      "id": "<id>",
      "leg": "<leg>"
    },
    "name": "build_refund"
  }
}

Input Schema

NameRequiredDescriptionDefault
idYesSwap id
legYesThe leg YOU funded: a if you are the maker, b if you are the taker

Output Schema

NameRequiredDescriptionDefault
txsNoEVM txs
signNoSigning scheme
payToNoBitcoin escrow address
feePayToNo
amountSatsNo
psbtBase64No
sighashHexesNoOne per input
transactionsNoTRON txs
feeAmountSatsNo
transactionBase64NoSolana tx

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed5 schema fields changed
    • removedInput schema / additionalProperties
      Removed value: -false
    • addedInput schema / properties / id / description
      Added value: +"Swap id"
    • addedInput schema / properties / id / pattern
      Added value: +"^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
    • addedInput schema / properties / leg / description
      Added value: +"The leg YOU funded: a if you are the maker, b if you are the taker"
    • changedOutput schema / (root)
      Previous value: -nullNew value: +{
      +  "$schema": "http://json-schema.org/draft-07/schema#",
      +  "additionalProperties": {},
      +  "properties": {
      +    "amountSats": {
      +      "type": [
      +        "string",
      +        "number",
      +        "null"
      +      ]
      +    },
      +    "feeAmountSats": {
      +      "type": [
      +        "string",
      +        "number",
      +        "null"
      +      ]
      +    },
      +    "feePayTo": {
      +      "type": [
      +        "string",
      +        "null"
      +      ]
      +    },
      +    "payTo": {
      +      "description": "Bitcoin escrow address",
      +      "type": "string"
      +    },
      +    "psbtBase64": {
      +      "type": "string"
      +    },
      +    "sighashHexes": {
      +      "description": "One per input",
      +      "items": {
      +        "type": "string"
      +      },
      +      "type": "array"
      +    },
      +    "sign": {
      +      "description": "Signing scheme",
      +      "type": "string"
      +    },
      +    "transactionBase64": {
      +      "description": "Solana tx",
      +      "type": "string"
      +    },
      +    "transactions": {
      +      "description": "TRON txs",
      +      "items": {},
      +      "type": "array"
      +    },
      +    "txs": {
      +      "description": "EVM txs",
      +      "items": {},
      +      "type": "array"
      +    }
      +  },
      +  "type": "object"
      +}
  2. First observed

TDQS

A4.3/5.0
Behavior4/5

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

Annotations already flag readOnlyHint=false, idempotentHint=true and destructiveHint=false, and the description adds real behavior beyond them: the output is unsigned (build, not broadcast), the timelock gate, and chain-specific signing rules (Solana refund/funder key only; Bitcoin needs preimageHex omitted). It stops short of stating wallet/auth or fee requirements, so not a 5.

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?

Three dense sentences, front-loaded with the core action and precondition, with the alternative route and signing caveats following logically. No filler, though the final sentence packs two distinct chain-specific rules.

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?

An output schema exists, so return-shape explanation is unnecessary, and the description covers the crucial gate, the unsigned nature, and per-chain signing differences. What remains unstated is auth/wallet requirements and whether the caller must hold the refund key locally.

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?

Schema coverage is 100% and the leg semantics (a for maker, b for taker) are already documented in the schema. The description's chain-specific signing notes concern the signing/broadcast step rather than clarifying the two input parameters, so it adds little beyond the schema; baseline 3 applies.

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 description states a specific verb+resource+scope; 'Build the UNSIGNED refund for a leg' names the exact artifact and the timelock precondition, and 'Same signing shapes as build_claim' contrasts with it against the sibling build tool.

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 an explicit precondition (available only after the leg's timelock expires) and an explicit alternative for the no-wallet case (hand the dealUrl to the counterparty to refund there), plus a routing rule against build_claim.

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.