base-stock-sentinel-mcp
by xgbtxy
README.md
# Base Stock Sentinel MCP (`base-stock-sentinel-mcp`)
Autonomous **Base B20 tokenized-stock due diligence**, **corporate-action multiplier drift radar**, and **Base DEX liquidity/slippage routing** server — built for AI agents over **Streamable HTTP MCP** and **x402 v2 Base-USDC** micropayments on Cloudflare Workers.
> **Compliance & Scope Notice**: 100% read-only onchain analytics and liquidity routing signals. Holds **zero private keys**, executes **zero trades**, does not custody funds or offer US securities brokerage/solicitation. **Not investment advice.**
## Why Base Stock Sentinel?
Onchain tokenized equities on Base (**Coinbase B20 Tokenized Stocks**) introduce two pitfalls that break naive crypto trading & research agents:
1. **Corporate-Action Multiplier Drift (`multiplier != 1`)**: B20 tokens adjust their share-to-token ratio (`multiplier`) for reinvested dividends, stock splits, and corporate actions (e.g., `GOOGLc` at `1.000377...`, `SANc` at `1.01057...`, `SNDKc` at `8.0`). Comparing raw DEX token price directly against an underlying stock quote misprices the asset unless adjusted by `dexPrice / multiplier`.
2. **Fragmented Base DEX Liquidity & Paper-Depth Traps**: Liquidity splits across Aerodrome Slipstream and Uniswap V3 pools on Base with varying fee tiers, spreads, and one-sided depth. A naive order can suffer severe slippage or cross-pool mispricing.
**Base Stock Sentinel** combines live public Coinbase B20 metadata with live GeckoTerminal Base DEX pool telemetry to deliver deterministic, SHA-256 attested due-diligence reports in one MCP or REST call.
## Public Zero-Key Data Sources
- **Coinbase B20 Tokenized Stocks API**: `GET https://api.coinbase.com/v1/tokenized-stocks` & `GET https://api.coinbase.com/v1/tokenized-stocks/chains` (Base `8453` protocol contracts + ~100 B20 equities)
- **GeckoTerminal Base DEX API**: `GET https://api.geckoterminal.com/api/v2/networks/base/tokens/{address}/pools` (Aerodrome / Uniswap V3 reserves, 24h volume, buys/sells, FDV, price changes)
- **Deterministic Offline Fixtures (`?demo=1` / `sample: true`)**: 5 structured B20 samples (`NVDAc`, `GOOGLc` with non-1 multiplier, `MSTRc`, `AAPLc`, and `THINc` ultra-thin liquidity trap) for zero-network verification and graceful 429 fallback.
## Endpoints & Pricing (Base `eip155:8453` USDC via x402 v2)
| Route / MCP Tool | Price (USDC) | Description |
| --- | --- | --- |
| `GET /` | Free (`$0`) | Browser `Accept: text/html` serves the zero-CDN **Interactive Base B20 Stock Sentinel Terminal**; JSON clients receive compact status |
| `GET /api/catalog` | Free (`$0`) | Full Base B20 catalog + `multiplier != 1` highlights + Base 8453 protocol contracts (`?demo=1`, `?only_adjusted=true`, `?search=...`) |
| `POST /api/stock-inspect` / `stock_inspect` | `$0.01` | Deep single-stock due diligence: multiplier-adjusted equivalent price, cross-pool spread, 3-tier (`$1k / $10k / $50k`) exit slippage curve, `maxSafeTradeUsd` (`<= 1.5%`), 0–100 risk score + tags + SHA-256 digest |
| `POST /api/stock-compare` / `stock_compare` | `$0.02` | Side-by-side comparison of 2–5 Base B20 stocks ranked by composite safety & executable depth, with `NO SAFE PICK` guard |
| `POST /api/multiplier-radar` / `multiplier_radar` | `$0.01` | Full-catalog scan for corporate-action multiplier drift (`DIVIDEND_REINVEST` vs `SPLIT_OR_MAJOR_ADJUSTMENT`) and supply leaders |
| `POST /mcp` | Streamable HTTP | MCP tools: `stock_inspect`, `stock_compare`, `multiplier_radar`, plus free `sample_tools` |
| `GET /.well-known/x402`, `/openapi.json`, `/llms.txt`, `/health` | Free (`$0`) | x402 v2 discovery manifest, strict OpenAPI 3.1 + `x-payment-info` (`x402scan` compliant), AI agent discovery |
Append `?sample=true` to any `POST /api/*` route or pass `{"sample": true}` in MCP `tools/call` for a free deterministic offline sample response.
## Quick Start
```bash
npm install
npx tsc --noEmit
npm test
npm run dev
```
### Example Requests
```bash
# 1. Free B20 catalog (live or offline ?demo=1)
curl -sS "http://localhost:8787/api/catalog?demo=1"
# 2. Free offline sample inspection (zero outbound fetch)
curl -sS -X POST "http://localhost:8787/api/stock-inspect?sample=true" \
-H "Content-Type: application/json" \
-d '{"query":"GOOGLc"}'
# 3. Inspect live x402 v2 HTTP 402 Base-USDC payment challenge
curl -i -sS -X POST "http://localhost:8787/api/stock-inspect" \
-H "Content-Type: application/json" \
-d '{"query":"NVDAc"}'
```
### Connect Claude Desktop / Cursor (Streamable HTTP MCP)
```json
{
"mcpServers": {
"base-stock-sentinel-mcp": {
"type": "http",
"url": "https://base-stock-sentinel-mcp.yan8925298.workers.dev/mcp"
}
}
}
```
## License
MIT — see [LICENSE](./LICENSE).
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues