geckoshield-mcp
# GeckoShield
**Zero-Hallucination Solana Long-Tail Token & Pool Due-Diligence Agent, Cryptographic Citation Verifier, MCP Server, and Risk-Gated Solana Actions/Blinks**
> **Mandatory Attribution**: [Data provided by CoinGecko](https://www.coingecko.com/en/api) | [On-chain data provided by GeckoTerminal](https://www.geckoterminal.com)
---
## Executive Summary & Problem Statement
Solana launches thousands of long-tail DEX tokens daily across Raydium, PumpSwap, Meteora, and Pump.fun. Both retail traders and autonomous AI agents routinely suffer preventable losses from three compounding failure modes:
1. **LLM Metric Hallucination**: General-purpose crypto agents invent or silently drift spot prices, pool liquidity reserves, 24-hour trading volumes, turnover ratios, and holder concentration percentages without verifiable source bindings.
2. **Token-2022 Contract Backdoors**: Modern long-tail Solana tokens overwhelmingly deploy on Token-2022 (`TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb`) rather than legacy SPL Token (`TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`). In our live Mainnet audit of 30 pools, **26 of 30 tokens** used Token-2022. Even when `mintAuthority` and `freezeAuthority` are revoked, hidden Token-2022 extensions—such as `permanentDelegate` (unilateral holder seizure/burn), `transferHook` (arbitrary sell-blocking logic), mutable `transferFeeConfig` (post-launch tax escalation up to 100%), `defaultAccountState=frozen`, and `nonTransferable`—can rug buyers instantaneously.
3. **Wash-Volume & Honeypot Traps**: Newly trending pools routinely fabricate multi-million-dollar 24h volume atop thin liquidity reserves (up to **113.085x** 24h volume-to-liquidity turnover in our live Mainnet cohort) to manipulate trending feeds.
**GeckoShield** solves all three problems with a deterministic, zero-hallucination forensic pipeline delivered across three native interfaces:
- **Single-Screen Forensic Web Console** (`web/`): Institutional dark/light security terminal (`100dvh`, vanilla ES2020, Solflare Wallet Standard + zero-friction Read-Only Simulation Mode) featuring Long-Tail Pool Radar, Token Forensic Dossier, Hallucination Gate & MCP Lab, and Solana Blinks & Benchmarks.
- **Model Context Protocol (MCP) Server & Agent Skill** (`geckoshield-mcp` + [`SKILL.md`](SKILL.md)): Standard JSON-RPC 2.0 stdio server exposing 5 security tools for Claude Desktop, Claude Code, Cursor, Windsurf, and autonomous trading agents.
- **Risk-Gated Solana Actions / Blinks v2** (`/actions.json`, `/api/actions/attest/{mint}`): Refuses clean attestations with HTTP `400` (`CRITICAL_RUG_ALERT`) when lethal backdoors are detected, and builds verifiable unsigned Solana Legacy Transactions targeting the official SPL Memo Program (`MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr`) for permitted tokens.
For full mathematical scoring formulas, Mermaid data-flow diagrams, Token-2022 risk tables, and binary wire-format specifications, see [`docs/architecture.md`](docs/architecture.md).
---
## Verified Live Mainnet Benchmark Scorecard
Every metric below is directly reproduced from [`docs/evidence/longtail-audit-benchmark.json`](docs/evidence/longtail-audit-benchmark.json) (captured at `2026-12-03T11:38:57Z`, Solana Mainnet Slot `476,957,067`, `SOL = $64.27`, zero-key `public_zero_key` tier) and verified test/UI runs:
| Evaluation Dimension | Verified Result | Ground-Truth Details |
|---|---|---|
| Live Solana Mainnet Cohort | **30 pools audited** | `15` trending + `15` newly launched pools at Slot `476,957,067` (`SOL $64.27`, 24h vol `$5.04B`, `-10.95%`) |
| Token Program Composition | **26 Token-2022 / 4 SPL** | Single-batch `getMultipleAccounts` (`jsonParsed`) inspection; mean Safety Score `66.42/100` (`17 SAFE`, `1 CAUTION`, `12 HIGH_RISK`, `0 CRITICAL_RUG_ALERT`) |
| Live Token-2022 Fee Flags | **2 live trending tokens flagged** | `TERMINUS` (`HIGH_RISK`, `44.0/100`, `61.972x` turnover) and `SI` (`SAFE`, `85.0/100`) detected with active `transferFeeConfig` (`100 bps` / `1.00%`) + mutable `transferFeeConfigAuthority` |
| Live Wash-Turnover Anomalies | **8 anomalies (`>= 10x`)** | Led by `ishoespeed` (**`113.085x`** turnover, `$1.21M` vol / `$10.7K` reserve) and `Jellykit` (**`92.583x`** turnover, `$3.40M` vol / `$36.7K` reserve) |
| Live Memo Grounding Integrity | **707 / 707 claims verified (100.0%)** | `0` ungrounded claims across all 30 live due-diligence security memos |
| Adversarial Hallucination Gate | **50 / 50 caught (100.0% catch rate)** | `0 / 30` clean false positives (`0.0%` FPR) across 7 attack vectors (spot price, liquidity, wash turnover, uncited claims, unknown citation IDs, contradicted on-chain facts, spoofed scores) |
| Token-2022 & Authority Backdoor Suite | **25 / 25 detected (100.0% TPR)** | `0 / 5` benign controls flagged (`0.0%` FPR) across `permanentDelegate`, `transferHook`, `transferFeeConfig`, `defaultAccountState=frozen` / `nonTransferable`, and active mint/freeze authorities |
| Solana Mainnet Memo Simulation (Benchmark) | **PASS (`err=null`)** | Live `simulateTransaction` on `CATE` (`SAFE`, `91.8/100`) at Slot **`476,957,083`** (`59,248 CU`, `396`-char Base64 Legacy TX); `CRITICAL_RUG_ALERT` HTTP `400` refusal verified |
| Solana Mainnet Memo Simulation (Live UI Blink) | **PASS (`err=null`)** | End-to-end Web Console Blink simulation verified at Slot **`476,960,081`** (`60,870 CU`, `err=null`) |
| Automated Offline Test Suite | **15 / 15 PASS** | `pytest` covers 3-tier adapter routing, HTTP 429 fallback, Token-2022 parser, hallucination gate, MCP JSON-RPC 2.0 (+ BOM safety), Solana Actions wire format & preflight, Base58 validation, and FastAPI routes |
| Headless Browser Visual QA (`1920x1080`) | **0 errors / 0 overflow** | Verified across all 4 dark & light console views (`0` console, page, or HTTP errors; exact `1920x1080` single-screen layout) |
---
## How CoinGecko API is Used
GeckoShield treats CoinGecko and GeckoTerminal telemetry as a cryptographically verifiable input layer rather than an unchecked prompt string.
### 1. Three-Tier Adaptive Client (Zero-Key Out of the Box)
`src/geckoshield/coingecko_client.py` implements an automatic 3-tier adapter that works immediately without requiring paid keys or credit cards while upgrading transparently when a key is configured in `.env`:
| Tier | Trigger Environment Variable | Market Endpoint Base | Solana On-Chain DEX Base | Auth Header |
|---|---|---|---|---|
| **Tier 1 (`pro_analyst`)** | `COINGECKO_PRO_API_KEY` | `https://pro-api.coingecko.com/api/v3` | `https://pro-api.coingecko.com/api/v3/onchain` | `x-cg-pro-api-key` |
| **Tier 2 (`demo_hybrid`)** | `COINGECKO_DEMO_API_KEY` | `https://api.coingecko.com/api/v3` | `https://api.geckoterminal.com/api/v2` | `x-cg-demo-api-key` |
| **Tier 3 (`public_zero_key`)** | *(none required)* | `https://api.coingecko.com/api/v3` | `https://api.geckoterminal.com/api/v2` | *(none)* |
### 2. Exact CoinGecko & GeckoTerminal Endpoints Consumed
| Endpoint | Purpose in GeckoShield | Bound Provenance Citations |
|---|---|---|
| `GET /simple/price?ids=solana&vs_currencies=usd&include_24hr_vol=true&include_24hr_change=true` | Live SOL market benchmark (`$64.27`, `$5.04B` 24h vol, `-10.95%` 24h change) displayed in header ticker and benchmark context | Market envelope SHA-256 |
| `GET /search/trending` | Cross-market CoinGecko trending context for snapshot enrichment | Market envelope SHA-256 |
| `GET /networks/solana/trending_pools?include=base_token,dex` | Ingests live trending Solana long-tail pools (15 pools per cohort) with token metadata and DEX venue attribution | `[CG-01]` through `[CG-10]` |
| `GET /networks/solana/new_pools?include=base_token,dex` | Ingests newly deployed Solana long-tail pools (15 pools per cohort) for early launch risk screening | `[CG-01]` through `[CG-10]` |
| `GET /networks/solana/tokens/{mint}/pools?include=base_token,dex` | Resolves the deepest liquidity pool as canonical pricing venue for any arbitrary Solana mint lookup | `[CG-01]` through `[CG-10]` |
| `GET /networks/solana/pools/{pool_address}/ohlcv/hour?limit=24` | Retrieves 24-hour hourly OHLCV candles returned by `/api/audit/{mint}` and the `audit_solana_token` MCP tool for agent trend analysis | OHLCV envelope SHA-256 |
| `GET /networks/solana/pools/{pool_address}/trades` | Retrieves recent on-chain pool swap flow for trade-level inspection | Trades envelope SHA-256 |
### 3. Cryptographic Provenance (`[CG-01..CG-10]`) & Rate-Limit Resilience
- **Immutable SHA-256 Provenance**: Every raw JSON response is canonicalized (`sort_keys=True, separators=(",", ":")`) and hashed via `SHA-256`. Each extracted metric—spot price (`[CG-01]`), reserve liquidity (`[CG-02]`), 24h volume (`[CG-03]`), 24h turnover ratio (`[CG-04]`), 24h price change (`[CG-05]`), 24h transaction count (`[CG-06]`), unique traders (`[CG-07]`), tx-per-unique-trader ratio (`[CG-08]`), pool age in hours (`[CG-09]`), and FDV (`[CG-10]`)—is stored as a typed `EvidenceRecord` with exact URL, UTC timestamp, and payload hash.
- **Deterministic Hallucination Enforcement**: CoinGecko metrics drive 4 of the 6 risk scoring dimensions (`liquidity_depth_risk`, `wash_volume_risk`, `pool_maturity_volatility_risk`, and behavioral honeypot floors) and are audited line-by-line by `verify_memo_grounding()` before any report is cleared.
- **Bounded Backoff + Verified Mainnet Snapshot Fallback**: A thread-safe rate pacer (`0.35s` minimum interval) and bounded HTTP `429` retry loop (honoring `Retry-After` with capped exponential backoff) prevent upstream bursts. If public endpoints throttle during evaluation, GeckoShield transparently serves the verified recorded Mainnet snapshot (`data/live_longtail_snapshot.json`) while explicitly tagging `data_source: "recorded_mainnet_snapshot"` and preserving original `payload_sha256` digests.
---
## How Solana is Used
Solana is embedded across on-chain contract forensics, risk-gated Actions/Blinks v2, pure-Python transaction serialization, live RPC simulation, and browser wallet signing:
1. **Single-Batch Mainnet `getMultipleAccounts` (`jsonParsed`) Mint & Token-2022 Parser (`src/geckoshield/solana_inspector.py`)**:
- Audits all 30 radar mints in a single `getMultipleAccounts` JSON-RPC call (chunk size up to 100), anchoring every finding to its exact Mainnet context slot (`Slot 476,957,067` in the benchmark cohort).
- Inspects owner program (`TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA` vs. `TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb`), `mintAuthority`, `freezeAuthority`, supply, decimals, and every Token-2022 extension (`permanentDelegate`, `transferHook`, `transferFeeConfig`, `defaultAccountState`, `nonTransferable`, `mintCloseAuthority`, `pausableConfig`, and benign metadata extensions).
- **Live Mainnet Discoveries**: Across 30 live pools (`26` Token-2022, `4` SPL), GeckoShield flagged **`TERMINUS`** (`6aPXErchjfESVWejxNu4JWM4xdzCMSwooXtgZDrR4rtR`) and **`SI`** (`DEW9dSN6QpWyNthphCpMmAbZP1Q4cEKR9xQXAri98WDP`) for running active `transferFeeConfig` (`100 bps` / `1.00%`) while retaining a **mutable `transferFeeConfigAuthority`** capable of raising transfer taxes up to `100%` post-launch.
- **Strict RPC Honesty**: When deep single-token audits call `getTokenLargestAccounts` and public Solana Mainnet RPC returns HTTP `429`, GeckoShield records `holder_concentration.status = "rpc_rate_limited"` (`[SOL-11]`) and intentionally withholds exact holder percentages instead of hallucinating estimates.
2. **Risk-Gated Solana Actions & Blinks v2 (`src/geckoshield/solana_actions.py`)**:
- Serves spec-compliant `GET /actions.json`, `OPTIONS/GET/POST /api/actions/attest/{mint}` with mandatory CORS headers, `X-Action-Version: 2.2`, and `X-Blockchain-Ids: solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp`.
- **Hard `CRITICAL_RUG_ALERT` Refusal Gate**: If a mint triggers a lethal backdoor (such as `permanentDelegate`, `defaultAccountState=frozen`, `transferFeeConfig > 1000 bps`, active `transferHook`, `nonTransferable`, or active `freezeAuthority`), `GET` sets `disabled: true` with grounded warning citations and `POST` refuses transaction issuance with **HTTP `400`** (`ActionBlockedError`).
3. **Pure-Python Solana Legacy Transaction Builder & Live Mainnet `simulateTransaction`**:
- For non-critical tokens, `build_memo_transaction_base64()` serializes a spec-compliant unsigned Solana Legacy Transaction (Base58 codec + `compact-u16` short_vec framing) invoking the official **SPL Memo Program** (`MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr`) with a live finalized blockhash from `getLatestBlockhash`.
- Compact on-chain attestation payload format:
```text
GeckoShield:v1|mint=<MINT>|tier=<TIER>|safety=<SCORE>|sha256=<16_HEX_DIGEST>|slot=<SLOT>
```
- **Live Mainnet Simulation Proof**:
- Benchmark run on `CATE` (`Ai66LHZG9MCzg1WKdawwqduVAXpNDUuV8M3uyq5ppump`, `SAFE`, `91.8/100`): **PASS** at Solana Mainnet Slot **`476,957,083`**, **`59,248 CU`** consumed, `err=null`, `396`-character Base64 transaction.
- Interactive Web Console Blink simulation: **PASS** at Solana Mainnet Slot **`476,960,081`**, **`60,870 CU`** consumed, `err=null`.
4. **Solflare Wallet Standard Integration (`web/app.js`)**:
- Detects `window.solflare` / `window.solana.isSolflare` in the browser console to connect a real Solflare wallet for Memo transaction signing, and automatically provides zero-friction **Read-Only Simulation Mode** using a public funded Mainnet signer key (`sigVerify=false`) so any evaluator can test full Blink generation and Mainnet `simulateTransaction` without installing a wallet extension.
---
## Visual Walkthrough & Evidence Gallery
### Web Security Console (1920x1080 Live Captures)
**1. Long-Tail Pool Radar** — Real-time trending & newly launched Solana pools ranked by 6-dimension risk score, Token-2022 badges, and wash-turnover ratios (`ishoespeed 113.1x`, `Jellykit 92.6x`, `TERMINUS 62.0x`), with prominent CoinGecko & GeckoTerminal attribution.

**2. Token Forensic Dossier** — Deep single-mint audit showing the SPL/Token-2022 extension & authority matrix (`TERMINUS` live `transferFeeConfig` 100 bps + mutable authority at Slot `476,957,067`), 6-dimension risk breakdown, citation-highlighted Security Memo (`100% Grounded`), and SHA-256 Evidence Provenance Ledger (while `/api/audit/{mint}` and `audit_solana_token` also return 24h hourly OHLCV candles).

**3. Hallucination Gate & MCP Lab** — Interactive adversarial testing bench: inject spoofed liquidity, price, or authority assertions into a memo and watch the Citation Verification Gate intercept every ungrounded claim in real time, alongside a live MCP tool runner.

**4. Solana Actions / Blinks & Benchmarks** — Risk-gated Solana Blink card preview, live Mainnet `simulateTransaction` verification (`Slot 476,960,081`, `60,870 CU`, `err=null`) against `MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr`, and cohort benchmark distributions.

### Quantitative Mainnet Benchmark Charts
**5. Live Solana Mainnet Long-Tail Risk Landscape (`30 Pools @ Slot 476,957,067`)** — Liquidity reserve vs. 24h wash-turnover ratio scatter and risk-tier breakdown highlighting extreme turnover outliers (`ishoespeed 113.085x`, `Jellykit 92.583x`) and live mutable `transferFeeConfig` tokens (`TERMINUS`, `SI`).

**6. Hallucination Grounding & Token-2022 Security Scorecard** — `50/50` (`100%`) adversarial hallucination interception across 7 attack categories with `0%` clean false positives, paired with `25/25` (`100%` TPR) Token-2022/authority backdoor detection and `0/5` (`0%` FPR) benign controls.

---
## Quickstart & Setup Steps
### Prerequisites
- Python **3.10+** (`python --version`)
### 1. Clone & Install
```bash
git clone <YOUR_REPO_URL>
cd long-tail-coingecko-solana
pip install -e ".[dev]"
```
### 2. Configure Environment (Optional — Runs Zero-Key Out of the Box)
Copy `.env.example` to `.env` if you wish to supply a CoinGecko Analyst/Pro or Demo API key, or a dedicated Solana RPC URL:
```bash
# macOS / Linux
cp .env.example .env
# Windows PowerShell
Copy-Item .env.example .env
```
> **Security Notice**: **NEVER commit `.env` or any real CoinGecko / OpenAI / RPC API keys to version control.** `.env` is already excluded in `.gitignore`. GeckoShield runs cleanly out of the box with zero API keys via public CoinGecko v3, GeckoTerminal v2, public Solana Mainnet RPC, and the verified recorded Mainnet snapshot fallback.
### 3. Run the Web Console & FastAPI Server
Option A (recommended explicit port `8080`):
```bash
uvicorn geckoshield.api:app --host 127.0.0.1 --port 8080
```
Then open `http://127.0.0.1:8080` (interactive OpenAPI docs at `http://127.0.0.1:8080/docs`, Solana Actions discovery at `http://127.0.0.1:8080/actions.json`).
Option B (installed CLI entrypoint; defaults to `http://127.0.0.1:8000`, override with `GECKOSHIELD_PORT=8080`):
```bash
geckoshield-api
```
### 4. Run the MCP Server (Claude Desktop / Claude Code / Cursor)
Launch directly over JSON-RPC 2.0 stdio:
```bash
geckoshield-mcp
# or:
python -m geckoshield.mcp_server
```
Register in your Claude Desktop, Claude Code, or Cursor MCP configuration (`claude_desktop_config.json` / `.cursor/mcp.json`):
```json
{
"mcpServers": {
"geckoshield": {
"command": "geckoshield-mcp",
"args": []
}
}
}
```
Pair with the repository's [`SKILL.md`](SKILL.md) agent skill so LLM agents strictly invoke the 5 exposed tools (`scan_solana_long_tail_pools`, `audit_solana_token`, `verify_memo_grounding`, `detect_wash_volume_anomalies`, `build_audit_attestation_blink`) and enforce zero-hallucination citation rules.
### 5. Re-Run the Live Mainnet Benchmark & Charts
```bash
python benchmarks/run_longtail_audit_benchmark.py
```
This fetches live Solana trending + new pools, executes single-batch Mainnet mint inspection, runs the 50-case adversarial hallucination suite and 30-case Token-2022 security suite, executes live Mainnet Memo `simulateTransaction`, and regenerates `data/live_longtail_snapshot.json`, `docs/evidence/longtail-audit-benchmark.json`, `docs/evidence/longtail-audit-benchmark.csv`, and both `1600x900` benchmark PNG charts.
### 6. Run the Offline Deterministic Test Suite
```bash
pytest
```
Expected output: **`15 passed`** (100% offline deterministic verification with zero external network dependencies).
---
## Repository Layout
```text
long-tail-coingecko-solana/
├── README.md # Project overview, API/Solana usage, gallery & quickstart
├── SKILL.md # Agent skill specification for Claude Code / Cursor / MCP
├── LICENSE # MIT License
├── pyproject.toml # Package metadata, dependencies & CLI entrypoints
├── .env.example # Safe environment template (no real keys)
├── src/geckoshield/
│ ├── coingecko_client.py # 3-tier CoinGecko/GeckoTerminal client + SHA-256 + 429 fallback
│ ├── solana_inspector.py # Batched Mainnet SPL/Token-2022 parser + RPC simulation
│ ├── forensic_agent.py # 6-dimension risk engine, floor gates & grounded memo builder
│ ├── citation_verifier.py # Deterministic Hallucination Audit Gate (numeric + boolean facts)
│ ├── solana_actions.py # Solana Actions/Blinks v2 + pure-Python SPL Memo TX builder
│ ├── mcp_server.py # JSON-RPC 2.0 stdio MCP server exposing 5 security tools
│ └── api.py # FastAPI server hosting REST, MCP bridge, Blinks & Web UI
├── web/
│ ├── index.html # Single-screen 4-view security console markup
│ ├── styles.css # Institutional dark/light design tokens & layout
│ └── app.js # Vanilla ES2020 console logic & Solflare Wallet Standard
├── benchmarks/
│ └── run_longtail_audit_benchmark.py # Live Mainnet cohort, adversarial & Token-2022 benchmark runner
├── tests/
│ └── test_geckoshield.py # 15-case offline deterministic pytest suite
├── data/
│ └── live_longtail_snapshot.json # Verified recorded Mainnet snapshot (Slot 476,957,067)
├── demo/screenshots/ # Live 1920x1080 Web Console screenshots
└── docs/
├── architecture.md # System diagrams, risk math, Token-2022 matrix & wire spec
├── superteam-submission-draft.md # Superteam Earn copy-paste submission package
└── evidence/ # Benchmark JSON, CSV, and 1600x900 quantitative PNG charts
```
---
## License & Attribution
Released under the **MIT License**. See [`LICENSE`](LICENSE) for full terms.
- **[Data provided by CoinGecko](https://www.coingecko.com/en/api)**
- **[On-chain data provided by GeckoTerminal](https://www.geckoterminal.com)**
TDQS
Scored across 5 tools
Each tool has a fairly distinct action (audit a mint, scan trending pools, verify a memo, detect wash volume, build a Blink). However, scan_solana_long_tail_pools explicitly says it ranks pools by risk and wash-volume anomalies, which overlaps with detect_wash_volume_anomalies, and the boundary between audit_solana_token's memo output and verify_memo_grounding is only implied.
All five tools use a clean snake_case verb_noun pattern (audit_, scan_, verify_, detect_, build_) with domain nouns appended as qualifiers. The convention is predictable and readable across the whole set.
Five tools is well-scoped for a Solana token-audit service; each tool covers a distinct stage of the workflow (audit, discovery, validation, anomaly detection, attestation) and carries substantial functionality. No padding or filler tools are present.
The pipeline covers audit -> scan -> verify -> attest, but there is no tool to retrieve a previously generated EvidenceRecord, list past audits/attestations, or fetch a memo by digest — verify_memo_grounding depends on a ledger the agent cannot re-fetch in a stateless session. There is also no way to inspect an arbitrary wallet/holder distribution, which limits deeper forensic coverage.