Skip to main content
Glama
Pariflow Agent MCP

Pariflow Agent MCP

README.md
# Pariflow Agent MCP Server & CLI

[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
[![Node.js >= 20](https://img.shields.io/badge/node-%3E%3D20-brightgreen.svg)](https://nodejs.org/)
<!-- Replace after approval on glama.ai/mcp:
[![Glama MCP](https://glama.ai/mcp/servers/@Aduersarius/pariflow-agent-starter/badge.svg)](https://glama.ai/mcp/servers/@Aduersarius/pariflow-agent-starter)
-->

Self-contained open-source **Model Context Protocol (MCP) stdio server** ([`src/pariflow-agent.mjs`](src/pariflow-agent.mjs)), CLI, and DEMO-first strategy workflows for **Pariflow** (`pariflow.com`).

Built on `@modelcontextprotocol/sdk` and `zod`, the server exposes **19 annotated MCP tools** and **1 prompt** directly from this repository so Claude Code, Codex, Cursor, or any MCP client can inspect prediction markets, screen whale flow, preview orders, inspect 211 perpetual futures (including Pre-IPO SpaceX/Anthropic/OpenAI and 24/7 NVDA/TSLA/Gold/S&P 500), and schedule **30-day server-side DEMO-only strategies** on a free `$10,000` virtual balance.

> **Important Safety Boundaries**
> - **Read-only keys cannot trade.** Start with a read-only key for discovery, account checks, and order previews.
> - **Scheduled strategy automation is strictly `DEMO`-only.** Server-side strategies (`create_strategy` / `start_strategy`) cannot use `LIVE` funds (`DEMO_ONLY_AUTOMATION`).
> - **Drafts never auto-start.** `create_strategy` only saves rules; `start_strategy` requires explicit `confirm: true`.
> - **Direct orders require explicit confirmation + idempotency key.** `place_trade` and `place_perp_order` reject execution without `confirm: true` and a fresh `idempotencyKey` (`CONFIRM_REQUIRED`).
> - **Not affiliated with Paraflow.** Pariflow (`pariflow.com`) is a prediction market and perpetual futures trading platform; it is unrelated to the Paraflow AI design tool.

---

## Requirements

- **OS:** macOS or Linux
- **Runtime:** Node.js 20+ and `npm`
- **Account:** Free Pariflow account with `$10,000` virtual demo balance (`https://pariflow.com/trading-demo` — email or Google sign-up, no card or deposit required)

---

## Quick Setup (Run Directly From Source or Docker)

### Option A — Clone and Run Locally (Node.js 20+)

```bash
git clone https://github.com/Aduersarius/pariflow-agent-starter.git
cd pariflow-agent-starter
npm install

# Verify the local MCP stdio server handshake (registers all 19 tools)
npm run test:smoke

# Configure a scoped API key from https://pariflow.com -> Settings -> Agent access
export PARIFLOW_API_KEY=YOUR_AGENT_KEY
export PARIFLOW_BASE_URL=https://pariflow.com

# Start the stdio MCP server directly from this repository
npm start
```

### Option B — Run via Docker (Built From This Repository)

```bash
docker build -t pariflow-agent-mcp .
docker run -i --rm -e PARIFLOW_API_KEY=YOUR_AGENT_KEY pariflow-agent-mcp
```

### Configure MCP Clients

**Claude Code (`claude mcp add`)**
```bash
claude mcp add pariflow -- node /absolute/path/to/pariflow-agent-starter/src/pariflow-agent.mjs mcp
```

**Cursor (`.cursor/mcp.json`) / Claude Desktop / Generic MCP Clients**
```json
{
  "mcpServers": {
    "pariflow": {
      "command": "node",
      "args": ["/absolute/path/to/pariflow-agent-starter/src/pariflow-agent.mjs", "mcp"],
      "env": {
        "PARIFLOW_API_KEY": "YOUR_AGENT_KEY",
        "PARIFLOW_BASE_URL": "https://pariflow.com"
      }
    }
  }
}
```

**Codex (`~/.codex/config.toml`)**
```toml
[mcp_servers.pariflow]
command = "node"
args = ["/absolute/path/to/pariflow-agent-starter/src/pariflow-agent.mjs", "mcp"]
```

*(You can also save credentials locally via `PARIFLOW_API_KEY=YOUR_AGENT_KEY node src/pariflow-agent.mjs configure`, which writes `~/.pariflow/agent.json` with `0600` owner-only permissions.)*

Verify the server responds by asking your agent to call `get_started` and `get_account_summary`.

---

## Reproducing the 30-Day Whale-Tape Replay Workflow

This repo implements the exact rule set tested in Pariflow Research's 30-day paper replay ([methodology & full trade log](https://pariflow.com/blog/ai-trading-strategy-30-days), May 29 – June 27, 2026):

| Filter Stage | Alerts Cut | Remaining |
|---|---:|---:|
| Raw 30-day Polymarket whale-alert window | — | **26,885** |
| Buy side only | −6,561 | 20,324 |
| Trade size ≥ $70,000 | −17,817 | 2,507 |
| Maps cleanly to 1 exact outcome | −1,144 | 1,363 |
| Resolves within 7 days | −681 | 682 |
| No earlier opposite ≥$70k whale in same event | −346 | 336 |
| Fits bankroll/daily/exposure risk caps | −276 | **60 copied trades** |

**Recorded Replay Metrics & Honest Caveats (Paper Only — No Live Funds):**
- **Paper result:** `$5,000` start → `$8,954.09` (`+79.1%`), peaking at `$10,284` on June 24; 48 wins / 12 losses (80% win rate); `$22,449` total staked across 37 events (all 60 resolved within 22h; 42/60 within 3h).
- **Day-1 Drawdown:** The first 3 copied trades all lost (Thunder vs. Spurs `$500` @ 42¢, SK Brann twice `$270` @ 57¢ and `$230` @ 58¢), dropping the paper account **−20% to `$4,000`** before its first win.
- **High-Price Tail Risk (≥90¢):** 11 copies entered at 90¢+ won 10 times (`+$87`) and lost once (Spain @ 92¢, `−$479`) for **−$392 net**.
- **Duplicate Event Concentration:** 18 of 37 events were copied more than once; **half of all 12 losses** came from double-copied events (SK Brann, Turkiye, Korea Republic).
- **Slippage Assumption:** The replay assumed flat `1¢` slippage rather than full live orderbook depth impact.

Because of those findings, `scripts/run-demo-strategy.mjs` adds two client-side pre-flight guardrails when reviewing live candidates: flagging entries **`>= 0.90`** and flagging **duplicate events** before you confirm anything.

### Run the Starter Script (Safe Read-Only Dry Run First)

```bash
# Step 1: Read-only shortlist (zero orders, zero strategy writes)
node scripts/run-demo-strategy.mjs --mode scan

# Step 2: Create a DEMO strategy DRAFT (does NOT start or place orders)
node scripts/run-demo-strategy.mjs --mode draft --config configs/whale-replay-demo.json

# Step 3: Explicitly activate the DEMO strategy after inspecting the draft ID
node scripts/run-demo-strategy.mjs --mode start --strategy-id <STRATEGY_ID>

# Step 4: Check latest scheduled run, accepted/skipped counts, and next scan time
node scripts/run-demo-strategy.mjs --mode status --strategy-id <STRATEGY_ID>

# Step 5: Pause without deleting run history
node scripts/run-demo-strategy.mjs --mode pause --strategy-id <STRATEGY_ID> --reason "Completed demo test"
```

### Bonus: Inspect Pre-IPO & 24/7 TradFi Perpetuals via CLI

```bash
# Read-only scan of SpaceX (SPCX), Anthropic (ANT / IO-ANTH), OpenAI (IO-OAI), NVDA, GOLD, SP500
node scripts/inspect-preipo-perps.mjs
```

---

## Complete MCP Tool Surface (19 Tools + 1 Prompt)

Implemented in [`src/pariflow-agent.mjs`](src/pariflow-agent.mjs) and verified locally by `npm run test:smoke` (`scripts/smoke-mcp.mjs`). Every tool carries standard MCP `readOnlyHint` / `destructiveHint` / `idempotentHint` annotations.

| Category | MCP Tool | Permission | Purpose |
|---|---|---|---|
| Onboarding | `get_started` | local read | Returns safe flow, starter prompts, and response rules |
| Account | `get_account_summary` | `read` | Balances (`DEMO`/`LIVE`), active mode, and account risk limits |
| Discovery | `get_top_trades` | `read` | Largest mapped trades (`date`, `limit`, `source`, `accountType`, `minAmount`) |
| Discovery | `search_markets` | `read` | Search prediction events and perps (`q`, `type: ALL\|PREDICTION\|PERP`, `limit`) |
| Discovery | `resolve_market` | `read` | Resolve external title/whale print to exact Pariflow event/outcome IDs |
| Discovery | `prepare_trade_target` | `trade` | Map a missing outcome for a trusted high-confidence signal (never executes) |
| Predictions | `preview_trade` | `read` | Estimated fill price (`LIVE` returns short-lived `quoteId` + `quoteExpiresAt`) |
| Predictions | `place_trade` | `trade` | Execute `DEMO` or `LIVE` order (requires `confirm: true` + `idempotencyKey`) |
| Predictions | `list_orders` | `read` | Inspect recent orders (`status`, `eventId`, `accountType`, `limit`, `offset`) |
| Perps | `list_perps` | `read` | List 211 perp instruments with live mark prices, hourly funding, max leverage |
| Perps | `get_perp_market` | `read` | Live market bounds, fees, and funding for one perp symbol (e.g., `SPCX`, `BTC`) |
| Perps | `preview_perp_order` | `read` | Preview fill price, required isolated margin, est. liquidation price, fee |
| Perps | `place_perp_order` | `trade` | Execute `DEMO`/`LIVE` perp order (`confirm: true`, `idempotencyKey`, `reduceOnly`) |
| Perps | `list_perp_positions` | `read` | List open perp positions (`entry`, `mark`, `leverage`, unrealized P&L) |
| Strategies | `create_strategy` | `trade` | Save a persistent **DEMO-only** strategy draft (`DRAFT` state) |
| Strategies | `start_strategy` | `trade` | Activate draft (`confirm: true`, `runNow` default `true`); runs server-side |
| Strategies | `pause_strategy` | `trade` | Stop future scans while keeping run history |
| Strategies | `get_strategy_status` | `read` | Inspect lifecycle state, latest run totals, end date, and next scan |
| Strategies | `list_strategies` | `read` | List saved strategies filtered by `DRAFT\|ACTIVE\|PAUSED\|COMPLETED` |

> **CLI Safety Defaults:** `preview-trade`, `trade`, `preview-perp`, and `trade-perp` all default `accountMode` to `DEMO` unless `--account-mode LIVE` is passed explicitly. Both `--confirm` and `--confirm=true` are accepted on `start-strategy`.

---

## Documentation & Links

- Full Agent MCP & CLI docs: https://docs.pariflow.com/developers/agent-mcp-cli
- 30-Day Whale Replay Methodology: https://pariflow.com/blog/ai-trading-strategy-30-days
- Free `$10K` Demo Account: https://pariflow.com/trading-demo
- License: [MIT](LICENSE) — Educational and research tooling only; not financial or trading advice.

TDQS

B3.2/5.0

Scored across 19 tools

Disambiguation4/5

Most tools target a distinct resource+action: market discovery (search_markets), resolution (resolve_market), execution (place_trade), and perp/strategy operations are clearly separated by descriptions. The one soft spot is the trade-targeting chain — resolve_market, prepare_trade_target, and preview_trade overlap in intent, since prepare_trade_target both creates outcomes and returns a preview_trade target, which can make an agent pause over which entry point to use.

Naming Consistency4/5

Consistent snake_case verb_noun pattern throughout (get_, list_, search_, preview_, place_, create_, start_, pause_). Minor deviations: the noun for the same domain shifts between 'trade' and 'order' (place_trade vs list_orders), and perps are referred to variably as list_perps, get_perp_market, preview_perp_order, list_perp_positions.

Tool Count4/5

19 tools spread across three coherent sub-surfaces (prediction-market trades, perpetual futures, DEMO strategies) with roughly parallel tool sets in each, so most tools earn their place. It is on the heavy side of the ideal range, and the strategy suite plus the trade-targeting trio add some bulk.

Completeness3/5

Core flows (discover → resolve → preview → place, plus perp data/positions and strategy lifecycle) are covered, but there are notable gaps: no cancel-order tool, no single prediction-market detail lookup analogous to get_perp_market, and the strategy suite has create/start/pause/status/list but no update or delete/stop-with-cleanup.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues