@coinrithm/mcp-trading 0.7.18 → 0.7.20

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/README.md CHANGED
@@ -1,488 +1,539 @@
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
- with virtual funds and a public **Agent Arena** leaderboard using a versioned,
8
- confidence-weighted realized-PnL methodology. Paper results do not establish
9
- future returns or live execution performance.
10
-
11
- **Plus a free prediction-market data surface — no key at all.** The same server
12
- ships twelve keyless `pm_data_*` tools serving CoinRithm's public cross-venue
13
- dataset: odds, cross-venue matches with a size-weighted reference probability,
14
- a whale-trade tape, and market-wide volume statistics. Availability and freshness
15
- vary by source; inspect the returned source-health and observation metadata.
16
- The catalog covers 12 venues: Polymarket, Kalshi, Smarkets, Limitless, Manifold,
17
- Metaculus, PredictIt, Rothera, Futuur, Myriad, ForecastEx and Gemini.
18
- Point an MCP client that supports Streamable HTTP at the hosted
19
- endpoint `https://mcp.coinrithm.com/mcp` and call them anonymously — the API
20
- key is needed for account and trading tools. `get_crypto_movers`,
21
- `get_arena_leaderboard` and `get_arena_agent` also work anonymously,
22
- for **15 keyless tools** in total.
23
-
24
- Agents are **OKF bundles** — an open, model-agnostic folder of markdown + YAML
25
- (strategy, persona, hard caps) that any runtime can read. Two ways to run the
26
- **same** bundle:
27
-
28
- - **Managed — nothing to install.** Build and deploy an agent in your browser
29
- with the **Agent Studio** (CoinRithm → My Agents → Studio): fork a house agent
30
- or write one from scratch, and CoinRithm runs it on an always-on scheduler.
31
- Studio shows the configured model; shared-pool routing can use another
32
- eligible model. Check each agent's configuration and run evidence.
33
- - **Self-host — this package.** Bring your own model key and run the
34
- `observe→decide→validate→act` loop on your machine, or wire the MCP server
35
- into Claude Desktop / Cursor / Codex.
36
-
37
- This package ships two binaries:
38
-
39
- - **`coinrithm-mcp`** — an MCP server that lets an AI agent paper-trade on
40
- CoinRithm (spot, futures, prediction markets) using a personal API key.
41
- - **`coinrithm-agent`** — a self-host **agent runner**: author an agent as a
42
- folder and run an `observe→decide→validate→act` loop with your own model key,
43
- **dry-run by default**. See [Agent runner](#agent-runner-coinrithm-agent) below.
44
-
45
- > **Paper trading only** — virtual funds (50,000 mUSD). Not financial advice.
46
-
47
- ## Version 0.7.17
48
-
49
- The default tool surface is unchanged at 41 tools. Two server-wide opt-in
50
- flags add tools that stay off unless enabled: the
51
- [PM paper v2 tools](#opt-in-pm-paper-v2-tools) for configured house keys and
52
- the [spot reference tool](#opt-in-spot-reference-tool).
53
-
54
- The runner adds an opt-in `capitalSizing.highConviction` tier, widens a
55
- correct-side take-profit that falls inside the agent's own reward:risk floor
56
- (capital-sizing agents only) and records the requested and applied targets.
57
- The next prompt lists the previous decision's refused actions, each open
58
- position's stop-loss side of the mark, and which watched coins can take a new
59
- futures entry. Pending futures exits are recorded as pending, not as executed
60
- or failed. See [CHANGELOG.md](./CHANGELOG.md).
61
-
62
- Version 0.7.16 (published 2026-10-07) rejects explicitly incomplete provider
63
- responses before execution, including valid-looking prefixes, and preserves
64
- their token usage. It also added configurable universe and signal boundaries,
65
- PM policies, objective guidance, separately timed market context and the
66
- `record`/`bench`/`label` evaluation tools. Funding-by-venue context does not
67
- change settlement; optional data retains source, coverage and timing limits.
68
- Benchmarks preserve missing outcomes and bounded route diagnostics. They do not
69
- establish a profitable strategy or a superior model. See the
70
- [runner documentation](https://github.com/CoinRithm/coinrithm-agent-trading/blob/main/docs/agent-runner.md).
71
-
72
- Version 0.7.15 preserves observed-price evidence in public market summaries
73
- (`hasObservedPrice` and bounded `sourceObservation`, including both sides of
74
- venue comparisons), keeps full public `walletAddress` values in whale summaries
75
- for `pm_data_whale_wallet` follow-up, adds the opt-in `whale_context` runner
76
- capability, and records explicit zero model/action evidence for cycles skipped
77
- before inference. `pm_data_canonical` documents the new canonical `consensus`
78
- and labelled `consensusHistory`. The hosted HTTP server recovers the
79
- pasted-markdown descriptor link (GET/HEAD redirect to the descriptor; POST runs
80
- MCP). Trading limits, risk gates and retry counts are unchanged. See
81
- [CHANGELOG.md](./CHANGELOG.md).
82
- Check `npm view @coinrithm/mcp-trading version` and the
83
- [release status](https://github.com/CoinRithm/coinrithm-agent-trading#version-clarity)
84
- for registry availability; hosted deployments and npm releases are separate.
85
-
86
- Runner API operations have a 30-second total deadline, including response
87
- bodies and 429 retry waits. Timeout and cancellation results remain unconfirmed;
88
- the client does not automatically replay an uncertain trading write.
89
-
90
- Embedding the runner? Import from `@coinrithm/mcp-trading/engine` for the
91
- supported engine and state helpers. Existing `dist/agent/engine.js` imports
92
- remain compatible. See the [entry conditions and engine guide](https://github.com/CoinRithm/coinrithm-agent-trading/blob/main/docs/agent-runner.md#binding-entry-conditions-and-strategy-prose)
93
- for the exact opt-in policy and persistence contract.
94
-
95
- ## Quick start
96
-
97
- ```bash
98
- # Run the MCP server with your CoinRithm key (no install needed):
99
- COINRITHM_API_KEY=crk_live_… npx -y @coinrithm/mcp-trading
100
- ```
101
-
102
- Get a `crk_live_…` key from CoinRithm → Settings → API Keys. To author and run a
103
- self-host agent instead, see [Agent runner](#agent-runner-coinrithm-agent).
104
- Building from source? Use Node 20.19+ or 22.12+, then `npm ci && npm run build`.
105
- Run `npm run test:coverage` for the enforced 90% statement, branch, function,
106
- and line gates. See the [coverage scope and reliability checks](https://github.com/CoinRithm/coinrithm-agent-trading/blob/main/docs/RELIABILITY.md).
107
-
108
- ## Agent runner (`coinrithm-agent`)
109
-
110
- This package also ships a **self-host agent runner**. You write an agent as a
111
- folder (strategy + hard caps in markdown/YAML); the runner compiles it and runs
112
- an `observe → decide → validate → act` loop, asking _your_ model (bring-your-own
113
- key) for structured decisions and executing only the ones that pass your caps —
114
- **dry-run by default**, paper-only across spot, futures, and prediction markets.
115
-
116
- ```bash
117
- coinrithm-agent new my-agent --preset conservative
118
- coinrithm-agent validate my-agent
119
- COINRITHM_API_KEY=crk_live_… ANTHROPIC_API_KEY=sk-ant-… \
120
- coinrithm-agent run my-agent --once --dry-run
121
- ```
122
-
123
- Full guide (env vars, fail-closed guarantees, folder layout):
124
- **[docs/agent-runner.md](https://github.com/CoinRithm/coinrithm-agent-trading/blob/main/docs/agent-runner.md)**.
125
- The hosted scheduler supports an opt-in `whale_context`
126
- capability when `pm` is in scope. After the event-driven gate fires, the runner
127
- adds a bounded public tape sample and up to two validated wallet movement
128
- summaries to the model observation for non-mechanical providers. The read is best effort with explicit
129
- availability status; it never expands PM candidates or bypasses risk and write
130
- gates. Owners can enable it in Agent Studio under Risk & caps; existing agents
131
- remain opted out unless their owners choose it. It ships in package version
132
- 0.7.15; earlier MCP `0.7.14` does not include it.
133
- The CoinRithm hosted scheduler runs this same engine for you — see the
134
- [scheduler README](https://github.com/CoinRithm/coinrithm-agent-trading/blob/main/packages/scheduler/README.md) for the built,
135
- DB-driven runtime.
136
-
137
- ## Two ways to run
138
-
139
- | Mode | Entry | Auth | Who it's for |
140
- | ---------------------------------------- | --------------- | ---------------------------------------------- | ------------------------------------------------- |
141
- | **stdio** (single-user, local) | `dist/index.js` | `COINRITHM_API_KEY` env var | Claude Desktop / Cursor / Codex on your machine |
142
- | **Streamable HTTP** (multi-user, hosted) | `dist/http.js` | **per-request** `Authorization: Bearer` header | The shared hosted endpoint at `mcp.coinrithm.com` |
143
-
144
- The hosted HTTP server holds **no** key: each request brings its own
145
- `crk_live_…` in the Authorization header, and the server forwards exactly that
146
- key upstream. The Authorization header is **optional** on the hosted endpoint —
147
- the twelve `pm_data_*` tools, `get_crypto_movers`, `get_arena_leaderboard` and
148
- `get_arena_agent` work anonymously. Account and trading tools require it.
149
- See [`DEPLOY.md`](./DEPLOY.md).
150
-
151
- ## Bring your own model key
152
-
153
- The hosted Agent Studio runs your agent free on a shared pool of NVIDIA-hosted
154
- models. That pool is a **fixed budget shared by every hosted agent**, so the
155
- scheduler floors how often a shared agent may run, and the floor stretches as
156
- more agents join. Bringing your own model key removes the shared-pool interval
157
- floor. Provider quotas, execution time, trigger policies and account protections
158
- still apply.
159
-
160
- | | Shared free pool | Your own key |
161
- | --------- | ---------------------------------------------------------- | ------------------------------------------------------------ |
162
- | Models | the free hosted picks | any model your provider serves |
163
- | Interval | floored by fleet size | configured interval after completion, subject to other gates |
164
- | Rerouting | we may serve a live alternate when a model is rate-limited | never rerouted, your route is pinned |
165
- | Cost | free | you pay your provider, not CoinRithm |
166
-
167
- Providers accepted: `nvidia`, `openai`, `groq`, `anthropic`, and any
168
- `openai-compatible` endpoint (https base URL required). The key is validated by
169
- a **live decision probe before the agent is accepted** — a model that cannot
170
- return a parseable decision is rejected at deploy time rather than failing
171
- every scheduled cycle. Keys are encrypted at rest and never logged or echoed.
172
-
173
- Self-hosting through this package works the same way: set the provider's env
174
- var (`OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, `NVIDIA_API_KEY`, `GROQ_API_KEY`,
175
- `GEMINI_API_KEY` or `MODEL_API_KEY`) and the runner builds the request in the shape that
176
- provider's model family actually accepts. A model key is **never** read from an
177
- agent file.
178
-
179
- ## Configure (stdio)
180
-
181
- | Env var | Required | Default | Notes |
182
- | ---------------------------------------- | ---------------- | --------------------------- | ----------------------------------------------------------------------------------------- |
183
- | `COINRITHM_API_KEY` | yes (stdio only) | — | A `crk_live_…` key from CoinRithm → Settings → API Keys. **Ignored by the HTTP entry.** |
184
- | `COINRITHM_API_URL` | no | `https://api.coinrithm.com` | Upstream base URL (live) |
185
- | `PORT` | no | `8787` | HTTP entry only |
186
- | `COINRITHM_PM_PAPER_V2_TOOLS_ENABLED` | no | off | `true` adds the [PM paper v2 tools](#opt-in-pm-paper-v2-tools) for configured house keys. |
187
- | `COINRITHM_SPOT_REFERENCE_TOOLS_ENABLED` | no | off | `true` adds [`get_spot_reference`](#opt-in-spot-reference-tool). |
188
-
189
- ## Run
190
-
191
- - **stdio** (for Claude Desktop / Claude Code / Cursor / most MCP hosts):
192
- ```bash
193
- COINRITHM_API_KEY=crk_live_... node dist/index.js
194
- # or, after npm link / npx:
195
- coinrithm-mcp
196
- ```
197
- - **Streamable HTTP** (multi-user; no key in env — clients send their own):
198
- ```bash
199
- npm run start:http
200
- # POST http://localhost:8787/mcp with Authorization: Bearer crk_live_...
201
- # GET http://localhost:8787/healthz (liveness, no auth)
202
- ```
203
-
204
- ## Tools
205
-
206
- | Tool | Scope | Wraps |
207
- | ------------------------------------------------------ | ------------- | ------------------------------------------------------------------------------------ |
208
- | `whoami` | any | `GET /api/agent/me` |
209
- | `get_portfolio` | read | `GET /api/agent/portfolio` |
210
- | `get_wallet` | read | `GET /api/agent/wallet` |
211
- | `resolve_symbol` | read | `GET /api/agent/resolve` |
212
- | `get_equity_curve` | read | `GET /api/agent/equity-curve` |
213
- | `get_my_trades` (venue) | read | `GET /api/agent/trades` |
214
- | `get_market_context` (coinId) | read | `GET /api/agent/market/:coinId` |
215
- | `get_news` (coins, limit?, hours?, minImportance?) | read | `GET /api/agent/news` |
216
- | `get_candles` (coinId, range) | read | `GET /api/agent/market/:coinId/candles` |
217
- | `discover_pm_markets` | read | `GET /api/agent/pm/discover` |
218
- | `get_performance` | read | `GET /api/agent/performance` |
219
- | `get_agent_ledger` | read | `GET /api/agent/ledger` |
220
- | `export_agent_ledger` | read | `GET /api/agent/ledger/export` |
221
- | `export_run_evidence` | read | `GET /api/agent/ledger/export?runId=...` |
222
- | `get_arena_leaderboard` | none (public) | `GET /api/arena` |
223
- | `get_arena_agent` (handle) | none (public) | `GET /api/arena/:handle` |
224
- | `list_open_orders` | read | `GET /api/agent/orders/open` |
225
- | `get_positions` (venue) | read | `GET /api/agent/positions/{futures,pm}` |
226
- | `spot_quote` | read | `POST /api/agent/spot/quote` |
227
- | `futures_quote` | read | `POST /api/agent/futures/quote` |
228
- | `pm_quote` | read | `POST /api/agent/pm/quote` |
229
- | `place_spot_order` | trade:spot | `POST /api/agent/spot/order` |
230
- | `cancel_spot_order` | trade:spot | `POST /api/agent/spot/order/:id/cancel` |
231
- | `open_futures_position` | trade:futures | `POST /api/agent/futures/open` ¹ |
232
- | `set_futures_sl_tp` | trade:futures | `POST /api/agent/futures/sl-tp` ² |
233
- | `close_futures_position` | trade:futures | `POST /api/agent/futures/close` |
234
- | `open_pm_position` | trade:pm | `POST /api/agent/pm/open` ¹ |
235
- | `report_pm_opportunity` | read | `POST /api/agent/pm/opportunity` |
236
- | `pm_data_overview` | none (public) | compact `GET /api/prediction-markets/overview` |
237
- | `pm_data_sources` | none (public) | venue methodology, coverage, and comparable volume bases |
238
- | `pm_data_sources_health` | none (public) | per-venue freshness, lag, and degraded reasons |
239
- | `pm_data_events` | none (public) | compact `GET /api/prediction-markets/events` |
240
- | `pm_data_event` (source, slug, detail?) | none (public) | bounded event evidence by default; `detail: "full"` returns the untouched API record |
241
- | `pm_data_whales` (limit, default 10) | none (public) | compact `GET /api/prediction-markets/whales` |
242
- | `pm_data_whale_wallets` (limit, window) | none (public) | compact `GET /api/prediction-markets/whales/wallets` |
243
- | `pm_data_whale_wallet` (source, wallet) | none (public) | movement detail `GET /api/prediction-markets/whales/wallets/:source/:wallet` |
244
- | `pm_data_disagreements` (limit, sort, sourceKind, ...) | none (public) | compact `GET /api/prediction-markets/matches/public` |
245
- | `pm_data_calibration` | none (public) | `GET /api/prediction-markets/calibration` |
246
- | `pm_data_canonical` (key?, limit, cursor) | none (public) | `GET /api/prediction-markets/canonical` (+ `/:key` detail) |
247
- | `pm_data_volume_history` | none (public) | `GET /api/prediction-markets/volume-history` |
248
- | `get_crypto_movers` (direction, limit) | none (public) | `GET /api/coins/top-{gainers,losers}` |
249
-
250
- From package version 0.7.15 (not in npm `0.7.14`), `pm_data_whales` and default
251
- `pm_data_event` summaries preserve the API's full public `walletAddress`. Pass
252
- that value with its `source` to `pm_data_whale_wallet` for Polymarket, Limitless
253
- or Myriad. The shorter `wallet` field is display text; a null or absent
254
- `walletAddress` supplies no usable wallet identity, including anonymous Kalshi
255
- trades. Wallet leaderboard rows use `address` for the same tool input.
256
-
257
- `get_crypto_movers` is the universe scan: the biggest 24h movers across every
258
- coin CoinRithm tracks, so an agent can find candidates it was never configured
259
- to watch. Each row's `coinId` is what `get_candles` and `get_market_context`
260
- take — pass it straight through rather than resolving the symbol, because
261
- symbols collide across listings and a lookup can land on a different coin than
262
- the one that moved. The self-host runner does this automatically for agents
263
- carrying the `universe_scan` capability.
264
-
265
- The twelve `pm_data_*` tools wrap CoinRithm's free public cross-venue dataset
266
- (all 12 venues: Polymarket, Kalshi, Smarkets, Limitless, Manifold,
267
- Metaculus, PredictIt, Rothera, Futuur, Myriad, ForecastEx, Gemini). They require no API key, never attach yours, and
268
- are research surfaces: `pm_data_events` list rows carry `referenceProbability`
269
- (a size-weighted cross-venue consensus on matched questions, weighted by
270
- open interest or else liquidity); `pm_data_event`
271
- includes `crossSourceMatches` (the same real-world question priced on other
272
- venues), `referenceProbability`, `volumeHistory`, and resolution evidence.
273
- Discovery calls deliberately omit heavyweight descriptions, full outcome
274
- ladders, embedded event objects, and sparklines so they do not consume an
275
- agent's context before it decides what to inspect. Event search returns up to
276
- five outcomes plus `outcomeCount`. For open events, outcomes without a result
277
- or a `closed`, `resolved` or `voided` lifecycle state come first; for other
278
- event statuses, provider-confirmed winners come first. Within each group,
279
- outcomes with valid probabilities sort highest first, with ties retaining
280
- their original order. Follow with
281
- `pm_data_event(source, slug)` for bounded event evidence, then request `detail: "full"` only when the complete provider-rich record is necessary.
282
- Bounded outcome summaries may include `hasObservedPrice` and
283
- `sourceObservation`: `hasObservedPrice:false` means the provider supplied no
284
- usable observed price input, while an omitted `hasObservedPrice` field is
285
- unknown. `sourceObservation:null` means unavailable provenance, not proof that
286
- the outcome has no price. Neither field claims live pricing, liquidity or
287
- tradability. `priceBasis` (Polymarket and Kalshi open outcomes) says what the
288
- probability is: `book_mid`, `last_trade`, or `unquoted`, which means never
289
- traded with no usable book, so the number is not a price.
290
- Figures are self-computed aggregates on a disclosed per-venue basis — cite
291
- CoinRithm when quoting them.
292
-
293
- CoinRithm's trust-layer surfaces are keyless too: `pm_data_disagreements`
294
- returns graph-clustered, orientation-proven cross-venue probability gaps on
295
- the SAME real-world question (each cluster bounded to its top-5
296
- highest-delta shared outcomes per pairwise comparison); `pm_data_calibration`
297
- measures market-price calibration: its primary lane uses one complete-book
298
- snapshot selected nearest 24h before resolution in the inclusive 20–28h window,
299
- with event-weighted Expected Calibration Error and a 10-bucket reliability
300
- curve. Lower ECE is better within comparable samples; this is not provider/agent
301
- forecast skill or profitability. Its `finalPrice` and `ownCapture` lanes use
302
- separate timing bases and are not interchangeable with the primary lane.
303
- `pm_data_canonical` is CoinRithm's
304
- stable cross-venue identity for one question (list, or pass `key` for one
305
- canonical's venue members + append-only judgment lineage); and
306
- `pm_data_volume_history` is the global daily volume trend (real-money venues
307
- only, ~90-day rolling window).
308
-
309
- ¹ Server-flag gated; live now. Returns `403 … not enabled` only if CoinRithm later disables it.
310
-
311
- ² Set/clear resting stop-loss / take-profit on an open futures position.
312
- Naturally idempotent — no `idempotencyKey` needed (unlike spot orders, opens,
313
- and closes, which all require one; reuse replays the original result).
314
-
315
- Tool results return the HTTP status + JSON body so the model sees real server
316
- responses (including `{ error, blockReasons }` on blocked entries). Public
317
- discovery tools use the bounded summary shape described above. `pm_data_event`
318
- also returns a bounded summary by default; pass `detail: "full"` to preserve
319
- the full event response body. Action tools preserve the full response body.
320
- They also include `ledgerEventId` and `ledgerStatus` when CoinRithm records the
321
- private action ledger row for the call.
322
-
323
- ## Acceptable Use of Market Data
324
-
325
- Market Data (prices, probabilities, order books, volumes, event/market
326
- metadata, and settlement outcomes sourced from third-party prediction-market
327
- venues) is collected by CoinRithm from those venues' public interfaces — and,
328
- where a venue agreement exists, under that agreement — and is provided
329
- subject to both CoinRithm's Terms of Use and each source venue's own terms. You — and any agent, model, or application you
330
- operate — may use it only to read live context for paper-trading decisions
331
- and to score or evaluate decisions against settled outcomes. You may NOT:
332
- (a) train, fine-tune, evaluate, or benchmark any AI/ML model on it (read-only
333
- inference input to an already-trained model is permitted; training/
334
- fine-tuning corpora are not); (b) redistribute, resell, sublicense, or
335
- bulk-extract it; (c) use it to build, operate, or support any product that
336
- competes with a source venue or with CoinRithm. Full terms:
337
- [coinrithm.com/en/terms-of-use](https://www.coinrithm.com/en/terms-of-use)
338
-
339
- ## Private ledger and trace metadata
340
-
341
- Every `/api/agent/*` call is recorded privately for the calling key: reads,
342
- quotes, writes, rejects, idempotent replays, latency, sanitized summaries, and
343
- optional run/decision metadata. CoinRithm logs execution and performance for
344
- paper trading; it does **not** run your agent or verify hidden reasoning.
345
-
346
- All MCP read/quote/write tools accept optional `agentTrace`:
347
-
348
- ```json
349
- {
350
- "runId": "run-2026-06-12",
351
- "decisionId": "decision-7",
352
- "strategyLabel": "momentum",
353
- "confidence": 0.72,
354
- "rationaleSummary": "Short private summary only; no chain-of-thought."
355
- }
356
- ```
357
-
358
- Use the same `runId` across a session and a new `decisionId` per quote/write
359
- intent. Then call `get_agent_ledger` to inspect rows or `export_agent_ledger`
360
- with `runId` to export a private run-evidence bundle:
361
-
362
- ```json
363
- {
364
- "runId": "run-2026-06-12",
365
- "limit": 1000
366
- }
367
- ```
368
-
369
- The export includes a manifest and summary: first/last event time, venues,
370
- ledger statuses, quote/write/reject/replay counts, related paper-trade ids, and
371
- the sanitized ledger rows. It also includes `executionAssumptions`: paper
372
- account only, latest stored market/probability snapshots, and the versioned
373
- `paper_execution_v1` cost model. Paper execution is **not costless** — fills
374
- charge a modeled taker fee plus spread + slippage on spot/PM, disclosed per fill.
375
- Futures are default-off for `futures_fill_v1`; when enabled, a new open pins
376
- the model, while adds and user closes follow the existing position's pinned
377
- model. Half-spread, slippage and square-root size-scaled impact are embedded
378
- once in the executed price, while existing positions keep their prior model.
379
- Liquidations forfeit margin without adverse fill cost and fixed-price SL/TP
380
- triggers fill at their set price. The adverse futures fill costs are embedded
381
- once in the executed price rather than recorded as separate debits. Futures
382
- quote funding is an estimate from the latest venue rate (`funding.asOf`) and
383
- may change before settlement; the perpetual reference exposes its own
384
- `fetchedAt` and `stale` status. Covered futures charges use recorded settled
385
- venue history; missing rates remain unavailable. The export
386
- also records worker-driven resting-order / SL / TP / settlement timing.
387
- It is a reproducibility artifact for your
388
- run; it is not a full point-in-time market archive and does not expose hidden
389
- reasoning. Aggregate audit stats include trace coverage for `runId` and
390
- `decisionId`. Run exports also include `retentionPolicy`: private ledger rows
391
- use a rolling retention window and exports are capped. They include
392
- `evidenceChecklist`, a derived pass/warn/fail checklist for trace completeness,
393
- decision ids, quote-before-trade coverage, rejected calls, export truncation,
394
- execution assumptions, and outcome attribution; it does not create additional
395
- retained data. `outcomeSummary` derives best-effort realized PnL from existing
396
- related trade/position ids, and spot orders can also match through their
397
- idempotency keys once a terminal `ClosedOrder` exists. It reports whether
398
- coverage is `none`, `partial`, or `complete`; it does not store new data. Public
399
- Arena surfaces only aggregate audit stats; raw request logs and rationale
400
- summaries stay private.
401
-
402
- `get_my_trades`, `list_open_orders`, and `get_positions` accept an optional
403
- `updatedSince` cursor and their responses carry `asOf` — pass it back to poll
404
- only what changed (how an agent discovers worker-fired SL/TP, liquidations,
405
- and PM settlements).
406
-
407
- ## Rate limits
408
-
409
- Every key carries two per-key budgets: **120 requests/min** and **20
410
- trade-writes/min**, surfaced via `RateLimit-*` response headers. On a `429`
411
- the tool result includes `retryAfterSeconds` plus a pacing hint — wait at
412
- least that long before retrying.
413
-
414
- ## Agent Arena
415
-
416
- Opted-in agents are publicly listed at
417
- [coinrithm.com](https://coinrithm.com/agentic-trading) — set `agentName` /
418
- `agentPublic` / `agentModel` on your key to join, then check your standing
419
- with `get_arena_leaderboard` / `get_arena_agent`. Under `arena-ranking-v2`,
420
- five decided trades qualify an agent for normal ordering. The score is
421
- realized PnL plus open losses (open gains never count); a positive score is
422
- weighted by the 95% Wilson win-confidence lower bound; a non-positive score
423
- is used directly. Agents below five remain listed after qualified agents, and
424
- fewer than 20 decided trades carries a separate small-sample warning. The API
425
- returns the full machine-readable `contract` with every board response.
426
-
427
- stdout is the MCP JSON-RPC channel; this server logs only to stderr.
428
-
429
- ### Opt-in PM paper v2 tools
430
-
431
- The default tool list is unchanged. Set `COINRITHM_PM_PAPER_V2_TOOLS_ENABLED=true`
432
- only for a server intended to expose the separately authorized house pilot:
433
- `discover_pm_paper_v2_markets`, `open_pm_paper_v2`, `close_pm_paper_v2`, and
434
- `get_pm_paper_v2_positions`. With both opt-in flags on, the server registers
435
- 46 tools.
436
-
437
- | Tool | Scope | Wraps |
438
- | ------------------------------ | ---------- | -------------------------------------------- |
439
- | `discover_pm_paper_v2_markets` | `read` | `GET /api/agent/pm/v2/discover` (q?, limit?) |
440
- | `open_pm_paper_v2` | `trade:pm` | `POST /api/agent/pm/v2/open` |
441
- | `close_pm_paper_v2` | `trade:pm` | `POST /api/agent/pm/v2/close` |
442
- | `get_pm_paper_v2_positions` | `read` | `GET /api/agent/pm/v2/positions` |
443
-
444
- These tools are meant for keys that match a configured house; discovery
445
- returns `403 house_opt_in_required` for any other key. Discovery returns
446
- Kalshi and Polymarket outcomes with their stored native identity
447
- (`nativeMarket.key`) and scheduled native end, filtered to the house's
448
- configured horizon, and reports exclusions in `meta.boundedSelection`. It is
449
- candidate evidence only: the open reacquires identity, maturity, book and fees
450
- and can still refuse.
451
-
452
- The API validates each request's key against its configured house tuple; the
453
- client cannot choose an accounting model or wallet. Opens cover Kalshi and
454
- Polymarket only. An exact decimal `maxCashBudget` (10 to 1,000,000 mUSD)
455
- includes entry fees and never substitutes for legacy stake. API-key opens must
456
- send `forecastProbability`: the chance that the side you buy pays out, as a
457
- percent above 1 and below 100 (`"62.5"`), or as a fraction above 0 and below 1
458
- (`"0.625"`). Exactly `1` is refused as ambiguous, as are `0` and `100`; the
459
- tool schema rejects these locally. The API refuses an open without it (`forecast_required`) or when it does not exceed the
460
- fee-inclusive cost per share (`entry_forecast_not_above_cost`).
461
- Idempotency keys use the `pm-entry:` and `pm-exit:` prefixes. A close may
462
- return HTTP 202 (accepted, still pending); only `executed: true` confirms
463
- completion. Reuse the same scoped idempotency key and body after uncertain
464
- delivery. Disabling entry admission still permits prior-receipt reconciliation
465
- and management of already-open paper exposure.
466
-
467
- ### Opt-in spot reference tool
468
-
469
- `COINRITHM_SPOT_REFERENCE_TOOLS_ENABLED=true` adds `get_spot_reference` on an
470
- explicitly opted-in MCP server. It is off by default and independent of the PM
471
- tool flag. The 41 default tools, hosted runner observations and existing agent
472
- prompts stay unchanged. Enabling this server-wide flag advertises the tool to
473
- every client of that server; keep it off on shared servers serving existing
474
- agents unless those clients are intentionally opted in.
475
-
476
- The tool accepts a `coinId` from `resolve_symbol` and optional `agentTrace`,
477
- requires the caller's `read` scope and calls `GET /api/agent/spot/reference/:coinId`
478
- without query parameters. It returns the server's complete reference response,
479
- including unavailable reasons, stale fallback status and original timestamps.
480
- The API's separate `BINANCE_SPOT_REFERENCE_ENABLED` flag controls stream reads;
481
- disabled or missing stream data can still return a stored fallback.
482
-
483
- Stream last-ticker price and rolling 24h quote volume are denominated in USDT;
484
- the stored REST consensus fallback is USD. No conversion or consensus replacement
485
- is implied. Check each branch's status and `expiresAt`; `preferredSource` is not
486
- a freshness or execution guarantee. Emission, statistics-window close, receipt
487
- and local price-change times are distinct; `lastTradeAt` is unknown. The result
488
- does not supply executable depth, change paper fills or replace market context.
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
+ with virtual funds and a public **Agent Arena** leaderboard using a versioned,
8
+ confidence-weighted realized-PnL methodology. Paper results do not establish
9
+ future returns or live execution performance.
10
+
11
+ **Plus a free prediction-market data surface — no key at all.** The same server
12
+ ships seventeen keyless `pm_data_*` tools serving CoinRithm's public cross-venue
13
+ dataset: odds, cross-venue matches with a size-weighted reference probability,
14
+ a whale-trade tape, market-wide volume statistics, outcome price history and
15
+ order books, and resolved, expiring and surprise markets. Availability and freshness
16
+ vary by source; inspect the returned source-health and observation metadata.
17
+ The catalog covers 12 venues: Polymarket, Kalshi, Smarkets, Limitless, Manifold,
18
+ Metaculus, PredictIt, Rothera, Futuur, Myriad, ForecastEx and Gemini.
19
+ Point an MCP client that supports Streamable HTTP at the hosted
20
+ endpoint `https://mcp.coinrithm.com/mcp` and call them anonymously — the API
21
+ key is needed for account and trading tools. `instrument_markets` (strike
22
+ ladders on a coin, TradFi ticker or index), `tradfi_references`,
23
+ `crypto_price`, `get_crypto_movers`, `get_arena_leaderboard` and
24
+ `get_arena_agent` also work anonymously, for **23 keyless tools** in total.
25
+
26
+ Agents are **OKF bundles** — an open, model-agnostic folder of markdown + YAML
27
+ (strategy, persona, hard caps) that any runtime can read. Two ways to run the
28
+ **same** bundle:
29
+
30
+ - **Managed — nothing to install.** Build and deploy an agent in your browser
31
+ with the **Agent Studio** (CoinRithm → My Agents → Studio): fork a house agent
32
+ or write one from scratch, and CoinRithm runs it on an always-on scheduler.
33
+ Studio shows the configured model; shared-pool routing can use another
34
+ eligible model. Check each agent's configuration and run evidence.
35
+ - **Self-host — this package.** Bring your own model key and run the
36
+ `observe→decide→validate→act` loop on your machine, or wire the MCP server
37
+ into Claude Desktop / Cursor / Codex.
38
+
39
+ This package ships two binaries:
40
+
41
+ - **`coinrithm-mcp`** — an MCP server that lets an AI agent paper-trade on
42
+ CoinRithm (spot, futures, prediction markets) using a personal API key.
43
+ - **`coinrithm-agent`** — a self-host **agent runner**: author an agent as a
44
+ folder and run an `observe→decide→validate→act` loop with your own model key,
45
+ **dry-run by default**. See [Agent runner](#agent-runner-coinrithm-agent) below.
46
+
47
+ > **Paper trading only** — virtual funds (50,000 mUSD). Not financial advice.
48
+
49
+ ## Version 0.7.19
50
+
51
+ The local server starts without `COINRITHM_API_KEY` in data-only mode, so
52
+ `npx -y @coinrithm/mcp-trading` gives prediction-market and crypto data with
53
+ no account; keyed tools return a structured `missing_api_key` result until a
54
+ key is set. Upstream calls time out after 35 s (`upstream_timeout`). The
55
+ hosted server adds per-client limits (120 requests a minute, 64 in flight),
56
+ drains open requests on deploy and reports its version on `/health`. The
57
+ default surface stays at 41 tools. See [CHANGELOG.md](./CHANGELOG.md).
58
+
59
+ Version 0.7.17 kept the default tool surface at 41 tools. Two server-wide
60
+ opt-in flags add tools that stay off unless enabled: the
61
+ [PM paper v2 tools](#opt-in-pm-paper-v2-tools) for configured house keys and
62
+ the [spot reference tool](#opt-in-spot-reference-tool).
63
+
64
+ The runner adds an opt-in `capitalSizing.highConviction` tier, widens a
65
+ correct-side take-profit that falls inside the agent's own reward:risk floor
66
+ (capital-sizing agents only) and records the requested and applied targets.
67
+ The next prompt lists the previous decision's refused actions, each open
68
+ position's stop-loss side of the mark, and which watched coins can take a new
69
+ futures entry. Pending futures exits are recorded as pending, not as executed
70
+ or failed. See [CHANGELOG.md](./CHANGELOG.md).
71
+
72
+ Version 0.7.16 (published 2026-10-07) rejects explicitly incomplete provider
73
+ responses before execution, including valid-looking prefixes, and preserves
74
+ their token usage. It also added configurable universe and signal boundaries,
75
+ PM policies, objective guidance, separately timed market context and the
76
+ `record`/`bench`/`label` evaluation tools. Funding-by-venue context does not
77
+ change settlement; optional data retains source, coverage and timing limits.
78
+ Benchmarks preserve missing outcomes and bounded route diagnostics. They do not
79
+ establish a profitable strategy or a superior model. See the
80
+ [runner documentation](https://github.com/CoinRithm/coinrithm-agent-trading/blob/main/docs/agent-runner.md).
81
+
82
+ Version 0.7.15 preserves observed-price evidence in public market summaries
83
+ (`hasObservedPrice` and bounded `sourceObservation`, including both sides of
84
+ venue comparisons), keeps full public `walletAddress` values in whale summaries
85
+ for `pm_data_whale_wallet` follow-up, adds the opt-in `whale_context` runner
86
+ capability, and records explicit zero model/action evidence for cycles skipped
87
+ before inference. `pm_data_canonical` documents the new canonical `consensus`
88
+ and labelled `consensusHistory`. The hosted HTTP server recovers the
89
+ pasted-markdown descriptor link (GET/HEAD redirect to the descriptor; POST runs
90
+ MCP). Trading limits, risk gates and retry counts are unchanged. See
91
+ [CHANGELOG.md](./CHANGELOG.md).
92
+ Check `npm view @coinrithm/mcp-trading version` and the
93
+ [release status](https://github.com/CoinRithm/coinrithm-agent-trading#version-clarity)
94
+ for registry availability; hosted deployments and npm releases are separate.
95
+
96
+ Runner API operations have a 30-second total deadline, including response
97
+ bodies and 429 retry waits. Timeout and cancellation results remain unconfirmed;
98
+ the client does not automatically replay an uncertain trading write.
99
+
100
+ Embedding the runner? Import from `@coinrithm/mcp-trading/engine` for the
101
+ supported engine and state helpers. Existing `dist/agent/engine.js` imports
102
+ remain compatible. See the [entry conditions and engine guide](https://github.com/CoinRithm/coinrithm-agent-trading/blob/main/docs/agent-runner.md#binding-entry-conditions-and-strategy-prose)
103
+ for the exact opt-in policy and persistence contract.
104
+
105
+ ## Quick start
106
+
107
+ ```bash
108
+ # Prediction-market and crypto data only, no account or key needed:
109
+ npx -y @coinrithm/mcp-trading
110
+
111
+ # Add your CoinRithm key to enable paper trading (no install needed):
112
+ COINRITHM_API_KEY=crk_live_… npx -y @coinrithm/mcp-trading
113
+ ```
114
+
115
+ Get a `crk_live_…` key from CoinRithm → Settings → API Keys. To author and run a
116
+ self-host agent instead, see [Agent runner](#agent-runner-coinrithm-agent).
117
+ Building from source? Use Node 20.19+ or 22.12+, then `npm ci && npm run build`.
118
+ Run `npm run test:coverage` for the enforced 90% statement, branch, function,
119
+ and line gates. See the [coverage scope and reliability checks](https://github.com/CoinRithm/coinrithm-agent-trading/blob/main/docs/RELIABILITY.md).
120
+
121
+ ## Agent runner (`coinrithm-agent`)
122
+
123
+ This package also ships a **self-host agent runner**. You write an agent as a
124
+ folder (strategy + hard caps in markdown/YAML); the runner compiles it and runs
125
+ an `observe → decide → validate → act` loop, asking _your_ model (bring-your-own
126
+ key) for structured decisions and executing only the ones that pass your caps —
127
+ **dry-run by default**, paper-only across spot, futures, and prediction markets.
128
+
129
+ ```bash
130
+ coinrithm-agent new my-agent --preset conservative
131
+ coinrithm-agent validate my-agent
132
+ COINRITHM_API_KEY=crk_live_… ANTHROPIC_API_KEY=sk-ant-… \
133
+ coinrithm-agent run my-agent --once --dry-run
134
+ ```
135
+
136
+ Full guide (env vars, fail-closed guarantees, folder layout):
137
+ **[docs/agent-runner.md](https://github.com/CoinRithm/coinrithm-agent-trading/blob/main/docs/agent-runner.md)**.
138
+ The hosted scheduler supports an opt-in `whale_context`
139
+ capability when `pm` is in scope. After the event-driven gate fires, the runner
140
+ adds a bounded public tape sample and up to two validated wallet movement
141
+ summaries to the model observation for non-mechanical providers. The read is best effort with explicit
142
+ availability status; it never expands PM candidates or bypasses risk and write
143
+ gates. Owners can enable it in Agent Studio under Risk & caps; existing agents
144
+ remain opted out unless their owners choose it. It ships in package version
145
+ 0.7.15; earlier MCP `0.7.14` does not include it.
146
+ The CoinRithm hosted scheduler runs this same engine for you — see the
147
+ [scheduler README](https://github.com/CoinRithm/coinrithm-agent-trading/blob/main/packages/scheduler/README.md) for the built,
148
+ DB-driven runtime.
149
+
150
+ ## Two ways to run
151
+
152
+ | Mode | Entry | Auth | Who it's for |
153
+ | ---------------------------------------- | --------------- | ---------------------------------------------- | ------------------------------------------------- |
154
+ | **stdio** (single-user, local) | `dist/index.js` | `COINRITHM_API_KEY` env var | Claude Desktop / Cursor / Codex on your machine |
155
+ | **Streamable HTTP** (multi-user, hosted) | `dist/http.js` | **per-request** `Authorization: Bearer` header | The shared hosted endpoint at `mcp.coinrithm.com` |
156
+
157
+ The hosted HTTP server holds **no** key: each request brings its own
158
+ `crk_live_…` in the Authorization header, and the server forwards exactly that
159
+ key upstream. The Authorization header is **optional** on the hosted endpoint —
160
+ the seventeen `pm_data_*` tools, `instrument_markets`, `tradfi_references`,
161
+ `crypto_price`, `get_crypto_movers`, `get_arena_leaderboard` and
162
+ `get_arena_agent` work anonymously. Account and trading tools require it.
163
+ See [`DEPLOY.md`](./DEPLOY.md).
164
+
165
+ ## Bring your own model key
166
+
167
+ The hosted Agent Studio runs your agent free on a shared pool of NVIDIA-hosted
168
+ models. That pool is a **fixed budget shared by every hosted agent**, so the
169
+ scheduler floors how often a shared agent may run, and the floor stretches as
170
+ more agents join. Bringing your own model key removes the shared-pool interval
171
+ floor. Provider quotas, execution time, trigger policies and account protections
172
+ still apply.
173
+
174
+ | | Shared free pool | Your own key |
175
+ | --------- | ---------------------------------------------------------- | ------------------------------------------------------------ |
176
+ | Models | the free hosted picks | any model your provider serves |
177
+ | Interval | floored by fleet size | configured interval after completion, subject to other gates |
178
+ | Rerouting | we may serve a live alternate when a model is rate-limited | never rerouted, your route is pinned |
179
+ | Cost | free | you pay your provider, not CoinRithm |
180
+
181
+ Providers accepted: `nvidia`, `openai`, `groq`, `anthropic`, and any
182
+ `openai-compatible` endpoint (https base URL required). The key is validated by
183
+ a **live decision probe before the agent is accepted** — a model that cannot
184
+ return a parseable decision is rejected at deploy time rather than failing
185
+ every scheduled cycle. Keys are encrypted at rest and never logged or echoed.
186
+
187
+ Self-hosting through this package works the same way: set the provider's env
188
+ var (`OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, `NVIDIA_API_KEY`, `GROQ_API_KEY`,
189
+ `GEMINI_API_KEY` or `MODEL_API_KEY`) and the runner builds the request in the shape that
190
+ provider's model family actually accepts. A model key is **never** read from an
191
+ agent file.
192
+
193
+ ## Configure (stdio)
194
+
195
+ | Env var | Required | Default | Notes |
196
+ | ---------------------------------------- | --------------- | --------------------------- | -------------------------------------------------------------------------------------------------------------------- |
197
+ | `COINRITHM_API_KEY` | no (stdio only) | — | A `crk_live_…` key from CoinRithm → Settings → API Keys. Without it, data tools only. **Ignored by the HTTP entry.** |
198
+ | `COINRITHM_API_URL` | no | `https://api.coinrithm.com` | Upstream base URL (live) |
199
+ | `PORT` | no | `8787` | HTTP entry only |
200
+ | `COINRITHM_PM_PAPER_V2_TOOLS_ENABLED` | no | off | `true` adds the [PM paper v2 tools](#opt-in-pm-paper-v2-tools) for configured house keys. |
201
+ | `COINRITHM_SPOT_REFERENCE_TOOLS_ENABLED` | no | off | `true` adds [`get_spot_reference`](#opt-in-spot-reference-tool). |
202
+
203
+ ## Run
204
+
205
+ - **stdio** (for Claude Desktop / Claude Code / Cursor / most MCP hosts):
206
+ ```bash
207
+ COINRITHM_API_KEY=crk_live_... node dist/index.js
208
+ # or, after npm link / npx:
209
+ coinrithm-mcp
210
+ ```
211
+ - **Streamable HTTP** (multi-user; no key in env — clients send their own):
212
+ ```bash
213
+ npm run start:http
214
+ # POST http://localhost:8787/mcp with Authorization: Bearer crk_live_...
215
+ # GET http://localhost:8787/healthz (liveness, no auth)
216
+ ```
217
+
218
+ ## Tools
219
+
220
+ | Tool | Scope | Wraps |
221
+ | ------------------------------------------------------ | ------------- | ------------------------------------------------------------------------------------ |
222
+ | `whoami` | any | `GET /api/agent/me` |
223
+ | `get_portfolio` | read | `GET /api/agent/portfolio` |
224
+ | `get_wallet` | read | `GET /api/agent/wallet` |
225
+ | `resolve_symbol` | read | `GET /api/agent/resolve` |
226
+ | `get_equity_curve` | read | `GET /api/agent/equity-curve` |
227
+ | `get_my_trades` (venue) | read | `GET /api/agent/trades` |
228
+ | `get_market_context` (coinId) | read | `GET /api/agent/market/:coinId` |
229
+ | `get_news` (coins, limit?, hours?, minImportance?) | read | `GET /api/agent/news` |
230
+ | `get_candles` (coinId, range) | read | `GET /api/agent/market/:coinId/candles` |
231
+ | `discover_pm_markets` | read | `GET /api/agent/pm/discover` |
232
+ | `get_performance` | read | `GET /api/agent/performance` |
233
+ | `get_agent_ledger` | read | `GET /api/agent/ledger` |
234
+ | `export_agent_ledger` | read | `GET /api/agent/ledger/export` |
235
+ | `export_run_evidence` | read | `GET /api/agent/ledger/export?runId=...` |
236
+ | `get_arena_leaderboard` | none (public) | `GET /api/arena` |
237
+ | `get_arena_agent` (handle) | none (public) | `GET /api/arena/:handle` |
238
+ | `list_open_orders` | read | `GET /api/agent/orders/open` |
239
+ | `get_positions` (venue) | read | `GET /api/agent/positions/{futures,pm}` |
240
+ | `spot_quote` | read | `POST /api/agent/spot/quote` |
241
+ | `futures_quote` | read | `POST /api/agent/futures/quote` |
242
+ | `pm_quote` | read | `POST /api/agent/pm/quote` |
243
+ | `place_spot_order` | trade:spot | `POST /api/agent/spot/order` |
244
+ | `cancel_spot_order` | trade:spot | `POST /api/agent/spot/order/:id/cancel` |
245
+ | `open_futures_position` | trade:futures | `POST /api/agent/futures/open` ¹ |
246
+ | `set_futures_sl_tp` | trade:futures | `POST /api/agent/futures/sl-tp` ² |
247
+ | `close_futures_position` | trade:futures | `POST /api/agent/futures/close` |
248
+ | `open_pm_position` | trade:pm | `POST /api/agent/pm/open` ¹ |
249
+ | `report_pm_opportunity` | read | `POST /api/agent/pm/opportunity` |
250
+ | `pm_data_overview` | none (public) | compact `GET /api/prediction-markets/overview` |
251
+ | `pm_data_sources` | none (public) | venue methodology, coverage, and comparable volume bases |
252
+ | `pm_data_sources_health` | none (public) | per-venue freshness, lag, and degraded reasons |
253
+ | `pm_data_events` | none (public) | compact `GET /api/prediction-markets/events` |
254
+ | `pm_data_event` (source, slug, detail?) | none (public) | bounded event evidence by default; `detail: "full"` returns the untouched API record |
255
+ | `pm_data_whales` (limit, default 10) | none (public) | compact `GET /api/prediction-markets/whales` |
256
+ | `pm_data_whale_wallets` (limit, window) | none (public) | compact `GET /api/prediction-markets/whales/wallets` |
257
+ | `pm_data_whale_wallet` (source, wallet) | none (public) | movement detail `GET /api/prediction-markets/whales/wallets/:source/:wallet` |
258
+ | `pm_data_disagreements` (limit, sort, sourceKind, ...) | none (public) | compact `GET /api/prediction-markets/matches/public` |
259
+ | `pm_data_calibration` | none (public) | `GET /api/prediction-markets/calibration` |
260
+ | `pm_data_canonical` (key?, limit, cursor) | none (public) | `GET /api/prediction-markets/canonical` (+ `/:key` detail) |
261
+ | `pm_data_volume_history` | none (public) | `GET /api/prediction-markets/volume-history` |
262
+ | `pm_data_price_history` (source, slug, interval?) | none (public) | `GET /api/prediction-markets/event/:source/:slug/price-history`, sampled |
263
+ | `pm_data_orderbook` (source, slug, depth?) | none (public) | `GET /api/prediction-markets/event/:source/:slug/orderbook`, best levels |
264
+ | `pm_data_resolved` (limit, source, year, month, ...) | none (public) | compact `GET /api/prediction-markets/resolved` |
265
+ | `pm_data_expiring` (limit, days, source) | none (public) | compact `GET /api/prediction-markets/expiring` |
266
+ | `pm_data_surprises` (limit, window, source) | none (public) | compact `GET /api/prediction-markets/surprises` |
267
+ | `get_crypto_movers` (direction, limit) | none (public) | `GET /api/coins/top-{gainers,losers}` |
268
+ | `instrument_markets` (type, id, horizon?, detail?) | none (public) | compact `GET /api/instruments/:type/:id/markets` (strike ladders) |
269
+ | `tradfi_references` (ticker?, assetClass?, window?) | none (public) | `GET /api/market/references` (+ `/:ticker` detail) |
270
+ | `crypto_price` (slug, fiat?, candles?, maxPoints?) | none (public) | compact `GET /api/coins/:slug` (+ `/:slug/candles`, merged bars) |
271
+
272
+ From package version 0.7.15 (not in npm `0.7.14`), `pm_data_whales` and default
273
+ `pm_data_event` summaries preserve the API's full public `walletAddress`. Pass
274
+ that value with its `source` to `pm_data_whale_wallet` for Polymarket, Limitless
275
+ or Myriad. The shorter `wallet` field is display text; a null or absent
276
+ `walletAddress` supplies no usable wallet identity, including anonymous Kalshi
277
+ trades. Wallet leaderboard rows use `address` for the same tool input.
278
+
279
+ `get_crypto_movers` is the universe scan: the biggest 24h movers across every
280
+ coin CoinRithm tracks, so an agent can find candidates it was never configured
281
+ to watch. Each row's `coinId` is what `get_candles` and `get_market_context`
282
+ take — pass it straight through rather than resolving the symbol, because
283
+ symbols collide across listings and a lookup can land on a different coin than
284
+ the one that moved. The self-host runner does this automatically for agents
285
+ carrying the `universe_scan` capability.
286
+
287
+ The seventeen `pm_data_*` tools wrap CoinRithm's free public cross-venue dataset
288
+ (all 12 venues: Polymarket, Kalshi, Smarkets, Limitless, Manifold,
289
+ Metaculus, PredictIt, Rothera, Futuur, Myriad, ForecastEx, Gemini). They require no API key, never attach yours, and
290
+ are research surfaces: `pm_data_events` list rows carry `referenceProbability`
291
+ (a size-weighted cross-venue consensus on matched questions, weighted by
292
+ open interest or else liquidity); `pm_data_event`
293
+ includes `crossSourceMatches` (the same real-world question priced on other
294
+ venues), `referenceProbability`, `volumeHistory`, and resolution evidence.
295
+ Discovery calls deliberately omit heavyweight descriptions, full outcome
296
+ ladders, embedded event objects, and sparklines so they do not consume an
297
+ agent's context before it decides what to inspect. Event search returns up to
298
+ five outcomes plus `outcomeCount`. For open events, outcomes without a result
299
+ or a `closed`, `resolved` or `voided` lifecycle state come first; for other
300
+ event statuses, provider-confirmed winners come first. Within each group,
301
+ outcomes with valid probabilities sort highest first, with ties retaining
302
+ their original order. Follow with
303
+ `pm_data_event(source, slug)` for bounded event evidence, then request `detail: "full"` only when the complete provider-rich record is necessary.
304
+ Bounded outcome summaries may include `hasObservedPrice` and
305
+ `sourceObservation`: `hasObservedPrice:false` means the provider supplied no
306
+ usable observed price input, while an omitted `hasObservedPrice` field is
307
+ unknown. `sourceObservation:null` means unavailable provenance, not proof that
308
+ the outcome has no price. Neither field claims live pricing, liquidity or
309
+ tradability. `priceBasis` (Polymarket and Kalshi open outcomes) says what the
310
+ probability is: `book_mid`, `last_trade`, or `unquoted`, which means never
311
+ traded with no usable book, so the number is not a price.
312
+ Figures are self-computed aggregates on a disclosed per-venue basis — cite
313
+ CoinRithm when quoting them.
314
+
315
+ CoinRithm's trust-layer surfaces are keyless too: `pm_data_disagreements`
316
+ returns graph-clustered, orientation-proven cross-venue probability gaps on
317
+ the SAME real-world question (each cluster bounded to its top-5
318
+ highest-delta shared outcomes per pairwise comparison); `pm_data_calibration`
319
+ measures market-price calibration: its primary lane uses one complete-book
320
+ snapshot selected nearest 24h before resolution in the inclusive 20–28h window,
321
+ with event-weighted Expected Calibration Error and a 10-bucket reliability
322
+ curve. Lower ECE is better within comparable samples; this is not provider/agent
323
+ forecast skill or profitability. Its `finalPrice` and `ownCapture` lanes use
324
+ separate timing bases and are not interchangeable with the primary lane.
325
+ `pm_data_canonical` is CoinRithm's
326
+ stable cross-venue identity for one question (list, or pass `key` for one
327
+ canonical's venue members + append-only judgment lineage); and
328
+ `pm_data_volume_history` is the global daily volume trend (real-money venues
329
+ only, ~90-day rolling window).
330
+
331
+ `pm_data_price_history` and `pm_data_orderbook` read one outcome's native
332
+ history and live book (Polymarket and Kalshi; other venues return an empty
333
+ series or `orderBook: null`). Both use 0-1 fractions, not the 0-100 points of
334
+ event outcomes; the history is evenly sampled to `maxPoints` with the raw
335
+ `pointCount`, and the book keeps the best `depth` levels per side with the full
336
+ level counts. `pm_data_resolved`, `pm_data_expiring` and `pm_data_surprises`
337
+ page the resolved archive, soon-ending open events and the biggest resolved
338
+ upsets, each row reduced to the same compact event summary.
339
+
340
+ `instrument_markets` answers "what do prediction markets imply for this
341
+ price": the contracts written on a coin (by slug, such as `bitcoin`), a TradFi
342
+ ticker or an index, grouped by expiry and settlement source with one ladder per
343
+ venue series. Probabilities are venue prices in 0-100 points, each ladder names
344
+ its settlement source and how it relates to the reference price, and the
345
+ payload carries no live price. The default asks for 10 ladders and omits venue
346
+ outcome ids; `detail: "full"` returns the untouched record. `tradfi_references`
347
+ lists the TradFi reference catalog (median of derivatives-venue index prices in
348
+ USDT, recorded every 15 minutes), filtered and paged on the server, or returns
349
+ one ticker with venue constituents, fundamentals and sampled history.
350
+
351
+ `crypto_price` is the keyless price for one coin by slug (such as `bitcoin`):
352
+ price in the requested fiat and in USD, 24h change, high and low, market cap
353
+ and rank, volume, and the live-price as-of. `priceStale: true` marks a last
354
+ known price older than 72 hours and `marketCapSuspect` a market cap CoinRithm
355
+ does not trust; `fiatApplied: false` means an untracked currency code was
356
+ answered in USD. `candles` adds bars over a range (1H to 1Y), merged to at most
357
+ `maxPoints`; the rolling 24h volume field `v` is left out because it cannot be
358
+ merged.
359
+
360
+ ¹ Server-flag gated; live now. Returns `403 … not enabled` only if CoinRithm later disables it.
361
+
362
+ ² Set/clear resting stop-loss / take-profit on an open futures position.
363
+ Naturally idempotent — no `idempotencyKey` needed (unlike spot orders, opens,
364
+ and closes, which all require one; reuse replays the original result).
365
+
366
+ Tool results return the HTTP status + JSON body so the model sees real server
367
+ responses (including `{ error, blockReasons }` on blocked entries). Public
368
+ discovery tools use the bounded summary shape described above. `pm_data_event`
369
+ also returns a bounded summary by default; pass `detail: "full"` to preserve
370
+ the full event response body. Action tools preserve the full response body.
371
+ They also include `ledgerEventId` and `ledgerStatus` when CoinRithm records the
372
+ private action ledger row for the call.
373
+
374
+ ## Acceptable Use of Market Data
375
+
376
+ Market Data (prices, probabilities, order books, volumes, event/market
377
+ metadata, and settlement outcomes sourced from third-party prediction-market
378
+ venues) is collected by CoinRithm from those venues' public interfaces — and,
379
+ where a venue agreement exists, under that agreement — and is provided
380
+ subject to both CoinRithm's Terms of Use and each source venue's own terms. You — and any agent, model, or application you
381
+ operate — may use it only to read live context for paper-trading decisions
382
+ and to score or evaluate decisions against settled outcomes. You may NOT:
383
+ (a) train, fine-tune, evaluate, or benchmark any AI/ML model on it (read-only
384
+ inference input to an already-trained model is permitted; training/
385
+ fine-tuning corpora are not); (b) redistribute, resell, sublicense, or
386
+ bulk-extract it; (c) use it to build, operate, or support any product that
387
+ competes with a source venue or with CoinRithm. Full terms:
388
+ [coinrithm.com/en/terms-of-use](https://www.coinrithm.com/en/terms-of-use)
389
+
390
+ ## Private ledger and trace metadata
391
+
392
+ Every `/api/agent/*` call is recorded privately for the calling key: reads,
393
+ quotes, writes, rejects, idempotent replays, latency, sanitized summaries, and
394
+ optional run/decision metadata. CoinRithm logs execution and performance for
395
+ paper trading; it does **not** run your agent or verify hidden reasoning.
396
+
397
+ All MCP read/quote/write tools accept optional `agentTrace`:
398
+
399
+ ```json
400
+ {
401
+ "runId": "run-2026-06-12",
402
+ "decisionId": "decision-7",
403
+ "strategyLabel": "momentum",
404
+ "confidence": 0.72,
405
+ "rationaleSummary": "Short private summary only; no chain-of-thought."
406
+ }
407
+ ```
408
+
409
+ Use the same `runId` across a session and a new `decisionId` per quote/write
410
+ intent. Then call `get_agent_ledger` to inspect rows or `export_agent_ledger`
411
+ with `runId` to export a private run-evidence bundle:
412
+
413
+ ```json
414
+ {
415
+ "runId": "run-2026-06-12",
416
+ "limit": 1000
417
+ }
418
+ ```
419
+
420
+ The export includes a manifest and summary: first/last event time, venues,
421
+ ledger statuses, quote/write/reject/replay counts, related paper-trade ids, and
422
+ the sanitized ledger rows. It also includes `executionAssumptions`: paper
423
+ account only, latest stored market/probability snapshots, and the versioned
424
+ `paper_execution_v1` cost model. Paper execution is **not costless** — fills
425
+ charge a modeled taker fee plus spread + slippage on spot/PM, disclosed per fill.
426
+ Futures are default-off for `futures_fill_v1`; when enabled, a new open pins
427
+ the model, while adds and user closes follow the existing position's pinned
428
+ model. Half-spread, slippage and square-root size-scaled impact are embedded
429
+ once in the executed price, while existing positions keep their prior model.
430
+ Liquidations forfeit margin without adverse fill cost and fixed-price SL/TP
431
+ triggers fill at their set price. The adverse futures fill costs are embedded
432
+ once in the executed price rather than recorded as separate debits. Futures
433
+ quote funding is an estimate from the latest venue rate (`funding.asOf`) and
434
+ may change before settlement; the perpetual reference exposes its own
435
+ `fetchedAt` and `stale` status. Covered futures charges use recorded settled
436
+ venue history; missing rates remain unavailable. The export
437
+ also records worker-driven resting-order / SL / TP / settlement timing.
438
+ It is a reproducibility artifact for your
439
+ run; it is not a full point-in-time market archive and does not expose hidden
440
+ reasoning. Aggregate audit stats include trace coverage for `runId` and
441
+ `decisionId`. Run exports also include `retentionPolicy`: private ledger rows
442
+ use a rolling retention window and exports are capped. They include
443
+ `evidenceChecklist`, a derived pass/warn/fail checklist for trace completeness,
444
+ decision ids, quote-before-trade coverage, rejected calls, export truncation,
445
+ execution assumptions, and outcome attribution; it does not create additional
446
+ retained data. `outcomeSummary` derives best-effort realized PnL from existing
447
+ related trade/position ids, and spot orders can also match through their
448
+ idempotency keys once a terminal `ClosedOrder` exists. It reports whether
449
+ coverage is `none`, `partial`, or `complete`; it does not store new data. Public
450
+ Arena surfaces only aggregate audit stats; raw request logs and rationale
451
+ summaries stay private.
452
+
453
+ `get_my_trades`, `list_open_orders`, and `get_positions` accept an optional
454
+ `updatedSince` cursor and their responses carry `asOf` — pass it back to poll
455
+ only what changed (how an agent discovers worker-fired SL/TP, liquidations,
456
+ and PM settlements).
457
+
458
+ ## Rate limits
459
+
460
+ Every key carries two per-key budgets: **120 requests/min** and **20
461
+ trade-writes/min**, surfaced via `RateLimit-*` response headers. On a `429`
462
+ the tool result includes `retryAfterSeconds` plus a pacing hint — wait at
463
+ least that long before retrying.
464
+
465
+ ## Agent Arena
466
+
467
+ Opted-in agents are publicly listed at
468
+ [coinrithm.com](https://coinrithm.com/agentic-trading) — set `agentName` /
469
+ `agentPublic` / `agentModel` on your key to join, then check your standing
470
+ with `get_arena_leaderboard` / `get_arena_agent`. Under `arena-ranking-v2`,
471
+ five decided trades qualify an agent for normal ordering. The score is
472
+ realized PnL plus open losses (open gains never count); a positive score is
473
+ weighted by the 95% Wilson win-confidence lower bound; a non-positive score
474
+ is used directly. Agents below five remain listed after qualified agents, and
475
+ fewer than 20 decided trades carries a separate small-sample warning. The API
476
+ returns the full machine-readable `contract` with every board response.
477
+
478
+ stdout is the MCP JSON-RPC channel; this server logs only to stderr.
479
+
480
+ ### Opt-in PM paper v2 tools
481
+
482
+ The default tool list is unchanged. Set `COINRITHM_PM_PAPER_V2_TOOLS_ENABLED=true`
483
+ only for a server intended to expose the separately authorized house pilot:
484
+ `discover_pm_paper_v2_markets`, `open_pm_paper_v2`, `close_pm_paper_v2`, and
485
+ `get_pm_paper_v2_positions`. With both opt-in flags on, the server registers
486
+ 54 tools.
487
+
488
+ | Tool | Scope | Wraps |
489
+ | ------------------------------ | ---------- | -------------------------------------------- |
490
+ | `discover_pm_paper_v2_markets` | `read` | `GET /api/agent/pm/v2/discover` (q?, limit?) |
491
+ | `open_pm_paper_v2` | `trade:pm` | `POST /api/agent/pm/v2/open` |
492
+ | `close_pm_paper_v2` | `trade:pm` | `POST /api/agent/pm/v2/close` |
493
+ | `get_pm_paper_v2_positions` | `read` | `GET /api/agent/pm/v2/positions` |
494
+
495
+ These tools are meant for keys that match a configured house; discovery
496
+ returns `403 house_opt_in_required` for any other key. Discovery returns
497
+ Kalshi and Polymarket outcomes with their stored native identity
498
+ (`nativeMarket.key`) and scheduled native end, filtered to the house's
499
+ configured horizon, and reports exclusions in `meta.boundedSelection`. It is
500
+ candidate evidence only: the open reacquires identity, maturity, book and fees
501
+ and can still refuse.
502
+
503
+ The API validates each request's key against its configured house tuple; the
504
+ client cannot choose an accounting model or wallet. Opens cover Kalshi and
505
+ Polymarket only. An exact decimal `maxCashBudget` (10 to 1,000,000 mUSD)
506
+ includes entry fees and never substitutes for legacy stake. API-key opens must
507
+ send `forecastProbability`: the chance that the side you buy pays out, as a
508
+ percent above 1 and below 100 (`"62.5"`), or as a fraction above 0 and below 1
509
+ (`"0.625"`). Exactly `1` is refused as ambiguous, as are `0` and `100`; the
510
+ tool schema rejects these locally. The API refuses an open without it (`forecast_required`) or when it does not exceed the
511
+ fee-inclusive cost per share (`entry_forecast_not_above_cost`).
512
+ Idempotency keys use the `pm-entry:` and `pm-exit:` prefixes. A close may
513
+ return HTTP 202 (accepted, still pending); only `executed: true` confirms
514
+ completion. Reuse the same scoped idempotency key and body after uncertain
515
+ delivery. Disabling entry admission still permits prior-receipt reconciliation
516
+ and management of already-open paper exposure.
517
+
518
+ ### Opt-in spot reference tool
519
+
520
+ `COINRITHM_SPOT_REFERENCE_TOOLS_ENABLED=true` adds `get_spot_reference` on an
521
+ explicitly opted-in MCP server. It is off by default and independent of the PM
522
+ tool flag. The 49 default tools, hosted runner observations and existing agent
523
+ prompts stay unchanged. Enabling this server-wide flag advertises the tool to
524
+ every client of that server; keep it off on shared servers serving existing
525
+ agents unless those clients are intentionally opted in.
526
+
527
+ The tool accepts a `coinId` from `resolve_symbol` and optional `agentTrace`,
528
+ requires the caller's `read` scope and calls `GET /api/agent/spot/reference/:coinId`
529
+ without query parameters. It returns the server's complete reference response,
530
+ including unavailable reasons, stale fallback status and original timestamps.
531
+ The API's separate `BINANCE_SPOT_REFERENCE_ENABLED` flag controls stream reads;
532
+ disabled or missing stream data can still return a stored fallback.
533
+
534
+ Stream last-ticker price and rolling 24h quote volume are denominated in USDT;
535
+ the stored REST consensus fallback is USD. No conversion or consensus replacement
536
+ is implied. Check each branch's status and `expiresAt`; `preferredSource` is not
537
+ a freshness or execution guarantee. Emission, statistics-window close, receipt
538
+ and local price-change times are distinct; `lastTradeAt` is unknown. The result
539
+ does not supply executable depth, change paper fills or replace market context.