Skip to main content
Glama
Frankencoin MCP Server

Frankencoin MCP Server

Official
README.md
# Frankencoin MCP Server

Real-time [Frankencoin](https://frankencoin.com) (ZCHF) protocol data for AI agents and developers. One read-only server, several ways to reach it — supply, prices, peg health, savings, minting positions, liquidation challenges, FCS governance and underlying FPS economics, insurance products, and historical analytics across every supported chain.

**Public endpoint:** `https://mcp.frankencoin.com`

| Interface | Endpoint | Best for |
|-----------|----------|----------|
| **MCP** (Streamable HTTP) | `POST /mcp` | Claude Desktop, Cursor, any MCP client / AI agent |
| **REST** | `GET /api/<tool>` | Scripts, curl, agents — one request, no handshake |
| **CLI** | `frankencoin <command>` | Humans at the terminal |
| **llms.txt** | `GET /llms.txt` | A compact, self-describing guide for LLMs/agents |
| **Legacy SSE** | `GET /sse` | Older MCP clients |

No authentication. No API key required. Read-only.

---

## Version 4

The server implements [MCP 2026-07-28](https://modelcontextprotocol.io/specification/2026-07-28)
over Streamable HTTP and stdio. Modern clients can issue a tool call as their first request.
`server/discover` returns the server identity and capabilities. Clients using the earlier
`initialize` handshake can keep their existing URL and session flow.

| Agent task | Entry point |
| --- | --- |
| Get ZCHF supply, TVL and per-chain supply from one upstream request | `get_protocol_snapshot` with `{"view":"overview"}` |
| Trace ZCHF transfers for an address on a selected chain | `get_analytics` with `type=wallet_flows`, `wallet`, `days` and optional counterparty `limit` and `chainId` |
| Review supply, reserves, savings and challenges | `protocol_briefing` prompt |
| Inspect holders, concentration, counterparty graphs, wallet history and multichain balances | `get_token_ledger` |
| Explain a transaction or find large transfers, repayments and share activity in a time window | `get_protocol_activity` |
| Read borrower lifecycle, amplifier positions, referrals, revenue, collateral exposure or bridge lanes | `get_protocol_report` |
| Discover pools and compare size-specific DEX routes and CEX book fills | `get_dex_pools` and `get_liquidity` |
| Check closed CHF market candles against a peg threshold | `get_peg_history` |
| Model collateral price declines and aggregate coverage | `stress_collateral` |
| Preview deposit/redemption, account maximum and primary/secondary funding scenarios | `preview_fcs` |
| Read total and address-level FCS voting data at a canonical Ethereum block | `get_fcs_votes` |
| Discover outbound ZCHF CCIP transfers and reconcile both legs | `get_bridge_message` |
| Compare a collateral report with live exposure | `collateral_review` prompt |
| Browse the tool guide | `resources/read` with `frankencoin://docs/guide` |
| Discover permitted GraphQL root fields | `resources/read` with `frankencoin://indexer/entities` |
| Find knowledge topics and website pages | `get_knowledge` with `{"topic":"index"}` |

The static discovery catalogue advertises a five-minute cache lifetime. Live tool calls retain
their individual provider timestamps and cache policies. For example, a report's publication date
and a position's observation time describe different points in time.

Local HTTP starts on loopback. Set `HOST=0.0.0.0` for a container that needs an external bind.
Railway sets this automatically through environment detection. Use `PUBLIC_URL` for the public
origin and `MCP_ORIGIN_HOSTS` for additional trusted browser client hostnames.

## Quick start

### MCP (Claude Desktop / Cursor)

```json
{
  "mcpServers": {
    "frankencoin": {
      "url": "https://mcp.frankencoin.com/mcp"
    }
  }
}
```

Then ask your assistant things like *"What's the current state of the Frankencoin protocol?"* or *"How healthy is the ZCHF peg versus other CHF stablecoins?"*.

### REST (curl / scripts)

```bash
# Full protocol snapshot — the best starting point
curl https://mcp.frankencoin.com/api/get_protocol_snapshot

# Market data + peg health
curl https://mcp.frankencoin.com/api/get_market_data

# FCS wrapper state, mechanics and official links
curl "https://mcp.frankencoin.com/api/get_governance?type=fcs"

# Governance: active minters
curl "https://mcp.frankencoin.com/api/get_governance?type=minters&status=active"

# Positions with full on-chain detail
curl "https://mcp.frankencoin.com/api/get_positions?detail=true&limit=10"

# 30 days of protocol analytics
curl "https://mcp.frankencoin.com/api/get_analytics?type=time_series&days=30"

# Raw read-only GraphQL against the on-chain indexer
curl -X POST https://mcp.frankencoin.com/api/query_ponder \
  -H 'Content-Type: application/json' \
  -d '{"query":"{ analyticDailyLogs(limit:3){ items { date fpsTotalSupply totalEquity } } }"}'
```

Data-contract corrections and migration notes: [v3.2 website and assessments](docs/data-contract-v3.2.md) · [v3.1](docs/data-contract-v3.1.md). Optional-provider health is separate from transport success; `ok:true` does not mean all metrics are available.

Every REST response is a JSON envelope: `{ "ok": true, "tool": "<name>", "result": { … } }`.

### CLI

```bash
npx frankencoin-mcp snapshot
npx frankencoin-mcp market
npx frankencoin-mcp positions --detail --limit 10
npx frankencoin-mcp analytics --type trades --limit 5
npx frankencoin-mcp knowledge --topic governance
npx frankencoin-mcp knowledge --topic website --page association --language de
npx frankencoin-mcp assessments --asset WBTC
npx frankencoin-mcp ponder '{ equityTrades(limit:3){ items { kind trader shares } } }'
```

### Discover everything

`GET /health` and `GET /api` are self-describing manifests, and [`GET /llms.txt`](https://mcp.frankencoin.com/llms.txt) is a compact, always-current guide generated from the live tool registry.

---

## Tools

Organised by **what the agent needs**, not where the data comes from — one tool per responsibility, each aggregating from multiple sources internally.

| Tool | Description |
|------|-------------|
| `get_protocol_snapshot` | Full live state — supply (per chain), TVL, FCS state separately from underlying FPS price/reserve/earnings, savings rate, active challenges |
| `get_market_data` | Prices, peg health, CHF-stablecoin comparison (ZCHF/VCHF/CHFAU), macro (BTC/ETH), collateral prices |
| `get_savings` | Approved + pending rates, plus per-module stats (TVL, interest paid, deposits, withdrawals) |
| `get_governance` | FCS context + API-reported supply/binding/reference prices (`type=fcs`); indexed rates/minters, underlying FPS trades and FPS/ZCHF holder stats |
| `get_positions` | Minting positions; `detail=true` for full on-chain data, else a lightweight address list |
| `get_challenges` | Liquidation challenges with collateral details, pricing, and position context |
| `get_collaterals` | Accepted collateral types across all chains |
| `get_collateral_assessments` | Full collateral research, structured risk scores and proposed parameters, drafts/published/deprecated reports, risk framework, schema and template |
| `get_analytics` | Historical time-series, FPS trades, minter history, rate-change timeline (`type` selector) |
| `get_knowledge` | Docs & reference: FCS mechanics (`fcs`), migration (`fcs_migration`), FAQ, guides, exact token addresses and links, and complete redesigned website content (`topic=website`, `page`, `language=en|de`) |
| `get_compliance` | Legal & regulatory posture — Swiss FINMA + EU MiCA classifications, legal opinions, MiCA white paper, ESMA register, security audits, bug bounty |
| `get_news` | Press articles, videos, use cases, ecosystem partners |
| `get_insurance_products` | ZCHF-related third-party insurance products such as OpenCover ZCHF depeg cover |
| `get_merch` | Merch store products, prices, availability |
| `get_risk` | Independent third-party risk ratings — Pharos stablecoin-safety report card + Xerberus composite scores (`source` selector) |
| `get_dune_stats` | Published Dune results with explicitly scoped indexer alternatives; inspect `sources` and `duneStatus` |
| `query_ponder` | Raw **read-only** GraphQL escape hatch against `ponder.frankencoin.com` |

Parameter details live in each tool's MCP `inputSchema` (via `tools/list`) and in `GET /api`.

---

## Website content and collateral research (v3.2)

Website data now follows [`frankencoin-site-redesign/main`](https://github.com/Frankencoin-ZCHF/frankencoin-site-redesign), including the redesigned compliance, security, press and insurance schemas. Existing technical documentation topics still use GitBook.

```bash
# Discover website pages, then read one complete page in either language
curl 'https://mcp.frankencoin.com/api/get_knowledge?topic=website'
curl 'https://mcp.frankencoin.com/api/get_knowledge?topic=website&page=association&language=de'

# Browse compact pages of collateral reports, including their publication status
curl 'https://mcp.frankencoin.com/api/get_collateral_assessments'
curl 'https://mcp.frankencoin.com/api/get_collateral_assessments?offset=10'
curl 'https://mcp.frankencoin.com/api/get_collateral_assessments?view=full&limit=50'
curl 'https://mcp.frankencoin.com/api/get_collateral_assessments?asset=WBTC'
curl 'https://mcp.frankencoin.com/api/get_collateral_assessments?publication=draft&includeContent=true'
curl 'https://mcp.frankencoin.com/api/get_collateral_assessments?document=framework'
```

Assessments are discovered from [`frankencoin-collateral-assessments/main`](https://github.com/Frankencoin-ZCHF/frankencoin-collateral-assessments). New reports appear after the GitHub cache refreshes (6-hour TTL plus 6-hour stale-while-revalidate). Defaults return 10 summaries with author/date/proposed parameters and `pageInfo`. Follow `nextOffset` until null; `limit` is capped at 50. `view=full` returns all JSON metadata on that page, while `asset=WBTC` or `includeContent=true` adds unabridged text. Full source text and all JSON metadata remain accessible; proposed parameters and research publication status do not imply live collateral approval. Supporting documents include `overview`, `framework`, `schema`, `template`, `validator` and `workflow`.

Website copy can contain dated figures and runtime placeholders; use protocol tools for live metrics. Missing content has explicit availability status. German content falls back to English where needed, with missing language sources reported.

## FCS and underlying FPS

FCS is the canonical holder-facing governance and share token on Ethereum:
`0xdb861830d9ae2d1fcf99fa0cfd3973de382b0b5b`. Each FCS wraps one FPS; the 1:1
ratio does not apply to investing ZCHF. FPS remains the underlying Equity token,
with distinct supply, voting records and economic metrics.

Use `get_governance?type=fcs` for API-reported wrapper state with source and
availability notes, or `get_knowledge?topic=fcs` / `topic=fcs_migration` for
technical docs. `get_protocol_snapshot` defaults to compact FCS identity/state (`includeContext=true` includes the full reference)
without renaming its existing FPS metrics. Votes, backing balance and eligibility
not exposed by the source are explicitly unavailable, not inferred from supply.

- [FCS mechanics](https://docs.frankencoin.com/pool-shares/fcs) · [Migration](https://docs.frankencoin.com/pool-shares/fcs-migration) · [Governance](https://docs.frankencoin.com/governance)
- [CoW Swap route](https://swap.cow.fi/#/1/swap/USDT/FCS) · [Legacy FPS page](https://frankencoin.com/fps)
- [Canonical FCS website](https://frankencoin.com/fcs).

[Source provenance, units, fallback behaviour and limitations](docs/FCS.md) document
the released canonical website and the primary technical sources.

## Data sources

All aggregated server-side — callers never talk to these directly:

| Source | Provides | Key |
|--------|----------|-----|
| [api.frankencoin.com](https://api.frankencoin.com) | Supply, TVL, FPS economics, FCS `/fcs/info` state, savings rates, collaterals, challenges, prices | — |
| [ponder.frankencoin.com](https://ponder.frankencoin.com) | On-chain indexed data — positions, trades, minters, analytics | — |
| [CoinGecko](https://coingecko.com) | Market prices, 24h changes, CHF-stablecoin comparison | optional |
| [Dune Analytics](https://dune.com/frankencoin) | Holder counts, minting volume, savings TVL history | optional |
| [Pharos](https://pharos.watch) | Stablecoin-safety report card for ZCHF (`get_risk`) | optional |
| [Xerberus](https://xerberus.io) | Composite on-chain risk scores (`get_risk`) | optional |
| [GitHub repos](https://github.com/Frankencoin-ZCHF) | Documentation and website content (links, media, token addresses) | — |
| [merch.frankencoin.com](https://merch.frankencoin.com) | Merch products (Shopify) | — |
| Ethereum RPC | CHFAU on-chain supply | — |

When an optional key is absent, the affected tool (`get_market_data`, `get_dune_stats`, `get_risk`) returns **partial data plus a `note`** rather than failing.

---

## Self-hosting

No build step. Node ≥ 20, that's it.

```bash
git clone https://github.com/Frankencoin-ZCHF/frankencoin-mcp.git
cd frankencoin-mcp
npm install

node src/index.js --http     # HTTP mode (default port 3000)
node src/index.js            # stdio mode (for local MCP clients)
npm test                     # run the test suite
```

Health check: `curl http://localhost:3000/health`

### Environment variables

**Nothing is required to boot.** Every variable is optional; missing secrets only degrade the tools that depend on them.

| Variable | Default | Effect |
|----------|---------|--------|
| `PORT` | `3000` | HTTP port |
| `COINGECKO_API_KEY` | — | Enables full market/macro data (else those fields degrade) |
| `DUNE_API_KEY` | — | Enables `get_dune_stats` (else it returns a soft note) |
| `PHAROS_API_KEY` | — | Enables detailed Pharos v9 report cards; the public overall-grade fallback works without a key |
| `XERBERUS_API_KEY` | — | Enables the Xerberus section of `get_risk` (else it returns a soft note) |
| `XERBERUS_USER_EMAIL` | — | Sent with `XERBERUS_API_KEY` (Xerberus requires an identifying email header) |
| `PUBLIC_URL` | `https://mcp.frankencoin.com` | Canonical origin used in `/llms.txt` and `/api` |
| `RATE_LIMIT_MAX` | `120` | Requests per IP per minute |
| `TRUST_PROXY_HOPS` | `1` | Trusted proxy hops for client-IP derivation |

See [`src/config.js`](src/config.js) for the full list (cache, timeouts, session and query_ponder limits).

---

## Architecture

Node.js ESM, no build step, no database — stateless between restarts and safe to restart anytime. Strictly layered, with **one** place that performs network I/O:

```
src/
  index.js            entrypoint — stdio vs --http, signals
  config.js           env read once, frozen; nothing required to boot
  cli.js              terminal client
  cache.js            in-memory TTL cache: single-flight + LRU bound
  lib/                pure utilities (number encoding, envelopes, errors, concurrency)
  upstream/           the ONLY layer that calls fetch() — one client per source
  services/           per-domain logic: compose upstreams, transform, shape output
  tools/              registry (zod-validated tool defs) + one dispatch path
  server/             http router, MCP registration, sessions, rate limiting, llms.txt
test/                 node:test suites (offline / hermetic)
```

**Why it's fast:** caching sits at the upstream boundary, so a single `/prices/list` fetch is shared across every tool that needs it, and concurrent identical fetches are coalesced (single-flight). Warm responses are ~1–2 ms.

### Adding a tool

1. Add the definition (name, description, zod `input`, `params`, `handler`) to `src/tools/registry.js`.
2. Implement its logic in the relevant `src/services/*.js`, using an `src/upstream/*.js` client for any network call.

That's it — MCP, REST, `/health`, `/api`, and `/llms.txt` all pick it up automatically from the registry.

---

## Security

Public, unauthenticated, read-only — hardened accordingly:

- **`query_ponder`** is AST-validated: read-only only (no mutations/subscriptions), no introspection or batched queries, with depth/field/alias/length and `limit` caps and a result-size cap.
- **Rate limiting** derives the client IP from the trusted proxy hop (never the attacker-controllable left-most `X-Forwarded-For`).
- Request-body caps (413), slowloris timeouts, session caps with idle/absolute expiry, prototype-pollution rejection, and a single error mapper that never leaks stack traces, upstream URLs, secrets, or file paths.
- Security headers and a strict CORS policy on every response.

Threat model and controls: [`docs/rebuild/SECURITY.md`](docs/rebuild/SECURITY.md).

---

## Deployment

Runs on [Railway](https://railway.app) and **auto-deploys from `main`** via nixpacks — no build phase, no dashboard configuration, no required env vars. `railway.toml` sets `startCommand = node src/index.js --http` and health-checks `/health`.

---

## License

MIT — [Frankencoin Association](https://frankencoin.com)


## v3.3 data and freshness contract

No new tools: the same 17-tool REST/MCP catalogue supports lean defaults, source provenance and provider fallbacks. See [the v3.3 contract](docs/data-contract-v3.3.md) for changed defaults, exact metric scopes, freshness fields and deployment checks.

Dune requests now read published results without starting executions. Failed or unverified queries fall back to indexer data with their source and scope stated; Dune health remains visible separately. Pharos uses the v9 model with a public overall-grade fallback. CHFAU supply uses a canonical Ethereum block hash and fixed RPC failover. FCS block evidence becomes available once the companion Frankencoin API change is deployed; older APIs remain supported with unknown measurement freshness.