Skip to main content
Glama

Build swap calldata under the spending policy

build_swap

Quotes a swap, enforces spending policy, simulates from the agent wallet, and returns Universal Router calldata to sign. Refusals list failed rules; approval calldata comes first when needed.

Instructions

Quote, enforce the spending policy (allowlist, per-trade cap, daily cap, max slippage, max price impact, pinned contracts and hooks), simulate from the agent wallet, and return Universal Router calldata for that wallet to sign. ERC-20 input without Permit2 allowances returns the approval calldata first. Refusals list every rule that failed. The trade's USD size counts toward the daily cap once calldata is returned.

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>",
      "from": "<from>"
    },
    "name": "build_swap"
  }
}

Input Schema

NameRequiredDescriptionDefault
fromYesThe agent wallet that will sign and send. Calldata is simulated from it.
amountYesAmount of tokenIn as a decimal string in whole-token units, e.g. "0.25".
tokenInYesToken address on Robinhood Chain, or "ETH" for native ETH.
tokenOutYesToken address on Robinhood Chain, or "ETH" for native ETH.
slippageBpsNoSlippage in basis points. Defaults to the policy maximum; above it the trade is refused.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.2/5.0
Behavior5/5

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

Beyond the annotations, the description adds substantial behavior: simulation happens from the specified agent wallet, refusals enumerate every failed rule, ERC-20 input without Permit2 returns approval calldata before the swap, and the trade only counts toward the daily cap once calldata is returned. These are exactly the operational details that the annotations (readOnly=false, openWorld=true, idempotent=false, destructive=false) do not 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?

The definition is front-loaded with the pipeline verb and stays under four sentences, with each sentence carrying a distinct fact. The long parenthetical listing policy rules is dense but it is informative rather than padding.

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?

There is no output schema, so the definition sets out the return values for both success paths (router calldata or an approval transaction) and the failure path (all failed rules listed). For a five-parameter calldata-building tool, the only thing the agent needs that isn't covered is the exact calldata encoding, and that is minor.

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 only semantic hints in the description (simulation from 'from', the slippage-vs-policy-maximum cap) are already spelled out in the schema property descriptions. The description adds no syntax, range, or format detail beyond the schema, so the baseline of 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 names a concrete pipeline of verbs on a concrete resource: quote, enforce policy, simulate from the agent wallet, and return Universal Router calldata. It is clearly distinguishable from the sibling tools quote and simulate because it states that it does all three stages and produces signable calldata.

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?

Usage is implied by the pipeline description, and there is one useful conditional about ERC-20 input without Permit2 allowances returning approval calldata first. However, it never says when to prefer this tool over quote or simulate, nor are there explicit exclusions, so the choice between siblings must be inferred.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.