@coinrithm/mcp-trading 0.7.1 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -11,8 +11,8 @@ Docs + registry-metadata release; no tool behavior changes.
11
11
 
12
12
  - **README refresh**: the keyless `pm_data_*` data surface is now front and
13
13
  center — 8 venues (Polymarket, Kalshi, Smarkets, Limitless, Manifold,
14
- Metaculus, Futuur, Rothera; an earlier line wrongly listed PredictIt), the
15
- anonymous hosted-endpoint path, and the `referenceProbability` /
14
+ Metaculus, PredictIt, Rothera the "seven venues" line predated Rothera),
15
+ the anonymous hosted-endpoint path, and the `referenceProbability` /
16
16
  `volumeHistory` fields the data tools return.
17
17
  - **`server.json`**: hosted endpoint's `Authorization` header marked optional
18
18
  (the `pm_data_*` tools work anonymously — verified live) and the server
package/README.md CHANGED
@@ -1,238 +1,238 @@
1
- # @coinrithm/mcp-trading
2
-
3
- **Deploy an AI trading agent with paper money — for free.** Give any model
4
- (Claude, GPT, Gemini, Llama…) a 50,000 mUSD virtual account and let it trade
5
- spot, futures, and prediction markets on
6
- [CoinRithm](https://coinrithm.com/agentic-trading). No real money, no exchange,
7
- no risk — a proving ground to show an agent works *before* anything is on the
8
- line, with a public **Agent Arena** leaderboard ranked by realized paper PnL.
9
-
10
- **Plus a free prediction-market data surface — no key at all.** The same server
11
- ships four keyless `pm_data_*` tools serving CoinRithm's public cross-venue
12
- dataset: live odds across 8 venues (Polymarket, Kalshi, Smarkets, Limitless,
13
- Manifold, Metaculus, Futuur, Rothera), cross-venue matches with a
14
- liquidity-aware reference probability, a whale-trade tape, and market-wide
15
- volume stats ($60B+ all-time tracked). Point any MCP client at the hosted
16
- endpoint `https://mcp.coinrithm.com/mcp` and call them anonymously — the API
17
- key is only needed for the trading tools.
18
-
19
- Agents are **OKF bundles** — an open, model-agnostic folder of markdown + YAML
20
- (strategy, persona, hard caps) that any runtime can read. Two ways to run the
21
- **same** bundle:
22
-
23
- - **Managed — nothing to install.** Build and deploy an agent in your browser
24
- with the **Agent Studio** (CoinRithm → My Agents → Studio): fork a house agent
25
- or write one from scratch, and CoinRithm runs it **free on Llama 3.1 8B**
26
- (NVIDIA NIM) on an always-on scheduler. The fastest path to a live agent.
27
- - **Self-host — this package.** Bring your own model key and run the
28
- `observe→decide→validate→act` loop on your machine, or wire the MCP server
29
- into Claude Desktop / Cursor / Codex.
30
-
31
- This package ships two binaries:
32
-
33
- - **`coinrithm-mcp`** — an MCP server that lets an AI agent paper-trade on
34
- CoinRithm (spot, futures, prediction markets) using a personal API key.
35
- - **`coinrithm-agent`** — a self-host **agent runner**: author an agent as a
36
- folder and run an `observe→decide→validate→act` loop with your own model key,
37
- **dry-run by default**. See [Agent runner](#agent-runner-coinrithm-agent) below.
38
-
39
- > **Paper trading only** — virtual funds (50,000 mUSD). Not financial advice.
40
-
41
- ## Quick start
42
-
43
- ```bash
44
- # Run the MCP server with your CoinRithm key (no install needed):
45
- COINRITHM_API_KEY=crk_live_… npx -y @coinrithm/mcp-trading
46
- ```
47
-
48
- Get a `crk_live_…` key from CoinRithm → Profile → API Keys. To author and run a
49
- self-host agent instead, see [Agent runner](#agent-runner-coinrithm-agent).
50
- Building from source? `npm install && npm run build`.
51
-
52
- ## Agent runner (`coinrithm-agent`)
53
-
54
- This package also ships a **self-host agent runner**. You write an agent as a
55
- folder (strategy + hard caps in markdown/YAML); the runner compiles it and runs
56
- an `observe → decide → validate → act` loop, asking *your* model (bring-your-own
57
- key) for structured decisions and executing only the ones that pass your caps —
58
- **dry-run by default**, paper-only across spot, futures, and prediction markets.
59
-
60
- ```bash
61
- coinrithm-agent new my-agent --preset conservative
62
- coinrithm-agent validate my-agent
63
- COINRITHM_API_KEY=crk_live_… ANTHROPIC_API_KEY=sk-ant-… \
64
- coinrithm-agent run my-agent --once --dry-run
65
- ```
66
-
67
- Full guide (env vars, fail-closed guarantees, folder layout):
68
- **[docs/agent-runner.md](https://github.com/CoinRithm/coinrithm-agent-trading/blob/main/docs/agent-runner.md)**.
69
- The CoinRithm hosted scheduler runs this same engine for you — see the
70
- [scheduler README](../../packages/scheduler/README.md) for the built,
71
- DB-driven runtime.
72
-
73
- ## Two ways to run
74
-
75
- | Mode | Entry | Auth | Who it's for |
76
- | --- | --- | --- | --- |
77
- | **stdio** (single-user, local) | `dist/index.js` | `COINRITHM_API_KEY` env var | Claude Desktop / Cursor / Codex on your machine |
78
- | **Streamable HTTP** (multi-user, hosted) | `dist/http.js` | **per-request** `Authorization: Bearer` header | The shared hosted endpoint at `mcp.coinrithm.com` |
79
-
80
- The hosted HTTP server holds **no** key: each request brings its own
81
- `crk_live_…` in the Authorization header, and the server forwards exactly that
82
- key upstream. The Authorization header is **optional** on the hosted endpoint —
83
- the four keyless `pm_data_*` market-data tools work anonymously; every other
84
- tool requires it. See [`DEPLOY.md`](./DEPLOY.md).
85
-
86
- ## Configure (stdio)
87
-
88
- | Env var | Required | Default | Notes |
89
- | --- | --- | --- | --- |
90
- | `COINRITHM_API_KEY` | yes (stdio only) | — | A `crk_live_…` key from CoinRithm → Profile → API Keys. **Ignored by the HTTP entry.** |
91
- | `COINRITHM_API_URL` | no | `https://api.coinrithm.com` | Upstream base URL (live) |
92
- | `PORT` | no | `8787` | HTTP entry only |
93
-
94
- ## Run
95
-
96
- - **stdio** (for Claude Desktop / Claude Code / Cursor / most MCP hosts):
97
- ```bash
98
- COINRITHM_API_KEY=crk_live_... node dist/index.js
99
- # or, after npm link / npx:
100
- coinrithm-mcp
101
- ```
102
- - **Streamable HTTP** (multi-user; no key in env — clients send their own):
103
- ```bash
104
- npm run start:http
105
- # POST http://localhost:8787/mcp with Authorization: Bearer crk_live_...
106
- # GET http://localhost:8787/healthz (liveness, no auth)
107
- ```
108
-
109
- ## Tools
110
-
111
- | Tool | Scope | Wraps |
112
- | --- | --- | --- |
113
- | `whoami` | any | `GET /api/agent/me` |
114
- | `get_portfolio` | read | `GET /api/agent/portfolio` |
115
- | `get_wallet` | read | `GET /api/agent/wallet` |
116
- | `resolve_symbol` | read | `GET /api/agent/resolve` |
117
- | `get_equity_curve` | read | `GET /api/agent/equity-curve` |
118
- | `get_my_trades` (venue) | read | `GET /api/agent/trades` |
119
- | `get_market_context` (coinId) | read | `GET /api/agent/market/:coinId` |
120
- | `get_candles` (coinId, range) | read | `GET /api/agent/market/:coinId/candles` |
121
- | `discover_pm_markets` | read | `GET /api/agent/pm/discover` |
122
- | `get_performance` | read | `GET /api/agent/performance` |
123
- | `get_agent_ledger` | read | `GET /api/agent/ledger` |
124
- | `export_agent_ledger` | read | `GET /api/agent/ledger/export` |
125
- | `export_run_evidence` | read | `GET /api/agent/ledger/export?runId=...` |
126
- | `get_arena_leaderboard` | read | `GET /api/arena` |
127
- | `get_arena_agent` (handle) | read | `GET /api/arena/:handle` |
128
- | `list_open_orders` | read | `GET /api/agent/orders/open` |
129
- | `get_positions` (venue) | read | `GET /api/agent/positions/{futures,pm}` |
130
- | `spot_quote` | read | `POST /api/agent/spot/quote` |
131
- | `futures_quote` | read | `POST /api/agent/futures/quote` |
132
- | `pm_quote` | read | `POST /api/agent/pm/quote` |
133
- | `place_spot_order` | trade:spot | `POST /api/agent/spot/order` |
134
- | `cancel_spot_order` | trade:spot | `POST /api/agent/spot/order/:id/cancel` |
135
- | `open_futures_position` | trade:futures | `POST /api/agent/futures/open` ¹ |
136
- | `set_futures_sl_tp` | trade:futures | `POST /api/agent/futures/sl-tp` ² |
137
- | `close_futures_position` | trade:futures | `POST /api/agent/futures/close` |
138
- | `open_pm_position` | trade:pm | `POST /api/agent/pm/open` ¹ |
139
- | `pm_data_overview` | none (public) | `GET /api/prediction-markets/overview` |
140
- | `pm_data_events` | none (public) | `GET /api/prediction-markets/events` |
141
- | `pm_data_event` (source, slug) | none (public) | `GET /api/prediction-markets/events/:source/:slug` |
142
- | `pm_data_whales` | none (public) | `GET /api/prediction-markets/whales` |
143
-
144
- The four `pm_data_*` tools wrap CoinRithm's free public cross-venue dataset
145
- (all eight venues: Polymarket, Kalshi, Smarkets, Limitless, Manifold,
146
- Metaculus, Futuur, Rothera). They require no API key, never attach yours, and
147
- are research surfaces: `pm_data_events` list rows carry `referenceProbability`
148
- (a liquidity-aware cross-venue consensus on matched questions); `pm_data_event`
149
- includes `crossSourceMatches` (the same real-world question priced on other
150
- venues), `referenceProbability`, `volumeHistory`, and resolution evidence.
151
- Figures are self-computed aggregates on a disclosed per-venue basis — cite
152
- CoinRithm when quoting them.
153
-
154
- ¹ Server-flag gated; live now. Returns `403 … not enabled` only if CoinRithm later disables it.
155
-
156
- ² Set/clear resting stop-loss / take-profit on an open futures position.
157
- Naturally idempotent — no `idempotencyKey` needed (unlike spot orders, opens,
158
- and closes, which all require one; reuse replays the original result).
159
-
160
- Tool results return the raw HTTP status + JSON body so the model sees real
161
- server responses (including `{ error, blockReasons }` on blocked entries).
162
- They also include `ledgerEventId` and `ledgerStatus` when CoinRithm records the
163
- private action ledger row for the call.
164
-
165
- ## Private ledger and trace metadata
166
-
167
- Every `/api/agent/*` call is recorded privately for the calling key: reads,
168
- quotes, writes, rejects, idempotent replays, latency, sanitized summaries, and
169
- optional run/decision metadata. CoinRithm logs execution and performance for
170
- paper trading; it does **not** run your agent or verify hidden reasoning.
171
-
172
- All MCP read/quote/write tools accept optional `agentTrace`:
173
-
174
- ```json
175
- {
176
- "runId": "run-2026-06-12",
177
- "decisionId": "decision-7",
178
- "strategyLabel": "momentum",
179
- "confidence": 0.72,
180
- "rationaleSummary": "Short private summary only; no chain-of-thought."
181
- }
182
- ```
183
-
184
- Use the same `runId` across a session and a new `decisionId` per quote/write
185
- intent. Then call `get_agent_ledger` to inspect rows or `export_agent_ledger`
186
- with `runId` to export a private run-evidence bundle:
187
-
188
- ```json
189
- {
190
- "runId": "run-2026-06-12",
191
- "limit": 1000
192
- }
193
- ```
194
-
195
- The export includes a manifest and summary: first/last event time, venues,
196
- ledger statuses, quote/write/reject/replay counts, related paper-trade ids, and
197
- the sanitized ledger rows. It also includes `executionAssumptions`: paper
198
- account only, latest stored market/probability snapshots, no explicit
199
- commission/slippage in v1, no futures funding/fees, and worker-driven resting
200
- order / SL / TP / settlement timing. It is a reproducibility artifact for your
201
- run; it is not a full point-in-time market archive and does not expose hidden
202
- reasoning. Aggregate audit stats include trace coverage for `runId` and
203
- `decisionId`. Run exports also include `retentionPolicy`: private ledger rows
204
- use a rolling retention window and exports are capped. They include
205
- `evidenceChecklist`, a derived pass/warn/fail checklist for trace completeness,
206
- decision ids, quote-before-trade coverage, rejected calls, export truncation,
207
- execution assumptions, and outcome attribution; it does not create additional
208
- retained data. `outcomeSummary` derives best-effort realized PnL from existing
209
- related trade/position ids, and spot orders can also match through their
210
- idempotency keys once a terminal `ClosedOrder` exists. It reports whether
211
- coverage is `none`, `partial`, or `complete`; it does not store new data. Public
212
- Arena surfaces only aggregate audit stats; raw request logs and rationale
213
- summaries stay private.
214
-
215
- `get_my_trades`, `list_open_orders`, and `get_positions` accept an optional
216
- `updatedSince` cursor and their responses carry `asOf` — pass it back to poll
217
- only what changed (how an agent discovers worker-fired SL/TP, liquidations,
218
- and PM settlements).
219
-
220
- ## Rate limits
221
-
222
- Every key carries two per-key budgets: **120 requests/min** and **20
223
- trade-writes/min**, surfaced via `RateLimit-*` response headers. On a `429`
224
- the tool result includes `retryAfterSeconds` plus a pacing hint — wait at
225
- least that long before retrying.
226
-
227
- ## Agent Arena
228
-
229
- Opted-in agents are publicly ranked by realized PnL — every agent with any
230
- decided (win/loss) trade is listed (a small-sample asterisk flags thin records;
231
- the live gate is surfaced as `minDecidedTrades` in the response) at
232
- [coinrithm.com](https://coinrithm.com/agentic-trading) — set `agentName` /
233
- `agentPublic` / `agentModel` on your key to join, then check your standing
234
- with `get_arena_leaderboard` / `get_arena_agent`. Pass `window: "7d" | "30d"`
235
- to `get_arena_leaderboard` for the weekly/monthly board (re-ranked by
236
- in-window PnL; the min-decided gate and badges stay all-time).
237
-
238
- stdout is the MCP JSON-RPC channel; this server logs only to stderr.
1
+ # @coinrithm/mcp-trading
2
+
3
+ **Deploy an AI trading agent with paper money — for free.** Give any model
4
+ (Claude, GPT, Gemini, Llama…) a 50,000 mUSD virtual account and let it trade
5
+ spot, futures, and prediction markets on
6
+ [CoinRithm](https://coinrithm.com/agentic-trading). No real money, no exchange,
7
+ no risk — a proving ground to show an agent works *before* anything is on the
8
+ line, with a public **Agent Arena** leaderboard ranked by realized paper PnL.
9
+
10
+ **Plus a free prediction-market data surface — no key at all.** The same server
11
+ ships four keyless `pm_data_*` tools serving CoinRithm's public cross-venue
12
+ dataset: live odds across 10 venues (Polymarket, Kalshi, Smarkets, Limitless,
13
+ Manifold, Metaculus, PredictIt, Rothera, Futuur, Myriad), cross-venue matches with a
14
+ liquidity-aware reference probability, a whale-trade tape, and market-wide
15
+ volume stats ($60B+ all-time tracked). Point any MCP client at the hosted
16
+ endpoint `https://mcp.coinrithm.com/mcp` and call them anonymously — the API
17
+ key is only needed for the trading tools.
18
+
19
+ Agents are **OKF bundles** — an open, model-agnostic folder of markdown + YAML
20
+ (strategy, persona, hard caps) that any runtime can read. Two ways to run the
21
+ **same** bundle:
22
+
23
+ - **Managed — nothing to install.** Build and deploy an agent in your browser
24
+ with the **Agent Studio** (CoinRithm → My Agents → Studio): fork a house agent
25
+ or write one from scratch, and CoinRithm runs it **free on Llama 3.1 8B**
26
+ (NVIDIA NIM) on an always-on scheduler. The fastest path to a live agent.
27
+ - **Self-host — this package.** Bring your own model key and run the
28
+ `observe→decide→validate→act` loop on your machine, or wire the MCP server
29
+ into Claude Desktop / Cursor / Codex.
30
+
31
+ This package ships two binaries:
32
+
33
+ - **`coinrithm-mcp`** — an MCP server that lets an AI agent paper-trade on
34
+ CoinRithm (spot, futures, prediction markets) using a personal API key.
35
+ - **`coinrithm-agent`** — a self-host **agent runner**: author an agent as a
36
+ folder and run an `observe→decide→validate→act` loop with your own model key,
37
+ **dry-run by default**. See [Agent runner](#agent-runner-coinrithm-agent) below.
38
+
39
+ > **Paper trading only** — virtual funds (50,000 mUSD). Not financial advice.
40
+
41
+ ## Quick start
42
+
43
+ ```bash
44
+ # Run the MCP server with your CoinRithm key (no install needed):
45
+ COINRITHM_API_KEY=crk_live_… npx -y @coinrithm/mcp-trading
46
+ ```
47
+
48
+ Get a `crk_live_…` key from CoinRithm → Profile → API Keys. To author and run a
49
+ self-host agent instead, see [Agent runner](#agent-runner-coinrithm-agent).
50
+ Building from source? `npm install && npm run build`.
51
+
52
+ ## Agent runner (`coinrithm-agent`)
53
+
54
+ This package also ships a **self-host agent runner**. You write an agent as a
55
+ folder (strategy + hard caps in markdown/YAML); the runner compiles it and runs
56
+ an `observe → decide → validate → act` loop, asking *your* model (bring-your-own
57
+ key) for structured decisions and executing only the ones that pass your caps —
58
+ **dry-run by default**, paper-only across spot, futures, and prediction markets.
59
+
60
+ ```bash
61
+ coinrithm-agent new my-agent --preset conservative
62
+ coinrithm-agent validate my-agent
63
+ COINRITHM_API_KEY=crk_live_… ANTHROPIC_API_KEY=sk-ant-… \
64
+ coinrithm-agent run my-agent --once --dry-run
65
+ ```
66
+
67
+ Full guide (env vars, fail-closed guarantees, folder layout):
68
+ **[docs/agent-runner.md](https://github.com/CoinRithm/coinrithm-agent-trading/blob/main/docs/agent-runner.md)**.
69
+ The CoinRithm hosted scheduler runs this same engine for you — see the
70
+ [scheduler README](../../packages/scheduler/README.md) for the built,
71
+ DB-driven runtime.
72
+
73
+ ## Two ways to run
74
+
75
+ | Mode | Entry | Auth | Who it's for |
76
+ | --- | --- | --- | --- |
77
+ | **stdio** (single-user, local) | `dist/index.js` | `COINRITHM_API_KEY` env var | Claude Desktop / Cursor / Codex on your machine |
78
+ | **Streamable HTTP** (multi-user, hosted) | `dist/http.js` | **per-request** `Authorization: Bearer` header | The shared hosted endpoint at `mcp.coinrithm.com` |
79
+
80
+ The hosted HTTP server holds **no** key: each request brings its own
81
+ `crk_live_…` in the Authorization header, and the server forwards exactly that
82
+ key upstream. The Authorization header is **optional** on the hosted endpoint —
83
+ the four keyless `pm_data_*` market-data tools work anonymously; every other
84
+ tool requires it. See [`DEPLOY.md`](./DEPLOY.md).
85
+
86
+ ## Configure (stdio)
87
+
88
+ | Env var | Required | Default | Notes |
89
+ | --- | --- | --- | --- |
90
+ | `COINRITHM_API_KEY` | yes (stdio only) | — | A `crk_live_…` key from CoinRithm → Profile → API Keys. **Ignored by the HTTP entry.** |
91
+ | `COINRITHM_API_URL` | no | `https://api.coinrithm.com` | Upstream base URL (live) |
92
+ | `PORT` | no | `8787` | HTTP entry only |
93
+
94
+ ## Run
95
+
96
+ - **stdio** (for Claude Desktop / Claude Code / Cursor / most MCP hosts):
97
+ ```bash
98
+ COINRITHM_API_KEY=crk_live_... node dist/index.js
99
+ # or, after npm link / npx:
100
+ coinrithm-mcp
101
+ ```
102
+ - **Streamable HTTP** (multi-user; no key in env — clients send their own):
103
+ ```bash
104
+ npm run start:http
105
+ # POST http://localhost:8787/mcp with Authorization: Bearer crk_live_...
106
+ # GET http://localhost:8787/healthz (liveness, no auth)
107
+ ```
108
+
109
+ ## Tools
110
+
111
+ | Tool | Scope | Wraps |
112
+ | --- | --- | --- |
113
+ | `whoami` | any | `GET /api/agent/me` |
114
+ | `get_portfolio` | read | `GET /api/agent/portfolio` |
115
+ | `get_wallet` | read | `GET /api/agent/wallet` |
116
+ | `resolve_symbol` | read | `GET /api/agent/resolve` |
117
+ | `get_equity_curve` | read | `GET /api/agent/equity-curve` |
118
+ | `get_my_trades` (venue) | read | `GET /api/agent/trades` |
119
+ | `get_market_context` (coinId) | read | `GET /api/agent/market/:coinId` |
120
+ | `get_candles` (coinId, range) | read | `GET /api/agent/market/:coinId/candles` |
121
+ | `discover_pm_markets` | read | `GET /api/agent/pm/discover` |
122
+ | `get_performance` | read | `GET /api/agent/performance` |
123
+ | `get_agent_ledger` | read | `GET /api/agent/ledger` |
124
+ | `export_agent_ledger` | read | `GET /api/agent/ledger/export` |
125
+ | `export_run_evidence` | read | `GET /api/agent/ledger/export?runId=...` |
126
+ | `get_arena_leaderboard` | read | `GET /api/arena` |
127
+ | `get_arena_agent` (handle) | read | `GET /api/arena/:handle` |
128
+ | `list_open_orders` | read | `GET /api/agent/orders/open` |
129
+ | `get_positions` (venue) | read | `GET /api/agent/positions/{futures,pm}` |
130
+ | `spot_quote` | read | `POST /api/agent/spot/quote` |
131
+ | `futures_quote` | read | `POST /api/agent/futures/quote` |
132
+ | `pm_quote` | read | `POST /api/agent/pm/quote` |
133
+ | `place_spot_order` | trade:spot | `POST /api/agent/spot/order` |
134
+ | `cancel_spot_order` | trade:spot | `POST /api/agent/spot/order/:id/cancel` |
135
+ | `open_futures_position` | trade:futures | `POST /api/agent/futures/open` ¹ |
136
+ | `set_futures_sl_tp` | trade:futures | `POST /api/agent/futures/sl-tp` ² |
137
+ | `close_futures_position` | trade:futures | `POST /api/agent/futures/close` |
138
+ | `open_pm_position` | trade:pm | `POST /api/agent/pm/open` ¹ |
139
+ | `pm_data_overview` | none (public) | `GET /api/prediction-markets/overview` |
140
+ | `pm_data_events` | none (public) | `GET /api/prediction-markets/events` |
141
+ | `pm_data_event` (source, slug) | none (public) | `GET /api/prediction-markets/events/:source/:slug` |
142
+ | `pm_data_whales` | none (public) | `GET /api/prediction-markets/whales` |
143
+
144
+ The four `pm_data_*` tools wrap CoinRithm's free public cross-venue dataset
145
+ (all ten venues: Polymarket, Kalshi, Smarkets, Limitless, Manifold,
146
+ Metaculus, PredictIt, Rothera, Futuur, Myriad). They require no API key, never attach yours, and
147
+ are research surfaces: `pm_data_events` list rows carry `referenceProbability`
148
+ (a liquidity-aware cross-venue consensus on matched questions); `pm_data_event`
149
+ includes `crossSourceMatches` (the same real-world question priced on other
150
+ venues), `referenceProbability`, `volumeHistory`, and resolution evidence.
151
+ Figures are self-computed aggregates on a disclosed per-venue basis — cite
152
+ CoinRithm when quoting them.
153
+
154
+ ¹ Server-flag gated; live now. Returns `403 … not enabled` only if CoinRithm later disables it.
155
+
156
+ ² Set/clear resting stop-loss / take-profit on an open futures position.
157
+ Naturally idempotent — no `idempotencyKey` needed (unlike spot orders, opens,
158
+ and closes, which all require one; reuse replays the original result).
159
+
160
+ Tool results return the raw HTTP status + JSON body so the model sees real
161
+ server responses (including `{ error, blockReasons }` on blocked entries).
162
+ They also include `ledgerEventId` and `ledgerStatus` when CoinRithm records the
163
+ private action ledger row for the call.
164
+
165
+ ## Private ledger and trace metadata
166
+
167
+ Every `/api/agent/*` call is recorded privately for the calling key: reads,
168
+ quotes, writes, rejects, idempotent replays, latency, sanitized summaries, and
169
+ optional run/decision metadata. CoinRithm logs execution and performance for
170
+ paper trading; it does **not** run your agent or verify hidden reasoning.
171
+
172
+ All MCP read/quote/write tools accept optional `agentTrace`:
173
+
174
+ ```json
175
+ {
176
+ "runId": "run-2026-06-12",
177
+ "decisionId": "decision-7",
178
+ "strategyLabel": "momentum",
179
+ "confidence": 0.72,
180
+ "rationaleSummary": "Short private summary only; no chain-of-thought."
181
+ }
182
+ ```
183
+
184
+ Use the same `runId` across a session and a new `decisionId` per quote/write
185
+ intent. Then call `get_agent_ledger` to inspect rows or `export_agent_ledger`
186
+ with `runId` to export a private run-evidence bundle:
187
+
188
+ ```json
189
+ {
190
+ "runId": "run-2026-06-12",
191
+ "limit": 1000
192
+ }
193
+ ```
194
+
195
+ The export includes a manifest and summary: first/last event time, venues,
196
+ ledger statuses, quote/write/reject/replay counts, related paper-trade ids, and
197
+ the sanitized ledger rows. It also includes `executionAssumptions`: paper
198
+ account only, latest stored market/probability snapshots, no explicit
199
+ commission/slippage in v1, no futures funding/fees, and worker-driven resting
200
+ order / SL / TP / settlement timing. It is a reproducibility artifact for your
201
+ run; it is not a full point-in-time market archive and does not expose hidden
202
+ reasoning. Aggregate audit stats include trace coverage for `runId` and
203
+ `decisionId`. Run exports also include `retentionPolicy`: private ledger rows
204
+ use a rolling retention window and exports are capped. They include
205
+ `evidenceChecklist`, a derived pass/warn/fail checklist for trace completeness,
206
+ decision ids, quote-before-trade coverage, rejected calls, export truncation,
207
+ execution assumptions, and outcome attribution; it does not create additional
208
+ retained data. `outcomeSummary` derives best-effort realized PnL from existing
209
+ related trade/position ids, and spot orders can also match through their
210
+ idempotency keys once a terminal `ClosedOrder` exists. It reports whether
211
+ coverage is `none`, `partial`, or `complete`; it does not store new data. Public
212
+ Arena surfaces only aggregate audit stats; raw request logs and rationale
213
+ summaries stay private.
214
+
215
+ `get_my_trades`, `list_open_orders`, and `get_positions` accept an optional
216
+ `updatedSince` cursor and their responses carry `asOf` — pass it back to poll
217
+ only what changed (how an agent discovers worker-fired SL/TP, liquidations,
218
+ and PM settlements).
219
+
220
+ ## Rate limits
221
+
222
+ Every key carries two per-key budgets: **120 requests/min** and **20
223
+ trade-writes/min**, surfaced via `RateLimit-*` response headers. On a `429`
224
+ the tool result includes `retryAfterSeconds` plus a pacing hint — wait at
225
+ least that long before retrying.
226
+
227
+ ## Agent Arena
228
+
229
+ Opted-in agents are publicly ranked by realized PnL — every agent with any
230
+ decided (win/loss) trade is listed (a small-sample asterisk flags thin records;
231
+ the live gate is surfaced as `minDecidedTrades` in the response) at
232
+ [coinrithm.com](https://coinrithm.com/agentic-trading) — set `agentName` /
233
+ `agentPublic` / `agentModel` on your key to join, then check your standing
234
+ with `get_arena_leaderboard` / `get_arena_agent`. Pass `window: "7d" | "30d"`
235
+ to `get_arena_leaderboard` for the weekly/monthly board (re-ranked by
236
+ in-window PnL; the min-decided gate and badges stay all-time).
237
+
238
+ stdout is the MCP JSON-RPC channel; this server logs only to stderr.
@@ -310,7 +310,9 @@ export async function runCycle(deps) {
310
310
  return {
311
311
  decision: "skip",
312
312
  skipReason: `model output invalid: ${parsed.error}`,
313
- rawModelOutput: res.text.slice(0, 8000),
313
+ // Never persist raw model text (no-CoT privacy policy) — the parse error
314
+ // in skipReason is the diagnostic; the malformed output is not stored.
315
+ rawModelOutput: undefined,
314
316
  planned: [],
315
317
  modelFailed: true,
316
318
  live,
@@ -323,11 +325,15 @@ export async function runCycle(deps) {
323
325
  state.consecutiveModelFailures = 0;
324
326
  const decision = parsed.decision;
325
327
  // Reasoning captured for the Arena terminal (keystone transparency): the
326
- // model's own analysis this cycle + decision confidence + the full raw text
327
- // (capped) for debugging. Shared across the skip + act return paths.
328
+ // model's PARSED, sanitized short analysis + decision confidence. We do NOT
329
+ // persist the full raw model text a response can carry prose reasoning
330
+ // around the JSON, and the privacy promise (frontend copy + CLAUDE.md
331
+ // data-retention) is that raw model reasoning traces are NEVER stored, only
332
+ // the sanitized rationale summary. Shared across the skip + act return paths.
328
333
  const rationale = decision.rationale;
329
334
  const confidence = decision.confidence;
330
- const rawModelOutput = res.text.slice(0, 8000);
335
+ // undefined (not the raw text) → db.ts stores NULL for raw_model_output.
336
+ const rawModelOutput = undefined;
331
337
  if (decision.decision === "skip" || decision.actions.length === 0) {
332
338
  state.consecutiveRejectCycles += 1;
333
339
  saveState(stateFile, state);
package/dist/tools.js CHANGED
@@ -859,8 +859,11 @@ export function registerTools(server, client) {
859
859
  title: "Cross-venue prediction-market statistics",
860
860
  description: "Free public cross-venue prediction-market statistics: total/open/" +
861
861
  "closed market counts, total volume, 24h volume, and liquidity " +
862
- "aggregated across Polymarket, Kalshi, Metaculus, PredictIt, " +
863
- "Limitless, Manifold, and Smarkets, plus market highlights. Volume is " +
862
+ "aggregated across all ten venues (Polymarket, Kalshi, Rothera, " +
863
+ "Limitless, Smarkets, Manifold, Metaculus, PredictIt, Futuur, Myriad), plus market " +
864
+ "highlights. Freshness is SOURCE-AWARE — each venue ingests " +
865
+ "independently; per-venue health (freshness tier, lag, stale reason) " +
866
+ "is at /api/prediction-markets/sources/health. Volume is " +
864
867
  "reported on each venue's own basis (see the methodology at " +
865
868
  "https://coinrithm.com/en/prediction-markets/stats) and monetary " +
866
869
  "totals cover real-money venues only — these are self-computed " +
@@ -876,9 +879,9 @@ export function registerTools(server, client) {
876
879
  }, async ({ fiat }) => present(await client.getPublicPmOverview({ fiat })));
877
880
  server.registerTool("pm_data_events", {
878
881
  title: "Search prediction markets across all venues",
879
- description: "Free public search over prediction-market events across ALL seven " +
880
- "venues (Polymarket, Kalshi, Metaculus, PredictIt, Limitless, " +
881
- "Manifold, Smarkets) — broader than discover_pm_markets, which is " +
882
+ description: "Free public search over prediction-market events across ALL ten " +
883
+ "venues (Polymarket, Kalshi, Rothera, Limitless, Smarkets, " +
884
+ "Manifold, Metaculus, PredictIt, Futuur, Myriad) — broader than discover_pm_markets, which is " +
882
885
  "scoped to the paper-tradeable venues. Returns titles, probabilities, " +
883
886
  "volume/liquidity, status, and source per event, plus " +
884
887
  "referenceProbability when present (CoinRithm's canonical cross-venue " +
@@ -891,8 +894,8 @@ export function registerTools(server, client) {
891
894
  source: z
892
895
  .string()
893
896
  .optional()
894
- .describe("Optional venue filter: polymarket, kalshi, metaculus, predictit, " +
895
- "limitless, manifold, or smarkets."),
897
+ .describe("Optional venue filter: polymarket, kalshi, rothera, limitless, " +
898
+ "smarkets, manifold, metaculus, predictit, futuur, or myriad."),
896
899
  status: z
897
900
  .string()
898
901
  .optional()
@@ -945,8 +948,8 @@ export function registerTools(server, client) {
945
948
  inputSchema: {
946
949
  source: z
947
950
  .string()
948
- .describe("Venue slug: polymarket, kalshi, metaculus, predictit, limitless, " +
949
- "manifold, or smarkets."),
951
+ .describe("Venue slug: polymarket, kalshi, rothera, limitless, smarkets, " +
952
+ "manifold, metaculus, predictit, futuur, or myriad."),
950
953
  slug: z.string().describe("Event slug on that venue."),
951
954
  fiat: z
952
955
  .string()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coinrithm/mcp-trading",
3
- "version": "0.7.1",
3
+ "version": "0.7.2",
4
4
  "mcpName": "io.github.CoinRithm/mcp-trading",
5
5
  "description": "CoinRithm paper-trading toolkit: an MCP server (coinrithm-mcp) AND a self-host agent runner (coinrithm-agent) for spot, futures, and prediction markets with a user-minted API key.",
6
6
  "type": "module",