TailGuard MCP Server
by kkpone
README.md
# TailGuard — Autonomous Solana Long-Tail Risk, Swap Price-Guard & Treasury Agent
[](https://www.coingecko.com/en/api)
[](https://solana.com)
[](./mcp/server.mjs)
[-0B1117?style=for-the-badge)](#quick-start)
**TailGuard** is an autonomous, fully grounded Solana AI agent that protects traders, autonomous trading bots, and DAO treasuries across the long tail of Solana tokens. Every score, swap allow/warn/block verdict, pool screen, and treasury alert is derived strictly from **live CoinGecko API / CoinGecko Onchain responses** and **live Solana Mainnet RPC verification** — with an inspectable per-call citation trail and zero hallucinated numbers.
- **Live Web App:** https://kkpone.github.io/tailguard-solana-agent/
- **Built for:** [Long Tail: A CoinGecko API Hackathon on Solana](https://superteam.fun/earn/hackathon/long-tail) — **AI Agents Track** (built from scratch starting Dec 2, 2026)
- **Surfaces:** Interactive Web Dashboard · CLI & 24/7 Watchdog Daemon · Stdio MCP Server (Claude Code / Codex / Cursor) · Solana Actions (Blinks)
---
## Why TailGuard Exists
Autonomous agents trading or researching Solana long-tail tokens fail in three predictable ways:
1. **Unverified claims & hallucinated prices:** LLM agents frequently cite stale or fabricated token metrics.
2. **Bad DEX execution:** An agent requests a Jupiter swap quote on a thin or manipulated long-tail pool without checking whether execution deviates from CoinGecko's live market benchmark or whether the mint still has active freeze/mint authorities.
3. **Silent rug & treasury drift:** New pools launch every second on Solana DEXes, and DAO/agent wallets accumulate unmonitored concentration risk.
TailGuard solves all three with four composable autonomous tools that work **zero-key out of the box** and automatically scale to **500 RPM + Analyst/Pro endpoints** when a CoinGecko API key is supplied.
---
## Screenshots (Live Mainnet Captures)
### 1. Grounded Token Due-Diligence Agent
Live CoinGecko price, liquidity, FDV, 15m OHLCV trajectory, and Solana Mainnet RPC Mint/Freeze authority verification with full citation trail.

### 2. Autonomous Swap Price-Guard (Jupiter vs. CoinGecko Benchmark)
Pre-trade safety gate returning `ALLOW`, `WARN`, or `BLOCK` by comparing live Jupiter execution quotes against CoinGecko benchmark prices, DEX price impact, pool reserve floors, and Solana mint authorities.

### 3. 24/7 Autonomous Solana Pool Scout
Screens live CoinGecko Onchain `trending_pools` and `new_pools`, batch-verifies every mint on Solana Mainnet via `getMultipleAccounts`, and classifies pools into `PASS`, `WATCH`, or `REJECT`.

### 4. Solana Wallet & Treasury Policy Agent
Connect Phantom/Solflare or inspect any Solana wallet/Squads treasury live via Solana RPC, price every SPL holding via CoinGecko Onchain, and flag stablecoin runway or single-asset concentration breaches.

---
## How CoinGecko API Is Used
TailGuard is architected around **CoinGecko API** and **CoinGecko Onchain** as its authoritative market and liquidity backbone (see [`src/coingecko.mjs`](./src/coingecko.mjs)):
| Capability | CoinGecko Endpoint(s) Used | Role in TailGuard |
|---|---|---|
| **Token Due-Diligence** | `/onchain/networks/solana/tokens/{mint}?include=top_pools`, `/onchain/networks/solana/tokens/{mint}/info`, `/api/v3/coins/{id}` | Live USD price, total onchain reserve depth, 24h volume, FDV/MCap, market cap rank, categories, GT Score, and top DEX pools. |
| **Intraday Trajectory** | `/onchain/networks/solana/pools/{pool}/ohlcv/minute` | Renders live 15-minute price trajectories directly from top Solana DEX pools. |
| **Swap Price-Guard** | `/onchain/networks/solana/tokens/multi/{mints}` + `/onchain/simple/networks/solana/token_price/{mints}` | Supplies independent CoinGecko benchmark prices & reserve floors to detect bad Jupiter quotes and flag/block excess bps deviation. |
| **Autonomous Pool Scout** | `/onchain/networks/solana/trending_pools` & `/onchain/networks/solana/new_pools` | Discovers live trending and brand-new Solana long-tail pools for autonomous safety screening and webhook alerts. |
| **Treasury Valuation** | `/onchain/networks/solana/tokens/multi/{mints}` | Batch-prices all SPL & Token-2022 balances discovered in a Solana wallet in a single request. |
- **Automatic Tier Support:** Set `COINGECKO_API_KEY` in `.env` (supports Hackathon **Analyst / Pro** keys via `pro-api.coingecko.com/api/v3` + `/onchain` with `x-cg-pro-api-key`, **Demo** keys via `x-cg-demo-api-key`, or zero-key public mode with built-in request pacing and TTL caching).
- **Attribution:** Every UI view, CLI memo, API JSON payload, and Blink response explicitly attributes data to **CoinGecko API** (`https://www.coingecko.com/en/api`).
---
## How Solana Is Used
Solana is integrated across four layers (see [`src/solana.mjs`](./src/solana.mjs), [`src/server.mjs`](./src/server.mjs), and [`public/app.js`](./public/app.js)):
1. **Live Solana Mainnet RPC Verification:**
- `getAccountInfo` (`jsonParsed`) & `getMultipleAccounts`: Inspects SPL Token and **Token-2022** mints directly on mainnet for active `mintAuthority`, `freezeAuthority`, supply, decimals, and dangerous Token-2022 extensions (`permanentDelegate`, `transferHook`, `transferFeeConfig`, `nonTransferable`).
- `getTokenLargestAccounts`: Computes Top-1 / Top-5 / Top-10 supply concentration directly from chain state.
- `getBalance` & `getTokenAccountsByOwner`: Reads live SOL, SPL, and Token-2022 balances for any Solana wallet or Squads multisig treasury.
2. **Live Jupiter Swap Routing (`lite-api.jup.ag/swap/v1/quote`):**
- Pulls real-time Solana multi-hop swap routes (Phoenix, Meteora DLMM, Raydium, Orca, Scorch) and compares implied execution price and price impact against CoinGecko benchmarks before allowing an agent to trade.
3. **Browser Wallet Connection:**
- One-click **Phantom / Solflare** wallet connect in the Web UI to audit your live Solana holdings against treasury policy rules.
4. **Solana Actions (Blinks):**
- Serves spec-compliant `GET /actions.json` and `GET /api/actions/audit/:mint` with `X-Action-Version` and `X-Blockchain-Ids: solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp` headers so Blink-compatible clients can query TailGuard risk verdicts inline.
---
## Quick Start
**Requirements:** Node.js **20+** (zero `npm install` packages required — built purely on standard Node.js `http`, `fetch`, and `node:test`).
```bash
# 1. Clone the repository
git clone https://github.com/kkpone/tailguard-solana-agent.git
cd tailguard-solana-agent
# 2. Optional: copy .env.example to .env and add your CoinGecko Analyst/Demo key (works without any key too!)
cp .env.example .env
# 3. Run unit tests
npm test
# 4. Launch the full-stack Web Dashboard + REST API + Solana Actions Blink server
npm start
# Open http://127.0.0.1:3789
```
---
## CLI & 24/7 Watchdog Usage
```bash
# Grounded token due-diligence memo with source citations
npm run cli -- audit JUP
npm run cli -- audit 9BB6NFEcjBCtnNLFko2FqVQBq8HHM13kCyYcdQbgpump
# Pre-trade swap price-guard (exits with code 2 if BLOCKED so CI/bots halt automatically)
npm run cli -- guard SOL JUP 1 --maxDeviationBps 150 --minLiquidityUsd 25000
# Autonomous pool scout (one-shot or continuous 60s watchdog with optional Discord/Telegram webhook)
npm run cli -- scout --mode trending --limit 6
npm run cli -- scout --mode new --limit 6 --watch 60
# Solana wallet / Squads treasury policy check
npm run cli -- wallet vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg
# Natural-language grounded agent (deterministic zero-key mode, or optional LLM synthesis via LLM_API_KEY)
npm run cli -- ask "Should my agent swap 2 SOL into JUP right now?"
```
---
## MCP Server Integration (Claude Code / Codex / Cursor)
TailGuard ships a native JSON-RPC 2.0 **Model Context Protocol (MCP)** stdio server exposing 4 tools:
- `tailguard_audit_token`
- `tailguard_swap_guard`
- `tailguard_scout_pools`
- `tailguard_wallet_treasury`
Register it in any MCP-compatible agent client:
```json
{
"mcpServers": {
"tailguard": {
"command": "node",
"args": ["/absolute/path/to/tailguard-solana-agent/mcp/server.mjs"],
"env": {
"COINGECKO_API_KEY": "YOUR_OPTIONAL_KEY",
"SOLANA_RPC_URL": "https://api.mainnet-beta.solana.com"
}
}
}
}
```
---
## REST & Solana Actions (Blinks) API
| Endpoint | Description |
|---|---|
| `GET /api/health` | Service status and active CoinGecko/Solana RPC configuration |
| `GET /api/audit?token=JUP` | Grounded token due-diligence JSON + risk score + citation trail |
| `GET / POST /api/guard` | Pre-trade Jupiter vs. CoinGecko swap safety gate (`ALLOW` / `WARN` / `BLOCK`) |
| `GET /api/scout?mode=trending\|new&limit=6` | Autonomous Solana pool screen with batch mainnet authority checks |
| `GET /api/wallet?address=<PUBKEY>` | Live Solana wallet valuation & treasury policy alert report |
| `POST /api/ask` | Natural-language tool-routing agent endpoint |
| `GET /actions.json` | Solana Actions (Blinks) discovery manifest |
| `GET /api/actions/audit/:mint` | Solana Action metadata for inline Blink risk cards |
---
## Project Structure
```text
tailguard-solana-agent/
├── src/
│ ├── coingecko.mjs # CoinGecko API + CoinGecko Onchain client, caching, pacing & citations
│ ├── solana.mjs # Solana Mainnet RPC (SPL/Token-2022/Holders/Wallet) + Jupiter Quote API
│ ├── agent.mjs # Deterministic risk engine, Swap Guard, Pool Scout, Treasury & Ask router
│ ├── server.mjs # HTTP API server + static UI host + Solana Actions (Blinks) endpoints
│ └── cli.mjs # CLI & 24/7 autonomous watchdog daemon with webhook alerts
├── mcp/
│ └── server.mjs # Native MCP stdio server for Claude Code, Codex, Cursor & Agent Kits
├── public/
│ ├── index.html # Web dashboard (supports both full-stack server & static browser-direct mode)
│ ├── styles.css # Terminal-editorial Solana + CoinGecko dark theme
│ ├── app.js # Frontend controller + Phantom/Solflare wallet connect + live CORS fallback
│ └── icon.svg # TailGuard emblem
├── test/
│ └── agent.test.mjs # Unit tests for token resolution & risk scoring engine
├── docs/screenshots/ # Live mainnet UI captures
├── .env.example # Safe environment template (no secrets committed)
└── package.json
```
---
## Attribution & License
Market prices, liquidity reserves, pool telemetry, and OHLCV trajectories are **powered by [CoinGecko API](https://www.coingecko.com/en/api)**. Onchain authority, holder, and wallet state is read directly from **Solana Mainnet RPC**, with swap routing quotes from **Jupiter**.
Released under the [MIT License](./LICENSE).
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues