Skip to main content
Glama

execute_swap

Swap a user's credits along a swap pair: deducts source_amount of the source type and credits the converted amount (after fee) in the target type. Errors: 400 INSUFFICIENT_CREDITS, 404 USER_NOT_FOUND, 400 outside min/max. On a bidirectional pair, direction "reverse" spends the target type for the source type at 1/rate (else 400 SWAP_NOT_BIDIRECTIONAL). Pass an idempotency_key so a retry replays the original swap (idempotent_replay: true); the same key on a different request is 409 IDEMPOTENCY_KEY_REUSED. Costs 1 CRD (platform credit) per call, charged even when the call is then rejected (a 429 RATE_LIMITED costs nothing). Error results include request_id; quote it to support.

Input Schema

NameRequiredDescriptionDefault
api_keyNoCred API key (optional if set via the x-api-key header)
user_idNoExternal user ID
directionNoDefault forward
project_idNoCred project ID (optional; the API key already identifies the project)
user_emailNoUser email (alternative)
swap_pair_idYesSwap pair ID
x402_paymentNoBase64 x402 PaymentPayload, only when a previous call failed with an x402 PaymentRequired because the account is out of CRD
source_amountYesCredits to spend (in the target type when direction is reverse)
idempotency_keyNoUnique key for this swap (max 255 chars). Retrying with the same key and same arguments returns the first result instead of repeating it; reusing it for different arguments fails with 409 IDEMPOTENCY_KEY_REUSED. Generate a fresh key (e.g. a UUID) per intended operation and reuse it only to retry that operation.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.2/5.0
Behavior5/5

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

With no annotations supplied, the description carries the full behavioral burden and does so thoroughly: it discloses the per-call cost of 1 CRD charged even on rejection, the 429 exception that costs nothing, the fee deduction, the idempotent_replay behavior, the 409 IDEMPOTENCY_KEY_REUSED condition, and the full set of error codes including 400 INSUFFICIENT_CREDITS, 404 USER_NOT_FOUND, and out-of-min/max bounds.

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?

Dense but front-loaded: the core swap mechanic comes first, followed by error codes, direction semantics, idempotency, and cost. Nearly every clause carries operational information, though the error-code enumeration and the support/request_id note make it longer than strictly needed for tool selection.

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 9-parameter, no-output-schema mutation tool, the description covers cost, failure modes, idempotency, and direction semantics well. What is left implicit is the success response shape (resulting balances, converted amount fields), which matters for a credit-moving operation when no output schema exists.

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 is 3, but the description genuinely adds meaning beyond the schema: it explains that reverse direction spends the target type at 1/rate, and it clarifies the idempotency_key contract (same key + same args replays, same key + different args is 409). The x402_payment parameter, though documented in schema, is not connected to the out-of-CRD scenario described in the text.

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?

States a specific verb and resource ('Swap a user's credits along a swap pair') and immediately defines the mechanics: deducts source_amount of the source type, credits the converted amount after fee in the target type. The mechanics inherently distinguish it from deduct_credits/issue_credits, but no sibling is named, so an agent must infer the routing rather than being told it.

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 clear usage context: when the pair is bidirectional, use direction='reverse' to spend the target type at 1/rate; otherwise the call fails with SWAP_NOT_BIDIRECTIONAL. It also tells the caller to supply an idempotency_key on retries. It stops short of explicit when-to-use-vs-alternative guidance (e.g. execute_swap vs deduct_credits), and states no prerequisites such as the user needing to exist.

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