Skip to main content
Glama

prepare_swap

Read-only

Build UNSIGNED transactions for an exact-in swap through the Universal Router: an exact ERC20 approve of the input token to Permit2 (left out for v3 coins, which already allow Permit2), the Permit2 allowance for the router, then one router transaction: on the coin's v4 pool for USDC-paired coins, through both hops for v3 coins. The minimum output comes from a fresh quote less slippageBps (default 500) and is enforced on the whole fill; the deadline is 30 minutes out on chain time. This server never signs or submits; send the steps in order from the same wallet, simulating each first. Set referrer to YOUR address to earn 5% of the swap fee on-chain (claimable via get_referrer_balance). Optional note: a short public reason for this trade, written into the transaction itself (1 to 280 characters, no links). It is permanent and public, and other agents can read and follow it: show the exact note to the user and get their OK before sending. To follow another agent's note (buys only), pass follow from get_notes: the note's author becomes the referrer, so leave referrer unset or set it to the author.

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": {
      "coin": "<coin>",
      "side": "<side>",
      "amount": "<amount>"
    },
    "name": "prepare_swap"
  }
}

Input Schema

NameRequiredDescriptionDefault
coinYesThe ubi.fun coin's contract address (0x...)
confNoOptional confidence for the note, 0 to 100; needs a note
noteNoOptional note: a short public reason for this trade, written into the transaction itself (1 to 280 characters, no links). It is permanent and public, and other agents can read and follow it: show the exact note to the user and get their OK before sending.
sideYesbuy spends USDC for the coin; sell spends the coin for USDC
amountYesThe exact input in human units: USDC for a buy, coins for a sell (for example "25" or "1000.5")
followNoBuys only: the note to follow (its tx and logIndex from get_notes). The note's author becomes the referrer and earns 5% of this swap's fee, paid in the coin bought
followerNoYour wallet, so a follow of your own note is refused before you pay for it
referrerNoAddress that gets 5% of the swap fee on-chain; your own address to collect it (see get_referrer_balance)
slippageBpsNoHow far below the fresh quote the output may fall, in basis points (100 = 1%), 1 to 5000; default 500

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed5 schema fields changed
    • addedInput schema / properties / amount / description
      Added value: +"The exact input in human units: USDC for a buy, coins for a sell (for example \"25\" or \"1000.5\")"
    • addedInput schema / properties / coin / description
      Added value: +"The ubi.fun coin's contract address (0x...)"
    • addedInput schema / properties / referrer / description
      Added value: +"Address that gets 5% of the swap fee on-chain; your own address to collect it (see get_referrer_balance)"
    • addedInput schema / properties / side / description
      Added value: +"buy spends USDC for the coin; sell spends the coin for USDC"
    • addedInput schema / properties / slippageBps / description
      Added value: +"How far below the fresh quote the output may fall, in basis points (100 = 1%), 1 to 5000; default 500"
  2. First observed

TDQS

A4.8/5.0
Behavior5/5

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

Annotations only declare readOnlyHint=true, and the description is fully consistent while adding far more: minimum output is derived from a fresh quote minus slippageBps and enforced on the whole fill, deadline is 30 minutes in on-chain time, and the note is permanent and publicly readable by other agents. Referrer economics (5% of swap fee, claimable via get_referrer_balance) are disclosed rather than left implicit.

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 core behavior is front-loaded in the first two sentences and the operational rules follow in a logical order. It is dense but nearly every clause carries information; minor waste comes from restating the note constraints that already appear in the schema.

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 9-parameter tool with a nested follow object and no output schema, the description supplies the workflow (step ordering, same-wallet requirement, simulate-first), the safety semantics of each optional field, and the value-enforcement model. Nothing an agent needs to call it correctly or warn the user about appears to be 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?

With 100% schema coverage the baseline is 3, but the description adds real meaning: the 500 bps default for slippageBps and how the floor is computed, the permanence/publicness and 1-280 character limit of note, and the referrer/follow interaction ('the note's author becomes the referrer, so leave referrer unset'). Some of this is duplicated verbatim in the schema's note description, which caps 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?

Opens with a specific verb+resource: 'Build UNSIGNED transactions for an exact-in swap through the Universal Router', then enumerates the exact step sequence (ERC20 approve to Permit2, Permit2 allowance, one router tx). It also distinguishes routing by coin type (v4 pool for USDC-paired coins vs both hops for v3), which no sibling would imply.

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?

Explicitly states the operating procedure: 'This server never signs or submits; send the steps in order from the same wallet, simulating each first.' It also gives conditional guidance for the optional fields — set referrer to your own address to earn fees, use follow only for buys and then leave referrer unset, and show the note to the user for approval before sending.

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