Swap Guard
README.md
# 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.
## Use it from an agent
MCP (Claude Desktop, Claude Code, Cursor, any MCP client):
```bash
git clone https://github.com/nurettebayosa/swap-guard && cd swap-guard
pip install -r requirements.txt -r requirements-mcp.txt
```
```json
{ "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
```bash
pip install -r requirements.txt -r requirements-mcp.txt
uvicorn api.index:app --reload
python -m pytest
```
Not financial advice.
## License
MIT
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues