Skip to main content
Glama

AgentPay — trust routing + spend caps for x402 agents

pre_trade_check

One-call pre-trade sanity check: 'I want to long $X of SYMBOL — is now sane?' Combines live orderbook slippage at YOUR size, cross-exchange funding (carry cost), open-interest crowding, and contract security (GoPlus) into a single ok/caution/avoid verdict with a per-factor breakdown. Major ERC-20 addresses (LINK, UNI, ARB, OP, AAVE, PEPE, SHIB) resolve automatically; native assets (BTC, ETH, SOL, ...) report security n/a; an unrecognized token without token_address reads 'unknown' and caps the verdict at caution — an unscreened contract can never read 'ok'. Replaces four API integrations and the judgment layer on top of them. Raw component data embedded so you can apply your own thresholds. Stacks tokens (STX, sBTC, USDCx, stSTX, ZEST, LEO, USDh, aeUSDC, stBTC) add the Bitflow DEX venue: price impact at YOUR size from a live route quote, the pools and bins the swap crosses, and their TVL; STX and sBTC keep their CEX perp legs, DEX-only tokens report funding/OI n/a and contract risk unscreened (no GoPlus coverage on Stacks).

Use when: An agent (or human) is about to enter a position and wants one verdict covering liquidity, carry, crowding, and security — instead of four raw feeds plus its own synthesis. Not for: you need a single raw factor — funding_rates, open_interest, orderbook_depth or token_security are free; you are not about to size a position. This call settles $0.01 on-chain. Returns: verdict (ok/caution/avoid), factors{liquidity,carry,crowding,security} each with level + reason, components{orderbook_depth,funding_rates,open_interest}, symbol, side, size_usd Example response: {"symbol":"ETH","side":"long","size_usd":50000,"venue":"cex","verdict":"caution","factors":{"liquidity":{"level":"ok","slippage_pct":0.011,"bucket_usd":50000,"reason":"fills within 0.011% of best ask"},"carry":{"level":"caution","median_funding_pct":0.062,"annualized_pct":67.9,"reason":"longs paying elevated funding"},"crowding":{"level":"ok","long_short_ratio":1.4,"oi_change_24h_pct":3.2,"reason":"positioning unremarkable"},"security":{"level":"n/a","reason":"ETH is a native chain asset — no token contract to screen"}},"not_checked":["security"]}

Price: $0.01 USDC per call (x402 over MCP: an unpaid call returns PaymentRequired; pay via _meta x402/payment)

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": {
      "symbol": "<symbol>"
    },
    "name": "pre_trade_check"
  }
}

Input Schema

NameRequiredDescriptionDefault
sideNoTrade direction (funding carry is side-aware)long
venueNoWhere the trade executes. auto (default): CEX books for majors, Bitflow for Stacks tokens, both for STX/sBTC. bitflow: price the swap on Bitflow only; cex: skip Bitflowauto
symbolYesAsset to check, e.g. 'ETH', 'BTC', 'SOL'
size_usdNoIntended position size in USD (drives the slippage check)
token_addressNoOptional ERC-20 contract address for the GoPlus security scan. Auto-resolved for major tokens; required for a full verdict on tokens the resolver doesn't know (otherwise security reads 'unknown' and caps the verdict at caution)

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • addedInput schema / properties / venue
      Added value: +{
      +  "default": "auto",
      +  "description": "Where the trade executes. auto (default): CEX books for majors, Bitflow for Stacks tokens, both for STX/sBTC. bitflow: price the swap on Bitflow only; cex: skip Bitflow",
      +  "enum": [
      +    "auto",
      +    "cex",
      +    "bitflow"
      +  ],
      +  "type": "string"
      +}
  2. First observed

TDQS

A4.8/5.0
Behavior5/5

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

Goes well beyond annotations (readOnlyHint=false, openWorldHint=true) by disclosing payment behavior (unpaid calls return PaymentRequired via x402 _meta), the guardrail that an unscreened contract can never read 'ok', native-asset and DEX-only 'n/a' semantics, and the fact that raw components are embedded so callers can apply their own thresholds. readOnlyHint=false is consistent with the on-chain $0.01 settlement described, so no contradiction.

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?

Front-loaded with a one-line hook followed by clearly labeled Use when / Not for / Returns / Example sections, so scanning is easy. It is dense and somewhat repetitive — the Returns list and the full example response convey overlapping information — which keeps it just below top marks.

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?

With no output schema, the description carries the full return burden and does so: verdict, per-factor levels and reasons, embedded components, plus a worked example response and a 'not_checked' field. Edge cases (unknown token, native asset, DEX-only Stacks token) and payment failure are all covered, leaving nothing an agent needs before calling.

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 already 100%, so the baseline is 3, but the description adds genuine semantics: size_usd drives the slippage bucket at 'YOUR size', side makes carry side-aware, venue auto-routes majors to CEX books and Stacks tokens to Bitflow, and token_address is what unlocks a full security verdict. The only gap is that these points largely restate the schema descriptions rather than extending them.

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 concrete verb+resource ('one-call pre-trade sanity check') and states exactly what it aggregates: orderbook slippage, cross-exchange funding, open-interest crowding, and GoPlus contract security, returning an ok/caution/avoid verdict. It also explicitly positions itself against the sibling raw feeds (funding_rates, open_interest, orderbook_depth, token_security), so an agent can tell it apart without opening any schema.

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?

Has explicit 'Use when' (about to enter a position and want one synthesized verdict) and 'Not for' (you need a single raw factor — naming the four free siblings; or you are not about to size a position) sections. It even flags the cost trigger ('This call settles $0.01 on-chain'), giving the agent a concrete reason to prefer the free alternatives.

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.