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