Skip to main content
Glama

Plan a plain swap between two assets

plan_swap
Read-onlyIdempotent

Plans a swap of one asset for another from the wallet, through an aggregator's route, and returns the unsigned transactions (an approval of the router when paying with a token, then the swap). Use only when a wallet needs an asset on its own; to fund a position, prefer plan_build, which buys the sides it needs in the chain's own pools. Returns: transactions[] (to, data, value in wei, gas), check (simulated, ok, failedStep, reason, ethNeeded, ethHeld), sendWithin, ifItReverts, slippagePct, from and to with expected and atLeast amounts, hops, router. Behavior: read-only on our side; nothing is signed or sent. The plan is laid out from the chain at this block and simulated from the owner; send it within check.sendWithin, and plan again rather than resend one that reverted. Costs quota units (agent_quota). Errors: refused when no route exists for that amount.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
toYesThe asset wanted: ETH, USDG, a token symbol or a 0x address.
fromYesThe asset paid: ETH, USDG, a token symbol or a 0x address.
ownerYesThe wallet that signs and sends.
amountYesHow much of `from`, as a decimal string.
slippagePctNoRoom for the price to move, in percent. Left out: from the pool's recent moves, 1.5% at least.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed5 schema fields changed
    • changedInput schema / properties / amount / description
      Previous value: -"how much of `from`, as a decimal string"New value: +"How much of `from`, as a decimal string."
    • changedInput schema / properties / from / description
      Previous value: -"ETH, USDG, a token symbol or address"New value: +"The asset paid: ETH, USDG, a token symbol or a 0x address."
    • addedInput schema / properties / owner / description
      Added value: +"The wallet that signs and sends."
    • addedInput schema / properties / slippagePct / description
      Added value: +"Room for the price to move, in percent. Left out: from the pool's recent moves, 1.5% at least."
    • changedInput schema / properties / to / description
      Previous value: -"ETH, USDG, a token symbol or address"New value: +"The asset wanted: ETH, USDG, a token symbol or a 0x address."
  2. Changed10 schema fields changed
    • removedInput schema / properties / from / anyOf
      Removed value: -[
      -  {
      -    "enum": [
      -      "ETH",
      -      "USDG"
      -    ],
      -    "type": "string"
      -  },
      -  {
      -    "pattern": "^0x[0-9a-fA-F]{40}$",
      -    "type": "string"
      -  }
      -]
    • addedInput schema / properties / from / description
      Added value: +"ETH, USDG, a token symbol or address"
    • addedInput schema / properties / from / maxLength
      Added value: +64
    • addedInput schema / properties / from / minLength
      Added value: +1
    • addedInput schema / properties / from / type
      Added value: +"string"
    • removedInput schema / properties / to / anyOf
      Removed value: -[
      -  {
      -    "enum": [
      -      "ETH",
      -      "USDG"
      -    ],
      -    "type": "string"
      -  },
      -  {
      -    "pattern": "^0x[0-9a-fA-F]{40}$",
      -    "type": "string"
      -  }
      -]
    • addedInput schema / properties / to / description
      Added value: +"ETH, USDG, a token symbol or address"
    • addedInput schema / properties / to / maxLength
      Added value: +64
    • addedInput schema / properties / to / minLength
      Added value: +1
    • addedInput schema / properties / to / type
      Added value: +"string"
  3. Added

TDQS

A4.7/5.0
Behavior5/5

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

Annotations already declare readOnlyHint, idempotentHint, openWorldHint, and destructiveHint=false, but the description adds meaningful context beyond them: it returns unsigned transactions, costs quota units, refuses when no route exists, simulates from the owner, and explains the approval-then-swap sequence. These details make the tool's behavior clear for an agent.

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 front-loaded with purpose and usage, then uses labeled sections (Returns, Behavior, Errors) that are appropriate for a tool with no output schema. Although dense, every sentence supplies relevant information and there is no filler.

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?

Given the complex swap-planning behavior, the absence of an output schema, and full parameter coverage by the schema, the description supplies the return shape, simulation semantics, quota cost, error condition, and revert guidance. Nothing material for correct invocation appears to be missing.

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 the schema already documents all five parameters. The description adds no additional parameter-level meaning; it restates the swap concept but does not clarify syntax, constraints, or defaults for from, to, owner, amount, or slippagePct beyond what the schema provides.

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 and resource: it plans a swap of one asset for another via an aggregator and returns unsigned transactions. It distinguishes itself from the sibling plan_build by specifying it is for a wallet needing an asset on its own, not for funding a position.

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 when-to-use condition ('Use only when a wallet needs an asset on its own') and names the alternative plan_build with the condition that selects it. It also includes operational guidance to send within check.sendWithin and to re-plan rather than resend a reverted transaction.

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