Skip to main content
Glama

Swap Guard

An MCP tool and HTTP API that an AI agent calls before it signs a Solana swap.

Live: https://swap-guard-pied.vercel.app

Agents that trade will sign whatever route a quote returns. Swap Guard checks the quote against the market first and answers allow, warn or block, with the number behind every reason, so the agent's decision is grounded in data rather than in the quote alone.

What it checks

Check

Data

Rule

Quote vs market value

Jupiter quote, both tokens valued at CoinGecko onchain prices

block at -5% or worse, warn at -1.5%

Price impact

Jupiter quote

warn at 1%

Output token liquidity

CoinGecko onchain, summed over all pools

block under $10k, warn under $50k

Freeze authority

Solana mint account (RPC, jsonParsed)

warn

Permanent delegate (Token-2022)

Solana mint account

block

Known regulated issuers (USDC, USDT, PYUSD, xStocks)

allowlist

issuer controls reported as info

Unpriced token, or the check fails

block: never sign what could not be checked

Example (5 Dec 2026): 1 SOL → JUP is allow at -0.55% to market. 20,000 SOL → JUP is block: the quote is worth 35.6% less than market value, with 35.2% price impact.

Related MCP server: SolGuard MCP

Use it from an agent

MCP (Claude Desktop, Claude Code, Cursor, any MCP client):

git clone https://github.com/nurettebayosa/swap-guard && cd swap-guard
pip install -r requirements.txt -r requirements-mcp.txt
{ "mcpServers": { "swap-guard": {
  "command": "python", "args": ["-m", "swapguard.mcp_server"],
  "env": { "COINGECKO_PRO_API_KEY": "your key" } } } }

Tool: check_swap(input_mint, output_mint, amount, slippage_bps=50). amount is in whole input tokens (1.5 means 1.5 SOL).

HTTP: GET /api/check?in={mint}&out={mint}&amount=1. Returns the decision, the reasons, both sides' values, the gap to market, price impact, liquidity, mint authorities, the route and the sources.

Data

  • CoinGecko onchain API: /onchain/networks/solana/tokens/multi/{mints} for price, decimals and liquidity across all pools (Pro key if COINGECKO_PRO_API_KEY is set, public endpoint otherwise).

  • Jupiter swap API /quote for the route the agent would sign.

  • Solana RPC getAccountInfo (jsonParsed) for freeze authority, mint authority and Token-2022 extensions of the output token.

Develop

pip install -r requirements.txt -r requirements-mcp.txt
uvicorn api.index:app --reload
python -m pytest

Not financial advice.

License

MIT

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables Solana AI agents and treasury operators to run pre-trade swap safety checks, citation-grounded token due diligence, multisig treasury policy audits, and new-pool screening through MCP tools backed by CoinGecko data and Solana RPC. It returns deterministic ALLOW/WARN/BLOCK decisions and evidence-grounded reports with SHA-256 receipts.
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI agents and MCP clients to screen Solana long-tail trades through deterministic fail-closed policy checks, block unsafe or prompt-injected swaps, compute safe trade limits, run red-team probes, and commit and verify decisions in a SHA-256 hash-chained audit ledger using CoinGecko and Solana RPC data.
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables MCP-capable agents to compare Jupiter swap quotes against CoinGecko market prices and receive ALLOW, WARN, or BLOCK verdicts with supporting figures and endpoints. It also supports preparing unsigned guarded swap transactions only when checks pass and the requested wallet matches.
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables agents and hosts to pre-check proposed Solana swaps by pricing both token legs, validating pool reserves and observation freshness, and returning a reasoned allow/block verdict with exact evidence. It also produces citation-backed token due-diligence memos, verifies cited fields, screens new pools, and compares quote batches.
      MIT