Skip to main content
Glama
README.md
# QuoteGuard MCP

**Grounded Solana Agent Trade-Quote Guard & Citation-Backed Due-Diligence Agent**

QuoteGuard checks a proposed swap before an agent can hand it to a wallet. It prices both token legs, checks the pool reserve and observation times, and returns a reasoned verdict. A second tool writes a short token memo. Selecting a figure opens its exact source field and original response.

[Open the offline inspection desk](dist/offline.html) · [Watch the 84-second demo](docs/demo_quoteguard_1080p.mp4) · [Track 2 submission notes](docs/SUBMISSION_PACK.md)

## Try the signed replay

Download and unpack the review ZIP. Open `dist/offline.html` in Chromium. A GitHub file preview displays source, so download the HTML to run it locally. The page contains the evidence, verification key and tool implementation.

1. Switch between **Wide spread** and **Tight spread**. The guard reports **BLOCK** at 500 bps and **ALLOW** at 18 bps on the displayed precision. Click the deviation to inspect the exact rational calculation.
2. Open **Diligence memo**. Select the BONK top-ten holder share or a value in the short brief. The inspector shows the raw field, endpoint, UTC retrieval time, JSON Pointer and verified response hash.
3. Choose **Tamper with one digit**. The verifier identifies the reserve claim, line, expected value and changed value. **Restore verified memo** reproduces the original.
4. Open **New pools** to screen the feed or compare quotes in one batch. **MCP trace** exposes request and response envelopes from the browser’s in-process dispatcher. The integration suite exercises that dispatcher over a real stdio connection.

The proposed quotes and caller timestamps in replay scenarios are generated test inputs. Market responses are real. Replay evaluates at the freeze clock. Live mode evaluates against the current clock.

## Setup

Use Node 24.14 or later in the Node 24 line and npm. For a source checkout, run the following in the project root.

```sh
npm ci
npm test
npm run build
node cli/index.mjs demo wide
node cli/index.mjs memo BONK
```

The downloadable ZIP includes an integrity-checked npm package bank. For a disconnected install use the following commands. The bank contains macOS ARM64 and Linux x64 native packages. The clean extraction receipt records the platform actually exercised.

```sh
node scripts/offline-install.mjs
npm test
npm run build
npm run check:snapshot
```

Public live reads work keyless. The optional **free Demo key** is read from `COINGECKO_API_KEY` and sent in a header exclusively to the CoinGecko Demo origin. [Environment example](.env.example)

```sh
node cli/index.mjs --live memo BONK
node --use-env-proxy cli/index.mjs --live memo BONK
```

The second command uses a configured system HTTP(S) proxy through Node. A live research lookup accepts a Solana mint or ticker. A ticker outside the signed shortcuts goes through a Solana pool search and must match a unique mint. An ambiguous result asks the caller for the address.

## MCP, CLI and the pre-swap adapter

Start the server with `node mcp/server.mjs --snapshot` or `node mcp/server.mjs --live`. The example MCP host configuration uses an absolute path on the host machine.

```json
{"mcpServers":{"quoteguard":{"command":"node","args":["/absolute/path/to/quoteguard-mcp/mcp/server.mjs","--snapshot"]}}}
```

| MCP tool | Inputs | Result |
| --- | --- | --- |
| `solana_guard_swap_quote` | Two mints, integer base-unit amounts, UTC quote time, optional direct pool and policy | Verdict, reasons, exact deviation and evidence |
| `solana_token_dd_memo` | Ticker or mint | Short brief, field ledger, coverage and citation index |
| `solana_verify_memo_citations` | Complete memo object | Verified field count or precise discrepancies |
| `solana_screen_new_pools` | Minimum reserve and result limit | Recent pools with reserve and authority reasons |
| `solana_compare_quotes_batch` | Up to sixteen quotes with a shared policy or aligned per-quote policies | Ordered verdicts on a shared observation and clock |

```sh
node cli/index.mjs list
node cli/index.mjs call solana_screen_new_pools '{"minLiquidityUsd":"10000","limit":3}'
node cli/index.mjs demo tight --csv
node cli/index.mjs memo BONK --csv
```

For any tool, use `call TOOL @args.json` to read its arguments from disk. CSV contains JSON Pointers, types and JSON values, including container types. This preserves nulls, full decimal strings, array order and nested evidence.

The adapter accepts fully allocated, direct Jupiter V1 ExactIn routes whose single hop matches both mints and amounts. Record `receivedAt` at intake. It checks the projected output and a conservative whole-atom floor derived from the quoted slippage. V1 `/swap` builds its own instructions. The host must decode the final transaction and enforce the same pair, pool, input and minimum output at signing. Run the assertion immediately before that step. V2 has a separate order contract. [Jupiter V1 quote reference](https://developers.jup.ag/docs/api-reference/swap/v1/quote)

```ts
import { createQuoteGuardMiddleware, fromJupiterExactIn } from 'quoteguard-mcp';

const guard = createQuoteGuardMiddleware({ policy: { maxDeviationBps: 150 } });
await guard.assertAllowed(fromJupiterExactIn(jupiterQuote, receivedAt));
```

The adapter performs its first read when invoked. It rehashes the returned market bodies, recalculates the decision with the caller’s quote and policy, and checks the earliest expiry again at return time. A supplied transport must connect to a trusted MCP service. On refusal, `QuoteGuardStop.code` identifies the execution stop and `.result` preserves the observed guard verdict for inspection. A live `ALLOW` with a bound direct pool can return from the assertion. A warning, block, stale result, replay or unbound/multihop route stops there. `evaluate` supports read-only inspection of a generic two-mint proposal. [TypeScript host example](sdk/agent-kit-example.ts)

## How CoinGecko API is used

| Observation | Public source | Use |
| --- | --- | --- |
| USD price and provider update time for listed assets | CoinGecko `/simple/price` | Primary listed-token valuation and freshness |
| Routed onchain price | GeckoTerminal `/simple/networks/solana/token_price/{mints}` | Independent route-market cross-check inside the CoinGecko data family |
| Pool pair, direct route reserve, token daily change and new pools | Solana token pools, direct pool and new-pool endpoints | Mint binding, observed liquidity and discovery |
| Minute OHLCV | Solana pool candles with explicit base/quote side and USD denomination | Price history and candle-timed reference for unlisted assets |
| Holder distribution and authority flags | Solana token `/info` | Concentration, mint authority, freeze authority and reported honeypot status |
| Category membership and peer prices | CoinGecko coin detail, categories list and category-filtered markets | Evidence for the subject’s membership and a distinct peer’s price |

For categorized long-tail assets, the signed cohort can also supply a peer with a matching GeckoTerminal category ID. The research output labels unavailable fields and preserves a provider’s explicit “unknown” value. A positive citation check measures agreement with the available evidence. The separate `coverage` field reports completeness. A cited `unknown` security flag counts as partial coverage. Daily percentage uses the mint-specific onchain field, with a matching base-side pool change as a fallback.

**Data provided by CoinGecko. On-chain data provided by GeckoTerminal.** [CoinGecko](https://www.coingecko.com/) · [GeckoTerminal](https://www.geckoterminal.com/) · [API reference](https://docs.coingecko.com/reference/onchain-simple-price)

## How Solana is used

Quotes use SPL mints and unsigned 64-bit atomic amounts. SOL uses the wrapped SOL mint for comparisons. Pool base and quote relationships bind evidence to the mint on the correct side. Supplying a direct pool requires both quoted mints to be present in that exact pool. Live evaluation requests the pool by its address. Missing direct evidence or conflicting reserve observations at the same time prevent execution. The guard uses reference pool reserves for proposals without a route. Reserves measure observed liquidity; executable depth depends on trade size, fees and pool mechanics.

The guard compares `10000 × |output USD − input USD| / input USD` using BigInt rationals. The exact fraction controls the decision. A displayed decimal can be rounded while a fractional threshold breach still blocks. The default ceiling is 150 bps, the reserve floor is USD 10,000 and the maximum age is 300 seconds. Both favorable and adverse outliers trigger the same absolute-deviation rule. A reserve from the floor up to twice the floor yields `WARN`. Missing or nonpositive prices, mismatched decimals, excessive disagreement, thin liquidity, expired inputs and unusable upstream observations fail closed.

Freshness uses the provider update time or the relevant minute candle start, plus the quote and observed reserve retrieval times. The routed-price cross-check has a retrieval-age check. A pool reserve or a routed-price response can have a different observation time from a listed market price. The SDK exposes a pre-signing decision point. Wallet custody, signing, broadcasting and fills remain with the host.

## Evidence and verification

The release contains 37 public HTTP responses, seven Solana mints and the twenty-entry new-pool feed. SOL, USDC, JUP, BONK and POPCAT are joined by DOOB and Gay, two tickers returned verbatim by the discovery feed. The latter two qualify by observed reserve below USD 10,000 and absolute daily pool price change above seven percent at selection. Addresses disambiguate the names. [Frozen raw responses](data/coingecko_agent_snapshot_20261202.json)

The collector stores the original UTF-8 response text. Each citation binds its endpoint, fetch time, response SHA-256, source kind and RFC 6901 JSON Pointer. Caller inputs, local policy and the evaluation clock use explicit local source identifiers. Derived deviation includes the formula, exact numerator and denominator, plus the source IDs for both prices, amounts and decimal scales.

The release signature covers the entire capture, including its asset map and timestamps. The Ed25519 collector key was generated in memory; the verifier pins the public key. The trust anchor is the collector and the distributed fingerprint. CoinGecko supplies the HTTP data over TLS. Live tools attach observed raw bodies and the running MCP server retains its most recent sixteen memo contexts for independent comparison. Use the same live server session to verify a live memo. Frozen memos verify across processes. [Detached seal](data/snapshot.seal.json) · [Pinned public key](core/trust.mjs) · [Citation verifier](core/verifier.mjs)

Snapshot SHA-256

`2ddf4c53594f7ab23dca4ca9f7bba26b4d9c4551f0295bf9e6a044852e12dc1f`

## Acceptance

Vitest exercises malformed quotes, six/nine-decimal conversion, single-atom boundaries, stale sources, timeouts, rate limits, single-digit tampering, source substitution, live session trust, stdio calls and independent CSV reconstruction. Chromium exercises four viewport sizes with networking disabled. The video uses a captured 1920 × 960 UI above a separately rendered 120-pixel caption band.

```sh
npm test
npm run check:browser
npm audit
npm audit --omit=dev
```

The browser check requires locally installed Chromium or `CHROME_PATH`. The downloadable archive can be checked from a copy of this repository with `python3 scripts/verify-archive.py /path/to/review.zip --receipt .work/review.json`. Its install, tests and build disable Node network access. The archive check also packs the SDK, installs it into a separate Node consumer offline, and calls its SDK and CLI. The final two npm audits contact the public advisory registry. [Unpacked replay](docs/receipts/unpacked.json) · [Browser checks](docs/receipts/chromium.json) · [Video frames](docs/receipts/video.json) · [Live quote](docs/receipts/live-stdio.json) · [Live memo](docs/receipts/live-memo.json)

## Screenshots

![A simulated wide SOL–USDC quote blocked by the signed replay](docs/screenshots/quote-block.png)

![The BONK research brief and its individually inspectable fields](docs/screenshots/diligence-memo.png)

![The complete source inspector for the top-ten holder share](docs/screenshots/citation-inspector.png)

## Built from 1 Dec 2026 onwards

Development started on **2 December 2026** for the Long Tail AI Agents track. This standalone project includes the collectors, evidence format, quote policy, memo verifier, MCP implementation, typed adapter, offline desk, video and tests. Original code uses the MIT license. Data and bundled dependencies retain their respective notices. [License](LICENSE) · [Notice](NOTICE) · [Official track](https://superteam.fun/earn/listing/long-tail-ai-agents-with-coingecko-data/)