AegisQuant
<div align="center">
# `aegis-swap-mcp` — Safe Token Checks & Smarter Swap Routing for AI Agents
**Check crypto tokens for scams, split large swaps across pools to get better prices, and protect trades from front-running—without ever handing over your wallet keys.**
[](https://www.npmjs.com/package/aegis-swap-mcp)
[](https://www.npmjs.com/package/aegis-swap-mcp)
[](./package.json)
[](https://aegisquant-mcp.famedied.workers.dev/stats)
[](https://aegisquant-mcp.famedied.workers.dev/.well-known/mcp/server-card.json)
[](https://cursor.com/en/install-mcp?name=aegisquant&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsImFlZ2lzLXN3YXAtbWNwIl19)
[](https://vscode.dev/redirect?url=vscode%3Amcp%2Finstall%3F%7B%22name%22%3A%22aegisquant%22%2C%22type%22%3A%22stdio%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22aegis-swap-mcp%22%5D%7D)
```bash
claude mcp add aegisquant -- npx -y aegis-swap-mcp
```
**Agent Auto-Setup Prompt:** Paste into Claude Code, Antigravity, Cursor, Hermes, OpenClaw, Codex, or Windsurf:
`Fetch and follow https://aegisquant-mcp.famedied.workers.dev/install.md to configure AegisQuant (aegis-swap-mcp). Start with the free tier.`

</div>
When you ask an AI assistant to evaluate or prepare an on-chain trade on Base, Ethereum, Arbitrum, Polygon, Optimism, or Solana, `aegis-swap-mcp` screens the token for honeypots and hidden sell taxes, calculates how to split the order across pools with minimal slippage, and builds an unsigned transaction that a 252-line local firewall verifies on your machine before any wallet signs. You get **5 free token safety checks per day**, and optional paid tools cost **`$0.005–$0.030` per call** in Base USDC via x402.
- **npm:** [`aegis-swap-mcp`](https://www.npmjs.com/package/aegis-swap-mcp) · **Live Edge:** `https://aegisquant-mcp.famedied.workers.dev` · **Live Telemetry:** [`/stats`](https://aegisquant-mcp.famedied.workers.dev/stats)
- **Discovery:** [`server-card.json`](https://aegisquant-mcp.famedied.workers.dev/.well-known/mcp/server-card.json) · [`agent-card.json`](https://aegisquant-mcp.famedied.workers.dev/.well-known/agent-card.json) · [`erc8004-registration.json`](https://aegisquant-mcp.famedied.workers.dev/.well-known/erc8004-registration.json) · [`llms.txt`](https://aegisquant-mcp.famedied.workers.dev/llms.txt) · [`skill.md`](https://aegisquant-mcp.famedied.workers.dev/skill.md)
---
## Zero Trust Required: Audit These 252 Lines + Local Calldata Firewall
You do **not** have to trust the remote edge server with your private keys or blind transaction calldata:
1. **Private keys never leave your machine.** Your micro-payer key (`X402_PRIVATE_KEY` or `~/.aegis-swap-mcp/wallet.json`) stays strictly local and signs EIP-3009 Base USDC micro-invoices (`$0.005–$0.030`) via `viem`.
2. **Hard Local Spend Guardrails** (`src/cli.ts`):
- `X402_MAX_PRICE_USD` (default `0.05`) blocks any single invoice above your cap before signing.
- `X402_DAILY_BUDGET_USD` (default `5.00`, persisted in `~/.aegis-swap-mcp/budget.json`) enforces a hard daily USDC ceiling.
3. **Deterministic Local Calldata Firewall** (`src/firewall.ts`):
Before any `build_verified_swap` payload reaches your LLM or wallet, `aegis-swap-mcp` verifies locally:
- `tx.to` matches the **immutable hardcoded router allowlist** per chain (CoW Protocol `GPv2Settlement`, KyberSwap `MetaAggregationRouterV2`, Uniswap `UniversalRouter`).
- `tx.data` does **not** start with dangerous approval or transfer selectors (`0x095ea7b3` `approve`, `0xa22cb465` `setApprovalForAll`, `0x23b872dd` `transferFrom`).
- The **SHA-256 verification envelope** (`crypto.subtle.digest`) matches `chainId`, `to`, `data`, `value`, `minAmountOut`, and `recipient` verbatim.
- If any check fails, calldata is redacted and `FIREWALL_BLOCKED` is returned immediately.
Audit the entire runtime yourself in 2 minutes: [`src/cli.ts`](./src/cli.ts) (`119` lines) + [`src/firewall.ts`](./src/firewall.ts) (`133` lines) = **252 lines total** (`wc -l src/cli.ts src/firewall.ts`).
---
## Optional: 10-Second Micro-Payer Wallet Setup (`init-wallet`)
The free tier (`scan_alpha_safety`, 5 calls/day/IP) works out of the box with zero wallet setup. To unlock paid routing, calldata construction, and arbitrage scans without ever exposing your main wallet:
```bash
npx aegis-swap-mcp init-wallet
```
This creates a fresh Base EOA strictly on your local disk at `~/.aegis-swap-mcp/wallet.json` (`chmod 0600`), prints a terminal ASCII QR code to fund it with **$2–$5 Base USDC**, and `aegis-swap-mcp` auto-loads it automatically under `X402_MAX_PRICE_USD=0.05` and `X402_DAILY_BUDGET_USD=5.00` caps.
---
## Measured On-Chain Proof (Not Synthetic Estimates)
Measured live across 18 real Base & Solana contracts (`GoPlus + Honeypot.is + RugCheck + DexScreener`) and live Base pool reserves — full data and reproducible script in [`benchmarks/LIVE_PROOF.md`](./benchmarks/LIVE_PROOF.md):
- **Live Honeypot & Trap Detection:** Caught `Basecat` (`0xB200...1D01`, `$336,776` liquidity) with **`100%` sell tax** (`CRITICAL_AVOID`, `99.0%` rug prob) and `PEPE` (`0x52b4...777D`, `$279,596` liquidity) with **`BLACKLIST_OR_PAUSE_TRAP`** (`99.0%` rug prob), while clearing `AERO`, `WETH`, `cbBTC`, `DEGEN`, `JUP`, `BONK`, and `$WIF`.
- **Live KKT Split Routing + MEV Sandwich Savings (`$0.035` total x402 fee for `compute` + `build`):**
| Live Base Pair | Trade Size | KKT Split + Tranching Gain | Naive 1% Sandwich Loss Avoided | Safe Slippage & Venue | Total Value Saved | Net ROI vs `$0.035` |
| --- | --- | --- | --- | --- | --- | --- |
| `AERO` (6 live pools) | `$1,000` | `+3.08 bps` | `$0.00` | `500 bps` (`KYBER_AGGREGATOR`) | **`$0.31`** | **`7.9x`** |
| `AERO` (6 live pools) | `$5,000` | `+23.76 bps` | `$50.00` | `1 bps` (`COW_MEV_PROTECTED`) | **`$61.88`** | **`1,767x`** |
| `AERO` (6 live pools) | `$25,000` | `+141.03 bps` | `$250.00` | `1 bps` (`COW_MEV_PROTECTED`) | **`$602.58`** | **`17,215.6x`** |
| `DEGEN` (6 live pools) | `$1,000` | `+50.53 bps` | `$10.00` | `1 bps` (`COW_MEV_PROTECTED`) | **`$15.05`** | **`429x`** |
| `DEGEN` (6 live pools) | `$5,000` | `+269.85 bps` | `$50.00` | `1 bps` (`COW_MEV_PROTECTED`) | **`$184.93`** | **`5,282.7x`** |
| `DEGEN` (6 live pools) | `$25,000` | `+1350.71 bps` | `$250.00` | `1 bps` (`COW_MEV_PROTECTED`) | **`$3,626.78`** | **`103,621.3x`** |
---
## Setup Across Every Major AI Harness
### 1. One-Command CLI & Plugin Harnesses
#### Claude Code (MCP or Native Plugin)
```bash
# MCP (free tier, no wallet required)
claude mcp add aegisquant -- npx -y aegis-swap-mcp
# Or install as a Claude Code Plugin (includes /check-token, /safe-swap, /find-arb + skill)
/plugin marketplace add FameDied/aegis-swap-mcp
/plugin install aegisquant
```
#### Hermes Agent
```bash
# Free tier (note: --args must be the last option)
hermes mcp add aegisquant --command npx --args -y aegis-swap-mcp
# With Base USDC x402 auto-pay (or omit X402_PRIVATE_KEY after running init-wallet)
hermes mcp add aegisquant \
--command npx \
--env X402_PRIVATE_KEY=0xYOUR_BASE_USDC_MICRO_PAYER_KEY \
--env X402_MAX_PRICE_USD=0.05 \
--env X402_DAILY_BUDGET_USD=5.00 \
--args -y aegis-swap-mcp
```
#### OpenClaw
```bash
openclaw mcp add aegisquant --command npx --arg -y --arg aegis-swap-mcp
```
#### OpenAI Codex CLI
```bash
codex mcp add aegisquant -- npx -y aegis-swap-mcp
```
#### OpenCode (`~/.config/opencode/opencode.json`)
```json
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"aegisquant": {
"type": "local",
"command": ["npx", "-y", "aegis-swap-mcp"],
"enabled": true
}
}
}
```
#### Goose (Block) (`~/.config/goose/config.yaml`)
```yaml
extensions:
aegisquant:
name: AegisQuant MCP
type: stdio
cmd: npx
args:
- "-y"
- "aegis-swap-mcp"
enabled: true
```
---
### 2. JSON Config Harnesses (`mcpServers`)
Paste into your harness's MCP config file (add `"env": { "X402_PRIVATE_KEY": "0x..." }` or run `npx aegis-swap-mcp init-wallet` for paid tools):
```json
{
"mcpServers": {
"aegisquant": {
"command": "npx",
"args": ["-y", "aegis-swap-mcp"]
}
}
}
```
| Harness | Config File Location |
| --- | --- |
| **Antigravity** | `~/.gemini/config/mcp_config.json` *(optionally copy [`SKILL.md`](./SKILL.md) to `~/.gemini/config/skills/aegisquant-defi-execution/SKILL.md`)* |
| **Cursor** | `.cursor/mcp.json` (project) or `~/.cursor/mcp.json` (global) |
| **Claude Desktop** | `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) · `%APPDATA%\Claude\claude_desktop_config.json` (Windows) |
| **Windsurf** | `~/.codeium/windsurf/mcp_config.json` or `~/Library/Application Support/Windsurf/mcp.json` (macOS) |
| **Gemini CLI** | `~/.gemini/settings.json` (global) or `.gemini/settings.json` (project) |
| **GitHub Copilot CLI** | `~/.copilot/mcp-config.json` (global) or `.mcp.json` (repo root) |
| **Cline / Roo Code** | `cline_mcp_settings.json` *(via MCP Servers → Configure)* |
---
### 3. Editor & TOML/YAML Config Harnesses
#### VS Code / GitHub Copilot Chat (`.vscode/mcp.json`)
```json
{
"servers": {
"aegisquant": {
"type": "stdio",
"command": "npx",
"args": ["-y", "aegis-swap-mcp"]
}
}
}
```
#### Zed (`settings.json`)
```json
{
"context_servers": {
"aegisquant": {
"command": "npx",
"args": ["-y", "aegis-swap-mcp"]
}
}
}
```
#### Codex TOML (`~/.codex/config.toml`)
```toml
[mcp_servers.aegisquant]
command = "npx"
args = ["-y", "aegis-swap-mcp"]
[mcp_servers.aegisquant.env]
X402_MAX_PRICE_USD = "0.05"
X402_DAILY_BUDGET_USD = "5.00"
```
#### Hermes Agent YAML (`~/.hermes/config.yaml`)
```yaml
mcp_servers:
aegisquant:
command: "npx"
args:
- "-y"
- "aegis-swap-mcp"
env:
X402_MAX_PRICE_USD: "0.05"
X402_DAILY_BUDGET_USD: "5.00"
```
---
### 4. Direct Remote Streamable HTTP & Raw x402 REST
- **MCP Streamable HTTP:** `https://aegisquant-mcp.famedied.workers.dev/mcp` *(note: the Local Calldata Firewall runs only in the local `npx -y aegis-swap-mcp` stdio bridge)*
- **Raw x402 REST:** `POST https://aegisquant-mcp.famedied.workers.dev/api/v1/{tool}` (paid routes return HTTP `402 Payment Required` with Base64 `PAYMENT-REQUIRED` header + `extensions.bazaar` schema; `/api/v1/scan_alpha_safety_pro` always returns `402` for Bazaar discovery).
---
## Tools
| Tool | Price (Base USDC) | Purpose |
| --- | --- | --- |
| `scan_alpha_safety` | **FREE (5/day/IP)**, then `$0.005` | Multi-source Bayesian rug probability, HHI holder concentration, honeypot/tax override, 0.25x Fractional Kelly sizing, and live `execution_preview` |
| `compute_optimal_execution` | `$0.015` | $O(N \log N)$ KKT water-filling split solver, Almgren-Chriss tranching, constant-product MEV bound |
| `build_verified_swap` | `$0.020` | Strictly unsigned calldata / CoW intent + SHA-256 envelope verified by Local Calldata Firewall |
| `audit_execution_shortfall` | `$0.008` | On-chain RPC receipt audit, implementation shortfall decomposition, persistent D1 EWMA update |
| `find_arb_and_yield_spreads` | `$0.025` | Closed-form cross-pool constant-product arb optimizer (strictly net-positive after gas & tax) |
| `batch_portfolio_shield` | `$0.030` | Parallel safety & LP-drain audit across up to 10 tokens |
TDQS
Scored across 6 tools
Each tool maps to a distinct stage of the trade lifecycle (pre-trade safety scan, execution planning, calldata build, post-trade audit, spread discovery, batch audit), so an agent can mostly infer intent from the name. The one real overlap is scan_alpha_safety vs batch_portfolio_shield, which run the same Bayesian/honeypot checks and differ only in single-vs-batch scope; compute_optimal_execution vs build_verified_swap are also adjacent (planning vs calldata) but the descriptions separate them adequately.
All six tools follow a strict snake_case verb_noun pattern (scan_, compute_, build_, audit_, find_, batch_). No camelCase mixing or vague noun-only names, and the naming style stays uniform despite differing domains within the tool.
Six tools is well within the ideal 3-15 range and each corresponds to a distinct step in the quant trading workflow, so nothing looks padded. The surface is compact and purpose-built for a specialized DeFi execution server.
The pipeline covers the core path: safety scan, execution optimization, calldata construction, shortfall auditing, and arbitrage/yield discovery, including a batch variant for portfolio-scale work. Minor gaps remain: there is no tool to read back the persistent EWMA telemetry that audit_execution_shortfall writes, and no position/LP state or telemetry query tool, leaving a mild dead end for follow-up analysis.