feraterra-mcp
Officialby FeraTerra
README.md
# feraterra-mcp
Zero-dependency **Node.js `>=20` Model Context Protocol (MCP) `stdio` server** and **ESM / TypeScript SDK** for [**FeraTerra**](https://feraterra.app) — sovereign central limit order book (CLOB) perpetuals, spot, basis spreads, stateless order simulation, and cryptographic `Keccak-256` + `secp256k1` solvency verification on Base (`https://testnet.feraterra.app`).
- **Zero npm dependencies:** Built strictly on Node.js `>=20` built-ins (`fetch`, `node:crypto`, `node:http`, `node:stream`) — `0` runtime dependencies and `0` install scripts for instant, supply-chain-clean `npx -y github:FeraTerra/feraterra-mcp` execution.
- **Full MCP `2025-11-25` & `2025-06-18` `stdio` server:** Supports protocol negotiation (`2025-11-25`, `2025-06-18`, `2025-03-26`, `2024-11-05`), `ToolAnnotations`, structured tool outputs, resources, prompts, `--read-only` guardrails, and automatic credential scrubbing.
- **Stateless pre-trade safety (`account_id: 0`):** Simulate fills, fees, and Eigen-SPAN portfolio margin impact via `POST /order/preview` with zero state mutation.
- **Client-side cryptographic solvency audit:** Pure-BigInt `Keccak-256` and `secp256k1` signature recovery (`ecrecover`) verifying `ARENA_LEDGER_TIP_V2_1` WAL state roots without external elliptic-curve packages.
---
## Quick Start (`npx` — Zero Install)
Verify your local Node.js `>=20` runtime and run the built-in loopback HTTP + MCP `stdio` self-test directly from GitHub:
```bash
npx -y github:FeraTerra/feraterra-mcp --self-test
```
Or install as an ESM / TypeScript SDK in any Node.js project:
```bash
npm install github:FeraTerra/feraterra-mcp
```
---
## MCP Client Configurations (`npx -y github:FeraTerra/feraterra-mcp`)
For read-only market discovery, order book analysis, stateless `previewOrder` (`account_id: 0`), and cryptographic solvency audits, **no API keys are required**. Add `FERATERRA_ACCOUNT_ID`, `FERATERRA_API_KEY`, and `FERATERRA_API_SECRET` only when enabling authenticated account inspection and order execution.
### 1. Claude Desktop (`claude_desktop_config.json`)
- **macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`
- **Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
```json
{
"mcpServers": {
"feraterra": {
"command": "npx",
"args": ["-y", "github:FeraTerra/feraterra-mcp"],
"env": {
"FERATERRA_API_URL": "https://testnet.feraterra.app"
}
}
}
}
```
### 2. Cursor (`.cursor/mcp.json`)
```json
{
"mcpServers": {
"feraterra": {
"command": "npx",
"args": ["-y", "github:FeraTerra/feraterra-mcp"],
"env": {
"FERATERRA_API_URL": "https://testnet.feraterra.app"
}
}
}
}
```
### 3. Windsurf (`~/.codeium/windsurf/mcp_config.json`)
```json
{
"mcpServers": {
"feraterra": {
"command": "npx",
"args": ["-y", "github:FeraTerra/feraterra-mcp"],
"env": {
"FERATERRA_API_URL": "https://testnet.feraterra.app"
}
}
}
}
```
### 4. Cline (`cline_mcp_settings.json`)
```json
{
"mcpServers": {
"feraterra": {
"command": "npx",
"args": ["-y", "github:FeraTerra/feraterra-mcp"],
"disabled": false,
"autoApprove": [
"feraterra_list_markets",
"feraterra_get_orderbook",
"feraterra_get_trades",
"feraterra_get_candles",
"feraterra_get_leaderboard",
"feraterra_verify_ledger_tip",
"feraterra_preview_order",
"feraterra_convert_units"
],
"env": {
"FERATERRA_API_URL": "https://testnet.feraterra.app"
}
}
}
}
```
### 5. Antigravity (`mcp_config.json`)
```json
{
"mcpServers": {
"feraterra": {
"command": "npx",
"args": ["-y", "github:FeraTerra/feraterra-mcp"],
"env": {
"FERATERRA_API_URL": "https://testnet.feraterra.app"
}
}
}
}
```
### 6. Mastra (`@mastra/mcp`)
```ts
import { MCPClient } from "@mastra/mcp";
export const feraterraMcp = new MCPClient({
servers: {
feraterra: {
command: "npx",
args: ["-y", "github:FeraTerra/feraterra-mcp"],
env: {
FERATERRA_API_URL: "https://testnet.feraterra.app",
},
},
},
});
```
### Hosted Streamable HTTP Alternative (Zero Local Process)
Any MCP host supporting Streamable HTTP can also connect directly to the public FeraTerra MCP gateway:
```json
{
"mcpServers": {
"feraterra-remote": {
"type": "streamable-http",
"url": "https://mcp.feraterra.app/mcp"
}
}
}
```
---
## Exposed MCP Tools (13)
| Tool | Endpoint / Mode | Auth | Description |
| :--- | :--- | :--- | :--- |
| `feraterra_list_markets` | `GET /markets` | Public | List active perpetual, spot, basis spread, and bounded-claim markets with USD mark prices and BBOs. |
| `feraterra_get_orderbook` | `GET /book` | Public | Fetch live L2/L3 order book depth, USD levels, base sizes, and top-of-book spread. |
| `feraterra_get_trades` | `GET /trades` | Public | Fetch recent CLOB trade executions with USD prices and base quantities. |
| `feraterra_get_candles` | `GET /candles` | Public | Fetch `tick`, `1s`, or `1m` OHLCV candles with formatted USD OHLC and base volume. |
| `feraterra_get_leaderboard` | `GET /leaderboard` | Public | Retrieve ranked traders sorted by `equity`, `pnl`, `streak`, `volume`, or `roi`. |
| `feraterra_verify_ledger_tip` | `GET /ledger/tip` + `GET /health` | Public | Verify `ARENA_LEDGER_TIP_V2_1` `Keccak-256` digest, `secp256k1` operator signature, and conservation invariants. |
| `feraterra_preview_order` | `POST /order/preview` | Public (`account_id: 0`) / HMAC | Stateless zero-mutation pre-trade order simulation returning estimated fills, fees, and margin impact. |
| `feraterra_get_account` | `GET /account` | HMAC `X-Arena-*` | Inspect Eigen-SPAN equity, free/withdrawable USD, IMR/MMR, positions, and open orders. |
| `feraterra_place_order` | `POST /order` | HMAC `X-Arena-*` | Submit limit or market orders (`gtc`, `ioc`, `fok`, `post_only`, `reduce_only`). |
| `feraterra_replace_quote` | `POST /quote` | HMAC `X-Arena-*` | Atomically replace resting two-sided maker bid and ask quotes in 1 WAL step. |
| `feraterra_cancel_order` | `POST /cancel` | HMAC `X-Arena-*` | Cancel a specific resting order by `order_id`. |
| `feraterra_cancel_all_orders` | `POST /cancel_all` | HMAC `X-Arena-*` | Batch-cancel resting orders across all markets or filtered by market, side, or tag. |
| `feraterra_convert_units` | Local Pure Math | Offline | Convert exact fixed-point `ticks` (`$0.01`), `lots` (`0.0001`), and `micro_usd` (`1e-6`). |
---
## Node.js / TypeScript ESM SDK Usage
```ts
import {
FeraTerraClient,
baseToLots,
lotsToBase,
ticksToUsd,
usdToTicks,
verifyLedgerTip,
} from "feraterra-mcp";
// 1. Read-only + stateless preview (zero credentials needed)
const publicClient = new FeraTerraClient({
baseUrl: "https://testnet.feraterra.app",
});
const markets = await publicClient.listMarkets({ activeOnly: true });
const book = await publicClient.getOrderbook({ symbol: "BTC-USD-PERP", depth: 10 });
const trades = await publicClient.getTrades({ symbol: "BTC-USD-PERP", limit: 20 });
const candles = await publicClient.getCandles({ symbol: "BTC-USD-PERP", interval: "1m", limit: 60 });
const leaderboard = await publicClient.getLeaderboard({ limit: 10, sort: "equity" });
const solvency = await publicClient.verifySolvency();
// Stateless dry-run preview with account_id: 0
const preview = await publicClient.previewOrder({
accountId: 0,
symbol: "BTC-USD-PERP",
side: "buy",
price: "70000.00",
amount: "0.1",
postOnly: true,
});
// Fixed-point unit helpers (1 tick = $0.01, 1 lot = 0.0001 base)
const pxTicks = usdToTicks("70000.25"); // 7000025
const pxUsd = ticksToUsd(pxTicks); // "70000.25"
const qtyLots = baseToLots("0.25"); // 2500
const qtyBase = lotsToBase(qtyLots); // "0.2500"
// 2. Authenticated HMAC-SHA256 trading client
const tradingClient = new FeraTerraClient({
baseUrl: process.env.FERATERRA_API_URL ?? "https://testnet.feraterra.app",
accountId: Number(process.env.FERATERRA_ACCOUNT_ID),
apiKey: process.env.FERATERRA_API_KEY,
apiSecret: process.env.FERATERRA_API_SECRET,
});
const account = await tradingClient.getAccount();
const order = await tradingClient.placeOrder({
symbol: "BTC-USD-PERP",
side: "buy",
price: "69950.00",
amount: "0.1",
postOnly: true,
});
await tradingClient.cancelOrder({ symbol: "BTC-USD-PERP", orderId: order.order_id });
```
---
## Environment Variables & CLI Flags
| Variable | CLI Flag | Default | Description |
| :--- | :--- | :--- | :--- |
| `FERATERRA_API_URL` | `--base-url <url>` | `https://testnet.feraterra.app` | FeraTerra HTTPS gateway URL (`ARENA_URL` also accepted). |
| `FERATERRA_ACCOUNT_ID` | `--account-id <id>` | `0` | Default trader account ID (`0` uses stateless preview; `>0` required for `/account` and trading). |
| `FERATERRA_API_KEY` | `--api-key <key>` | *(optional)* | `X-Arena-API-Key` identifier for HMAC-SHA256 authenticated requests. |
| `FERATERRA_API_SECRET` | `--api-secret <secret>` | *(optional)* | HMAC-SHA256 signing secret (automatically redacted from MCP outputs and errors). |
| `FERATERRA_EXPECTED_OPERATOR` | `--expected-operator <0x...>` | *(optional)* | Pinned `0x...` Ethereum operator signer address for `GET /ledger/tip` verification. |
| `FERATERRA_READ_ONLY` | `--read-only` | `false` | Disables mutating tools (`feraterra_place_order`, `feraterra_replace_quote`, `feraterra_cancel_*`). |
| `FERATERRA_TIMEOUT_MS` | `--timeout-ms <ms>` | `10000` | Per-request HTTP timeout in milliseconds. |
---
## Verification & Testing
```bash
node ./bin/feraterra-mcp.mjs --self-test
node --test test/*.test.mjs
```
---
## License
[MIT](./LICENSE) — Copyright (c) 2026 FeraTerra.
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues