Skip to main content
Glama
README.md
# SlippageGate MCP — Pre-Trade Execution & Token-2022 Guardrail for Solana AI Agents

**SlippageGate MCP** is a runnable Python **MCP 2.x (`MCPServer`)** server and deterministic pre-trade safety engine that protects Solana trading agents from thin-liquidity slippage blowups, anomalous wash volume, and Token-2022 hidden transfer fees/hooks/pauses — returning actionable `max_safe_trade_usd` bounds and Megafilter rerouting candidates.

- **Live Zero-Key Agent Console & Simulator:** https://nikhilbharti284.github.io/slippagegate-mcp/
- **Hackathon Track:** AI Agents (CoinGecko API × Superteam *Long Tail* Solana Hackathon, Dec 2026)

## MCP 2.x Tools Exposed (`src/slippagegate/mcp_server.py`)
1. **`gate_solana_swap(pool_address, token_mint, trade_size_usd, max_slippage_bps=150)`** — Evaluates pool depth, 1s OHLCV freshness, anomalous print share, and Solana Token-2022 state; returns `ALLOW_EXECUTION`, `REQUIRE_HUMAN_CONFIRM`, or `DENY_SWAP` plus closed-form `max_safe_trade_usd`.
2. **`inspect_token2022_extensions(mint_address)`** — Reads epoch-aware `transferFeeConfig`, `transferHook`, `permanentDelegate`, `freezeAuthority`, `defaultAccountState`, and `pausableConfig` from Solana Mainnet RPC.
3. **`discover_safe_solana_pools(min_reserve_usd=50000, trade_size_usd=1000, max_slippage_bps=150)`** — Queries CoinGecko Analyst Megafilter so an agent can reroute out of a denied thin pool.

## Quickstart
```bash
python3 -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
cp .env.example .env  # add COINGECKO_API_KEY
PYTHONPATH=src pytest -v
PYTHONPATH=src python3 -m slippagegate.collector
PYTHONPATH=src python3 examples/agent_demo.py
```

## Claude Desktop / MCP Client Config
```json
{
  "mcpServers": {
    "slippagegate": {
      "command": "python3",
      "args": ["-m", "slippagegate.mcp_server"],
      "env": {
        "PYTHONPATH": "src",
        "COINGECKO_API_KEY": "YOUR_COINGECKO_PRO_API_KEY",
        "SOLANA_RPC_URL": "https://api.mainnet-beta.solana.com"
      }
    }
  }
}
```

## Screenshots
### Live Mainnet Agent Traces
![Live Mainnet Agent Traces](docs/screenshots/01-agent-traces.png)

### Interactive Agent Guardrail Simulator
![Interactive Agent Guardrail Simulator](docs/screenshots/02-agent-simulator.png)

## Data Attribution
Powered by [CoinGecko API](https://www.coingecko.com/en/api) (Analyst Plan: Megafilter, Pools Multi, 1s OHLCV, Trades Range `include_anomalous=true`) and Solana Mainnet RPC.