Skip to main content
Glama

Swap build

swap_build

Build an UNSIGNED swap transaction on X1 at the best price across XDEX and APEX AMM — direct, or two hops through XNT or APEX in ONE transaction, simulated against your wallet before it is returned. Returns base64 you sign with your own key and broadcast yourself; this server never holds your keys and never signs for you. Use mint addresses, or the string "native" for XNT. APEX mint is Du6Z596DwGnfUcMSyRHSBQzNybiQKu8GESVfruEv9Jqr. Check priceImpact before signing — thin pools move hard. Building is free. When you spend XNT (more than 0.01), the transaction includes a 0.1% platform fee to the APEX buyback wallet, shown as platformFee in the answer; otherwise you pay only the network fee.

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": {
      "tokenIn": "<tokenIn>",
      "tokenOut": "<tokenOut>",
      "amount": "<amount>",
      "wallet": "<wallet>"
    },
    "name": "swap_build"
  }
}

Input Schema

NameRequiredDescriptionDefault
amountYesAmount of tokenIn, in whole tokens (not raw units).
walletYesYour X1 wallet public key — it will be the fee payer and signer.
tokenInYesMint address to spend, or "native" for XNT.
slippageNoSlippage tolerance as a fraction. Default 0.01 (1%).
tokenOutYesMint address to receive, or "native" for XNT.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4/5.0
Behavior5/5

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

With zero annotations, the description carries the full burden and does it well: it discloses that the transaction is unsigned, that it is simulated against the caller's wallet before return, that it returns base64 the caller signs and broadcasts, and that the server never holds keys or signs. It also quantifies cost behavior — building is free, a 0.1% platform fee applies only when spending more than 0.01 XNT, otherwise network fee only — and warns about priceImpact on thin pools.

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?

The key facts — what it builds, that it is unsigned, who signs, and what it returns — are front-loaded in the first two sentences, and later sentences carry fee and safety detail. It is dense and mostly waste-free, though 'Building is free' partially duplicates the fee sentence that follows it.

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?

No output schema exists, so the description must cover return values, and it does name the returned base64 transaction, priceImpact, and platformFee fields. What remains unstated is how failures surface (e.g. simulation revert, no route found, insufficient balance), which matters for a build-then-sign flow.

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%, so the baseline would be 3; the description adds meaning beyond the schema by supplying the concrete APEX mint address (Du6Z596DwGnfUcMSyRHSBQzNybiQKu8GESVfruEv9Jqr) and by tying the 0.01 XNT threshold to the amount implied by the fee rule. It does not explain the units or semantics of slippage beyond what the schema already says.

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 states a specific verb and resource plus scope: builds an UNSIGNED swap transaction on X1, routed across XDEX and APEX AMM directly or via XNT/APEX hops, simulated against the caller's wallet. That is far more precise than the title 'Swap build'. It never names or differentiates against the closest sibling (commodity_swap_build), which also builds swaps, so it falls short of a 5.

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?

It gives practical pre-call guidance ('Check priceImpact before signing — thin pools move hard', 'Use mint addresses, or the string "native" for XNT'), which is genuinely useful. However, there is no explicit statement of when to use this versus alternatives such as trade_rail_quote, arc_price, or commodity_swap_build, and no when-not guidance (e.g. no route available, insufficient balance). Usage is implied rather than routed.

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