Skip to main content
Glama

SolGuard MCP — Fail-Closed Solana Agent Policy Gate, Red-Team Harness & Audit Ledger

Built from scratch starting December 2, 2026 for the Superteam Earn "Long Tail: Build on Solana with CoinGecko Data" hackathon (AI Agents track).

SolGuard MCP prevents autonomous AI trading agents and LLM MCP clients from executing unsafe Solana long-tail swaps or prompt-injected trades. Every trade proposal passes through a deterministic 7-invariant fail-closed policy gate, gets stamped with a SHA-256 policyDecisionHash, and commits into a cryptographically hash-chained audit ledger before any simulated or devnet execution can proceed.

Attribution & Scope Notice: Market prices, trending pool liquidity, gt_score, and holder concentration telemetry are fetched live from CoinGecko (Data provided by CoinGecko). Policy verdicts (ALLOW / DENY), slippage curves, and audit ledger hashes are computed independently by SolGuard MCP (SolGuard Independent Policy Decision).


Screenshots

1. Live Autonomous Agent Cycle (ALLOW) & Policy Slippage Frontier

SolGuard Live Agent Cycle

2. Adversarial Prompt-Injection Trap Blocked (DENY — Token-2022 Permanent Delegate)

SolGuard Prompt Attack Blocked

3. Live MCP JSON-RPC 2.0 Tool Inspector & SHA-256 Hash-Chained Ledger

SolGuard MCP Inspector and Hash Ledger


Related MCP server: pnllabs-mcp

Architecture: 6 Real MCP Tools (src/mcp/handlers.ts & src/mcp/server.ts)

Run the real Node stdio JSON-RPC 2.0 MCP server (protocolVersion: "2024-11-05"):

npm run mcp

Or connect any MCP client (Claude Desktop, Cursor, Antigravity):

{
  "mcpServers": {
    "solguard": {
      "command": "npx",
      "args": ["tsx", "src/mcp/server.ts"]
    }
  }
}

Tool Name

Purpose

solguard_scan_longtail

Scans CoinGecko trending Solana pools under policy depth & volatility bounds

solguard_policy_gate

Runs 7-invariant Solana RPC + CoinGecko gate, returning ALLOW/DENY + maxSafeTradeUsd + SHA-256 policyDecisionHash

solguard_rebalance_plan

Computes portfolio drift and CoinGecko-priced rebalance legs capped at maxTradeUsd

solguard_simulate_prompt_attack

Executes 3 prompt-injection red-team probes (thin_pool_rug, token2022_delegate_trap, whale_slippage_blowout)

solguard_append_ledger_exec

Commits verified decisions into a SHA-256 hash-chained audit log (GENESIS -> prevHash -> entryHash)

solguard_verify_ledger

Verifies chain integrity, counts ALLOW/DENY, and totals blocked USD exposure


How Coingecko API is used

  1. Trending Long-Tail Opportunity Feed (GET /api/v2/networks/solana/trending_pools?page=1&include=base_token): Powers solguard_scan_longtail, agent:cycle, and the live CoinGecko scanner panel in the web console.

  2. Pool Liquidity & 24h Flow (GET /api/v2/networks/solana/tokens/{mint}?include=top_pools): Supplies top DEX reserves, pool creation age, 24h buys/sells, and volume USD to compute constant-product (x * y = k) swap price impact and round-trip cost, ensuring the agent stays inside maxSlippageBps and computes quantitative maxSafeTradeUsd remediation.

  3. Holder & Honeypot Metadata (GET /api/v2/networks/solana/tokens/{mint}/info): Evaluates top-10 concentration, developer holding %, and is_honeypot while distinguishing established protocol/custody vaults (reserve >= $500k and gt_score >= 75) from unvetted meme concentration.

  4. Portfolio Rebalance Pricing (GET /api/v3/simple/token_price/solana): Powers solguard_rebalance_plan using live USD spot prices across SOL, USDC, JUP, and BONK.

  5. Resilient Cross-Runtime Fetching (src/services/coingecko.ts): Uses a 1100ms pacing queue, 180s TTL cache (Map in Node / sessionStorage in browser), exponential retry on rate limits, and optional api/cg.ts Vercel serverless proxy (COINGECKO_API_KEY).


How Solana is used

  1. Live Mainnet-Beta JSON-RPC Account Verification (src/services/solanaRpc.ts): Calls https://solana-rpc.publicnode.com (getAccountInfo with jsonParsed encoding + getSlot) in both Node CLI/MCP and the browser console to decode:

    • Classic SPL (TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA), Wrapped SOL native mint, and Token-2022 (TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb) accounts.

    • Live mintAuthority, freezeAuthority, supply, and all active Token-2022 extensions[] (permanentDelegate, transferHook, mintCloseAuthority, transferFeeConfig basis points).

  2. Adversarial Guardrails: Blocks prompt-injected allocations targeting mints with active freeze authorities, shallow AMM pools, or Token-2022 permanentDelegate overrides (demonstrated live against PYUSD Token-2022 on mainnet).

  3. Live Mainnet Slot Anchoring: Every policy decision and hash-chained ledger trace captures the current Solana mainnet slot for reproducible audit trails.


Local Setup, CLI Cycle & Verification

git clone https://github.com/cocvn157/solguard-mcp-agent.git
cd solguard-mcp-agent
cp .env.example .env
npm install
npm test
npm run build
npm run agent:cycle

Windows PowerShell: Use npm.cmd / npx.cmd. Runs $0 capital out of the box with no API keys required (COINGECKO_API_KEY= optional in .env.example for Vercel proxy).

  • Vitest Suite (npm test): 37 tests across 5 files (policyGate, hashLedger, mcpServer JSON-RPC 2.0 dispatch, parsers, rebalance).

  • Live Autonomous Cycle (npm run agent:cycle): Scans CoinGecko trending Solana pools, evaluates JUP & top trending mints against Solana RPC + CoinGecko, blocks all 3 prompt-injection red-team traps, and verifies the SHA-256 hash chain.


Attribution & License

Data provided by CoinGecko. Licensed under the MIT License.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      MCP server for real-time Solana token risk analysis. Cross-references RugCheck.xyz, DexScreener, and GoPlus Security to generate three-layer reports: machine verdict → LLM analysis → raw on-chain evidence. Live on Solana mainnet with USDC micropayments ($0.02/audit). Give any AI agent the ability to check if a token is safe before trading.
      2
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Gives AI trading agents machine-readable trust and risk verdicts on Solana by checking whether a wallet's realized PnL makes it worth copying, where its funds came from, whether a token is structurally safe, and what a given trade size would really cost in slippage. Exposes these four checks as MCP tools callable against a hosted x402 pay-per-call API, so agents can hard-stop bad trades without RPC keys, signup, or local setup.
      1
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enforces a policy ladder for Solana AI agents so on-chain actions are vetted before signing, checking whether an action is justified, recently repeated, or targets only known programs, and applying spend, daily, and slippage caps plus recipient allowlists. Also dry-runs candidate transactions on an RPC and exposes the policy rules as agent prompt instructions.
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI agents to perform DeFi safety checks over MCP, including pre-signing transaction simulation, sanctions and scam address screening, token rug checks, risk-scored launches, and liquidation-risk assessment.
      66 npm
      MIT