SolGuard MCP
README.md
# SolGuard MCP — Autonomous Solana Due-Diligence, Pre-Trade Guard & 24/7 Pool Scout
> **Built from scratch during the Superteam × CoinGecko *Long Tail: AI Agents* Hackathon (Dec 2026).**
> **Track:** Long Tail — AI Agents with CoinGecko Data
> **Data Attribution:** Market & Onchain Data Powered by [CoinGecko API](https://www.coingecko.com/en/api)
**SolGuard MCP** is an autonomous, zero-hallucination Solana risk & trade-guard AI agent and **Model Context Protocol (MCP)** server (`stdio` + Streamable HTTP `/mcp`) with a real-time institutional web dashboard and **Solana Actions / Blinks** support.
Every single price, liquidity figure, volume ratio, and onchain security check is recorded in an immutable **Evidence Provenance Ledger (`[E1]`..`[En]`)** — so autonomous agents and human traders can trace every claim directly back to its live CoinGecko API or Solana Mainnet RPC response with **zero invented numbers**.
---
## Live Screenshots
| 1. Grounded Token Due-Diligence + Evidence Ledger | 2. Pre-Trade Swap Guard (Jupiter vs CoinGecko) |
|---|---|
|  |  |
| 3. 24/7 Autonomous Solana Pool Scout | 4. "Why Did It Move?" OHLCV & Order-Flow Analyzer |
|---|---|
|  |  |
---
## Architecture
```mermaid
flowchart LR
U[AI Agents: Claude Code / Codex / Cursor / Antigravity] -->|MCP stdio or HTTP /mcp| CORE[SolGuard MCP Core Engine]
W[Web Dashboard + Phantom/Solflare Wallet] -->|REST + SSE Live Stream| CORE
B[Solana Blinks / Actions Clients] -->|GET/POST /api/actions/guard| CORE
CORE --> CG[CoinGecko Market & Onchain Solana API]
CORE --> RPC[Solana Mainnet JSON-RPC]
CORE --> JUP[Jupiter Live Swap Quote API]
CORE --> EV[(Evidence Provenance Ledger)]
CORE --> DAEMON[24/7 Autonomous Pool Scout Loop]
DAEMON -->|SSE + Optional Telegram/Discord Webhook| W
```
---
## Key Capabilities
1. **Grounded Token Due-Diligence (`solana_token_due_diligence`):**
- Pass any Solana symbol (`JUP`, `BONK`, `WIF`, `SOL`, `PYTH`, `RAY`, `ORCA`) or any Base58 SPL / Token-2022 mint address.
- Computes a deterministic **0–100 Safety Score & Grade (`A+` to `F`)** and generates an analyst memo where every figure links to an interactive `[E#]` provenance entry.
2. **Pre-Trade Price & Security Guard (`solana_guard_trade`):**
- Safety gate for autonomous trading agents *before* signing a Solana swap.
- Compares a **live Jupiter DEX swap quote** against **CoinGecko's benchmark price**, evaluates route price impact, liquidity-to-trade depth ratio, and Solana SPL `mintAuthority` / `freezeAuthority`, returning a policy-enforced **`ALLOW`**, **`WARN`**, or **`BLOCK`** verdict.
3. **Autonomous 24/7 Solana Pool Scout (`solana_scout_pools` + Background Daemon):**
- Continuously screens CoinGecko Onchain Solana **new** and **trending** DEX pools, verifies top base tokens directly against Solana Mainnet RPC for live mint/freeze authorities, streams updates over SSE (`/api/scout/stream`), and optionally pushes alerts to Telegram or Discord webhooks.
4. **"Why Did It Move?" Catalyst Analyzer (`solana_why_did_it_move`):**
- Explains sudden token moves by combining CoinGecko `5m / 1h / 6h / 24h` price momentum, 24h hourly OHLCV trading band, onchain buy/sell transaction imbalance, and volume-to-liquidity turnover acceleration.
5. **Solana Wallet Risk & Valuation Audit (`solana_wallet_risk_scan`):**
- Connect Phantom/Solflare or inspect any Solana mainnet address to value SOL + SPL / Token-2022 balances via CoinGecko API and flag active authorities or single-asset concentration risk.
6. **Native MCP Server (8 Tools) + Solana Actions / Blinks:**
- Exposes all 8 tools over both local `stdio` (`node src/mcp-stdio.js`) and Streamable HTTP (`POST /mcp`), plus Solana Actions v2.1.3 endpoints (`/actions.json`, `/api/actions/guard`).
---
## How CoinGecko API Is Used
SolGuard MCP uses a **dual-tier CoinGecko API client** (`src/coingecko.js`) with in-flight request deduplication, TTL caching, and automatic `429` exponential backoff:
- **Pro / Hackathon Analyst Mode** *(set `COINGECKO_PRO_API_KEY` in `.env`)*: Queries `https://pro-api.coingecko.com/api/v3/*` and `https://pro-api.coingecko.com/api/v3/onchain/networks/solana/*` (including `/top_holders`, 500 RPM).
- **Zero-Friction Public / Demo Mode** *(works out of the box with no API key, or higher limits with `COINGECKO_DEMO_API_KEY`)*: Queries `https://api.coingecko.com/api/v3/*` and CoinGecko's public Onchain API (`https://api.geckoterminal.com/api/v2/networks/solana/*`, identical JSON:API schema).
| Endpoint | Purpose in SolGuard MCP |
|---|---|
| `/simple/price` | Global CEX+DEX spot price, market cap, 24h change, and 24h volume benchmark (for DEX-vs-Spot dislocation checks & SOL wallet valuation) |
| `/onchain/simple/networks/solana/token_price/{mints}` | Batch real-time USD pricing of up to 30 SPL / Token-2022 wallet holdings |
| `/onchain/networks/solana/tokens/{mint}` | Live Solana onchain price, FDV, total DEX reserve liquidity, and 24h volume |
| `/onchain/networks/solana/tokens/{mint}/info` | CoinGecko GT Trust Score, metadata, and official links |
| `/onchain/networks/solana/tokens/{mint}/pools` | Top Solana DEX pools (Meteora, Orca, Raydium, etc.) with `5m/1h/6h/24h` price changes and buy/sell transaction counts |
| `/onchain/networks/solana/trending_pools` & `/new_pools` | Feeds the autonomous 24/7 pool scout daemon |
| `/onchain/networks/solana/pools/{pool}/ohlcv/hour` | 24-hour hourly OHLCV candles for the *"Why Did It Move?"* catalyst analyzer |
| `/onchain/networks/solana/tokens/{mint}/top_holders` | *(Pro/Analyst tier)* Enhanced holder distribution intelligence |
All displayed data in the Web UI, REST API, Solana Actions, and MCP tool responses includes explicit attribution: **Market & Onchain Data Powered by [CoinGecko API](https://www.coingecko.com/en/api)**.
---
## How Solana Is Used
SolGuard MCP integrates directly with **Solana Mainnet** across four layers (`src/solana.js`, `src/actions.js`, `public/index.html`):
1. **Direct Solana Mainnet JSON-RPC Authority & Concentration Verification:**
- Calls `getAccountInfo(mint, { encoding: "jsonParsed" })` to inspect SPL Token (`Tokenkeg...`) and **Token-2022** (`TokenzQd...`) mint accounts for live `mintAuthority`, `freezeAuthority`, `decimals`, `supply`, and extensions.
- Calls `getTokenLargestAccounts(mint)` to calculate exact live **Top-1 / Top-5 / Top-10 supply concentration (%)**.
2. **Jupiter Live Swap Routing & Pre-Trade Execution Guard:**
- Queries `https://lite-api.jup.ag/swap/v1/quote` for live executable swap output, route DEX hops, and `priceImpactPct`, then compares effective execution price against CoinGecko's benchmark to `ALLOW`, `WARN`, or `BLOCK` trades.
3. **Solana Wallet Connection & Onchain Portfolio Audit:**
- Browser dashboard connects to **Phantom / Solflare** via `window.solana.connect()`, and `src/solana.js` queries `getBalance` + `getTokenAccountsByOwner` across both SPL Token and Token-2022 programs.
4. **Solana Actions / Blinks (Spec v2.1.3):**
- Serves `/actions.json` and `GET / POST /api/actions/guard` with full `X-Action-Version: 2.1.3` and Solana Mainnet `X-Blockchain-Ids` headers so Blink clients can trigger live token safety audits and pre-trade guards.
---
## Quick Start (Zero Build, Zero Native Dependencies)
**Requirements:** Node.js `>= 20.0.0`
```bash
git clone https://github.com/OnTechnologyCo/solguard-mcp.git
cd solguard-mcp
# Optional: copy .env.example to .env and add your CoinGecko Pro/Analyst or Demo API key
cp .env.example .env
# Launch Web Dashboard + REST API + 24/7 Scout + Streamable HTTP MCP (/mcp) + Solana Actions
npm start
```
Open **`http://127.0.0.1:3840`** in your browser!
### Run Live End-to-End Integration Tests
```bash
npm test
```
Verifies live CoinGecko Market & Onchain API calls, Solana Mainnet RPC mint/wallet checks, Jupiter swap quote guard, Solana Actions `/api/actions/guard`, Streamable HTTP MCP (`/mcp`), and `stdio` MCP transport (`10/10` checks).
---
## Connect to AI Coding Tools (MCP)
### Streamable HTTP MCP (Recommended — while `npm start` is running)
```bash
# Claude Code
claude mcp add --transport http solguard http://127.0.0.1:3840/mcp
```
### Stdio MCP (`claude_desktop_config.json`, Cursor, Codex, Antigravity)
```json
{
"mcpServers": {
"solguard": {
"command": "node",
"args": ["/absolute/path/to/solguard-mcp/src/mcp-stdio.js"],
"env": {
"COINGECKO_PRO_API_KEY": ""
}
}
}
}
```
### Exposed MCP Tools (8)
- `solana_token_due_diligence` — Grounded risk audit + Evidence Ledger `[E#]` memo
- `solana_guard_trade` — Jupiter quote vs CoinGecko benchmark pre-trade `ALLOW`/`WARN`/`BLOCK` gate
- `solana_scout_pools` — Screen CoinGecko Solana `new` or `trending` pools with live Solana RPC authority checks
- `solana_why_did_it_move` — Multi-timeframe momentum, 24h OHLCV, and buy/sell order-flow catalyst analysis
- `solana_wallet_risk_scan` — Solana wallet SOL + SPL/Token-2022 CoinGecko valuation & authority audit
- `solana_mint_authority_check` — Direct Solana Mainnet RPC mint/freeze authority & Top-10 holder concentration check
- `solana_policy_config` — Read/update autonomous risk thresholds at runtime
- `solana_evidence_trace` — Retrieve raw API provenance records for any `reportId`
---
## License & Attribution
- Licensed under the **MIT License** — see [LICENSE](LICENSE).
- Never commit real API keys; use `.env.example` as a template.
- **Market & Onchain Data Powered by [CoinGecko API](https://www.coingecko.com/en/api).**
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessOutdated data