Skip to main content
Glama
GeckoPilot MCP

GeckoPilot MCP

README.md
# GeckoPilot MCP

**Zero-dependency grounded autonomous Solana AI agent workbench & native Model Context Protocol (MCP) server powered by CoinGecko API v3 & GeckoTerminal.**

Built for the **CoinGecko × Superteam Long Tail Hackathon — Track #4: AI Agents**.

> **Live Interactive Mission Control:** https://ngominhtam1998.github.io/geckopilot-mcp/  
> **Data Attribution:** Data provided by CoinGecko API & GeckoTerminal. Read-only Solana telemetry — zero private keys, zero external npm dependencies.

---

## Why GeckoPilot MCP?

Most crypto AI agents hallucinate token prices, pool liquidity, or slippage estimates—and then make dangerous trade recommendations off invented numbers. **GeckoPilot MCP** solves this at the protocol and runtime layer:

1. **Cryptographic Evidence Receipts (SHA-256):** Every CoinGecko API v3, GeckoTerminal Solana v2, and read-only Solana RPC response is canonicalized and hashed (`SHA-256`) into an immutable receipt (`receiptId`, `provider`, `endpoint`, `fetchedAt`, `sha256`, `payload`).
2. **Zero-Hallucination Citation Auditor (`cg_verify_grounding`):** Every single numeric figure in an agent report binds to an exact `[receiptId -> fieldPath]` (or deterministic formula derivation whose inputs each bind to raw receipts). If ANY number is fabricated, rounded outside tolerance, or references a tampered receipt, Agent 2 rejects it and Agent 3 **hard-blocks execution** (`BLOCK_EXECUTION`).
3. **Isomorphic 3-Agent Workflow Engine (`shared/agent_runtime.mjs`):** Runs identically in the **Native `stdio` MCP Server**, **Node CLI**, and **Live Browser Mission Control** with zero build step and zero npm dependencies.

---

## Architecture: 3-Agent Grounded Pipeline

```text
CoinGecko API v3 + GeckoTerminal Solana v2 + Read-Only Solana RPC
   (90s TTL Cache · HTTP 429 Cooldown Guard · SHA-256 Receipts)
                             │
                             ▼
            ┌─────────────────────────────────┐
            │  Agent 1 · Scout                │  Invokes MCP tools via JSON-RPC 2.0
            │  (MCP Tool Caller)              │  Mints canonical SHA-256 Evidence Receipts
            └────────────────┬────────────────┘
                             │
                             ▼
            ┌─────────────────────────────────┐
            │  Agent 2 · Citation Verifier    │  Executes cg_verify_grounding
            │  (Zero-Hallucination Auditor)   │  Re-hashes payloads & verifies every number
            └────────────────┬────────────────┘
                             │
                             ▼
            ┌─────────────────────────────────┐
            │  Agent 3 · Policy Guardrail     │  Enforces liquidity floor, AMM impact cap,
            │  (Solana Risk Gate)             │  pool maturity, FDV overhang & order flow
            └─────────────────────────────────┘
                             │
                             ▼
       ALLOW_TEST_ALLOCATION │ MONITOR_ONLY │ BLOCK_EXECUTION
```

---

## Native `stdio` MCP Server (`src/mcp-server.mjs`)

Implements JSON-RPC 2.0 MCP protocol (`2024-11-05`) with automatic dual-framing (newline-delimited JSON and `Content-Length` framing), exposing `initialize`, `notifications/initialized`, `ping`, `tools/list`, `tools/call`, `resources/list`, and `resources/read`.

### 6 Grounded Solana MCP Tools

| Tool Name | Purpose | Upstream Sources |
|---|---|---|
| `cg_token_due_diligence` | Full pool reserve depth, pool age, FDV/reserve overhang, 24h buy/sell share & CoinGecko market depth | GeckoTerminal Solana v2 + CoinGecko API v3 |
| `cg_solana_anomaly_scan` | Sweeps live trending & newly deployed Solana pools for turnover spikes, thin exit doors & skewed flow | GeckoTerminal `trending_pools` + `new_pools` |
| `cg_trade_guardrail_quote` | Deterministic constant-product (`x·y=k`) AMM price impact, LP fee & max safe clip enforcement | GeckoTerminal Solana v2 |
| `cg_narrative_momentum` | CoinGecko category 24h momentum + Solana ecosystem leaders for macro regime classification | CoinGecko `coins/categories` + `coins/markets` |
| `cg_wallet_risk_audit` | Read-only Base58 Solana RPC (`getBalance` + SPL `getTokenAccountsByOwner`) priced live in USD | Solana Mainnet RPC + CoinGecko API v3 |
| `cg_verify_grounding` | Zero-Hallucination Citation Auditor verifying claims & derivations against SHA-256 raw receipts | Pure deterministic FIPS 180-4 SHA-256 verifier |

---

## Quick Start (Zero `npm install`)

Requires **Node.js 20+** (tested on Node 24.15.0). No dependencies to install!

### 1. Run the 3-Agent Grounded CLI
```bash
# Mission 1: Solana Token Due Diligence (live CoinGecko/GeckoTerminal)
node src/cli.mjs --mission token_due_diligence --token JUP --trade-usd 5000

# Mission 2: Live Solana Pool Anomaly Hunt
node src/cli.mjs --mission solana_anomaly_hunt

# Mission 3: Execution Guardrail Quote
node src/cli.mjs --mission execution_guardrail_check --token BONK --trade-usd 25000

# Prove Zero-Hallucination Blocking (injects a fake number before Agent 2 verifies)
node src/cli.mjs --mission token_due_diligence --token JUP --simulate-hallucination --snapshot

# Invoke any single MCP tool directly
node src/cli.mjs --tool cg_narrative_momentum --args '{"limit":6}'
```

### 2. Connect Native MCP Server to Claude Desktop / Cursor / Antigravity
Add to `claude_desktop_config.json`, `.cursor/mcp.json`, or `~/.gemini/antigravity/mcp_config.json`:

```json
{
  "mcpServers": {
    "geckopilot-mcp": {
      "command": "node",
      "args": ["/absolute/path/to/geckopilot-mcp/src/mcp-server.mjs"],
      "env": {
        "COINGECKO_API_KEY": "",
        "COINGECKO_API_TIER": "demo"
      }
    }
  }
}
```

### 3. Launch Local Web Mission Control
```bash
node src/server.mjs
# Open http://127.0.0.1:4173/
```

### 4. Refresh Live Snapshot & Run Automated Verification Suite (21 Tests)
```bash
# Capture fresh live CoinGecko + GeckoTerminal + Solana RPC snapshot
node src/fetch_snapshot.mjs

# Run all 21 automated tests (includes real child-process stdio JSON-RPC MCP tests!)
node tests/run_tests.mjs
```

---

## Interactive Web Mission Control Highlights (`docs/`)

- **3 One-Click Agent Missions** (`Token Due Diligence`, `Solana Anomaly Hunt`, `Execution Guardrail Check`) + custom Base58 Solana mint support + live **"Refresh Live"** trigger.
- **Simulate Hallucination Attack Toggle:** Injects a synthetic numeric mismatch before Agent 2 runs, visibly proving real-time SHA-256 interception (`REJECTED_HALLUCINATION`) and automatic Agent 3 `BLOCK_EXECUTION`.
- **Click-Any-Number Citation Provenance Drawer:** Click any emerald or rose pill in the Executive Brief or Claim Ledger to inspect the exact `receiptId`, upstream URL, full 64-hex `SHA-256` re-hash proof, derivation formula, and highlighted raw CoinGecko/GeckoTerminal JSON field.
- **Interactive Policy Sliders:** Adjust Liquidity Floor, Max AMM Price Impact Cap, and Pool Maturity live to re-evaluate Agent 3 deterministically.
- **Live MCP Tool Tester (6 Tools) & JSON-RPC Trace Viewer:** Execute all 6 tools interactively and inspect raw `tools/call` frames.
- **Export Verifiable Proof:** 1-click **1200×630 Canvas 2D Trace PNG** export and full **Audit JSON Trace** download.
- **Optional CoinGecko Demo/Pro API Key Drawer:** Stored strictly in browser `localStorage` and sent only to CoinGecko API directly.

---

## Repository Layout

```text
geckopilot-mcp/
├── shared/                    # Isomorphic ESM core (Node CLI, MCP Server, Browser)
│   ├── agent_runtime.mjs      # 3-Agent workflow engine (Scout -> Verifier -> Guardrail)
│   ├── coingecko_client.mjs   # CoinGecko v3 + GeckoTerminal v2 + Solana RPC (90s TTL + 429 guard)
│   ├── crypto_hash.mjs        # Canonical JSON + FIPS 180-4 SHA-256
│   ├── grounding.mjs          # Zero-Hallucination Citation Auditor
│   ├── policy.mjs             # Deterministic Solana policy engine + AMM x*y=k quote math
│   └── tools.mjs              # 6 grounded Solana MCP tools & JSON Schemas
├── src/
│   ├── mcp-server.mjs         # Native zero-dependency stdio JSON-RPC 2.0 MCP Server
│   ├── cli.mjs                # Terminal runner for missions & tools
│   ├── fetch_snapshot.mjs     # Live CoinGecko/GeckoTerminal/Solana RPC snapshot capturer
│   └── server.mjs             # Hardened static HTTP server (path-traversal protected)
├── docs/                      # GitHub Pages live Mission Control (Vanilla HTML/CSS/JS)
│   ├── index.html
│   ├── styles.css
│   ├── app.js
│   ├── export_png.js          # 1200x630 Canvas 2D Grounded Trace PNG generator
│   ├── shared/                # Verified byte-for-byte mirror of shared/ for GitHub Pages
│   └── data/snapshot.json     # Live-captured CoinGecko/GeckoTerminal Solana snapshot
├── tests/
│   └── run_tests.mjs          # 21-test automated verification suite (100% pass)
├── .env.example
├── LICENSE                    # MIT License
└── package.json               # Zero external dependencies
```

---

## Data Attribution & Safety

**Data provided by CoinGecko API & GeckoTerminal.**  
GeckoPilot MCP is strictly read-only. It never requests, accepts, or signs Solana private keys or transactions.