Skip to main content
Glama

Build a swap transaction

build_swap
Read-only

Build an unsigned, simulated swap transaction for the user's own Stellar account, ready to sign. Returns the XDR, the expected and minimum amounts, the network fee, warnings, and sign links: sign.web opens a skyhitz.io page where the user signs with their own wallet and the swap is submitted; sign.sep7 is a SEP-7 link for wallets that support it. Nothing moves until the user signs. Show the user the amounts and warnings first.

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": {
      "account": "<account>",
      "sell": "<sell>",
      "buy": "<buy>",
      "amount": "<amount>"
    },
    "name": "build_swap"
  }
}

Input Schema

NameRequiredDescriptionDefault
toNoOptional recipient (G… or C…) instead of account.
buyYesHITZ, XLM, USDC (any case), or a token contract address (C…).
sellYesHITZ, XLM, USDC (any case), or a token contract address (C…).
amountYesExact amount of sell to trade.
accountYesThe user's account: it pays, signs and (unless to is set) receives.
valid_forNoSeconds the transaction stays valid.
slippage_bpsNoHow far below the quote the output may land, in basis points (100 = 1%).

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.3/5.0
Behavior5/5

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

Goes well beyond the readOnlyHint/openWorldHint annotations by disclosing that the transaction is unsigned and simulated, that nothing moves until the user signs, that two distinct sign links are returned, and that warnings and min/expected amounts accompany the result. This is exactly the kind of context annotations cannot convey.

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, then the return payload, then the sign-link distinction, then the safety instruction — a logical order. It is dense but nearly every sentence carries new information; the sign.web/sign.sep7 breakdown is the only slightly verbose stretch.

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?

For a seven-parameter mutation-building tool with no output schema, the description compensates well by enumerating return fields and the signing paths. Minor gaps remain around what happens on quote failure or how valid_for expiry surfaces to the agent.

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 description coverage is 100%, so all seven parameters are already documented, establishing a baseline of 3. The description adds only that the swap targets the user's own account, and it never explains how the optional `to` recipient or `valid_for`/`slippage_bps` interact with the returned amounts, so no meaningful lift beyond the schema.

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 — 'Build an unsigned, simulated swap transaction' — plus the exact output artifacts (XDR, amounts, fee, warnings, sign links). The contrast with the sibling submit_transaction is made implicit through 'Nothing moves until the user signs,' so an agent can distinguish building from submitting without opening the schema.

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?

Gives a clear workflow instruction — 'Show the user the amounts and warnings first' — and clarifies the signing handoff via sign.web vs sign.sep7. It does not explicitly name quote or submit_transaction as alternatives or state when not to use this tool, so it stops short of full routing guidance.

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.