@coinrithm/mcp-trading 0.7.14 → 0.7.16

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.
Files changed (72) hide show
  1. package/CHANGELOG.md +811 -613
  2. package/README.md +415 -366
  3. package/dist/agent/bench/bench.d.ts +59 -0
  4. package/dist/agent/bench/bench.js +319 -0
  5. package/dist/agent/bench/cassette.d.ts +97 -0
  6. package/dist/agent/bench/cassette.js +181 -0
  7. package/dist/agent/bench/costs.d.ts +28 -0
  8. package/dist/agent/bench/costs.js +60 -0
  9. package/dist/agent/bench/labelBuilder.d.ts +123 -0
  10. package/dist/agent/bench/labelBuilder.js +282 -0
  11. package/dist/agent/bench/labels.d.ts +75 -0
  12. package/dist/agent/bench/labels.js +259 -0
  13. package/dist/agent/bench/recordingClient.d.ts +51 -0
  14. package/dist/agent/bench/recordingClient.js +193 -0
  15. package/dist/agent/bench/replayClient.d.ts +41 -0
  16. package/dist/agent/bench/replayClient.js +262 -0
  17. package/dist/agent/bench/report.d.ts +115 -0
  18. package/dist/agent/bench/report.js +435 -0
  19. package/dist/agent/cli.d.ts +25 -0
  20. package/dist/agent/cli.js +300 -2
  21. package/dist/agent/client.d.ts +14 -0
  22. package/dist/agent/client.js +113 -4
  23. package/dist/agent/configurationWarnings.js +11 -0
  24. package/dist/agent/decision.d.ts +3 -0
  25. package/dist/agent/decision.js +85 -3
  26. package/dist/agent/decisionReceipt.d.ts +5 -1
  27. package/dist/agent/decisionReceipt.js +52 -3
  28. package/dist/agent/decisionValidator.d.ts +30 -0
  29. package/dist/agent/decisionValidator.js +147 -2
  30. package/dist/agent/engine.d.ts +3 -3
  31. package/dist/agent/engine.js +3 -3
  32. package/dist/agent/futuresEligibility.d.ts +36 -0
  33. package/dist/agent/futuresEligibility.js +90 -0
  34. package/dist/agent/observe.d.ts +35 -2
  35. package/dist/agent/observe.js +969 -128
  36. package/dist/agent/pmContext.d.ts +10 -1
  37. package/dist/agent/pmContext.js +163 -1
  38. package/dist/agent/prompt.d.ts +18 -1
  39. package/dist/agent/prompt.js +229 -33
  40. package/dist/agent/promptTables.d.ts +1 -0
  41. package/dist/agent/promptTables.js +33 -0
  42. package/dist/agent/providerCapabilities.d.ts +9 -0
  43. package/dist/agent/providerCapabilities.js +57 -4
  44. package/dist/agent/providers.d.ts +28 -7
  45. package/dist/agent/providers.js +200 -50
  46. package/dist/agent/resolve.js +3 -0
  47. package/dist/agent/runner.d.ts +8 -0
  48. package/dist/agent/runner.js +159 -26
  49. package/dist/agent/setups.d.ts +2 -1
  50. package/dist/agent/setups.js +17 -16
  51. package/dist/agent/signals.d.ts +33 -0
  52. package/dist/agent/signals.js +89 -0
  53. package/dist/agent/skill.js +37 -0
  54. package/dist/agent/skillValidator.js +33 -0
  55. package/dist/agent/strictLint.js +29 -0
  56. package/dist/agent/templates.js +30 -30
  57. package/dist/agent/types.d.ts +266 -13
  58. package/dist/agent/types.js +4 -0
  59. package/dist/agent/universe.d.ts +78 -0
  60. package/dist/agent/universe.js +215 -0
  61. package/dist/client.d.ts +9 -2
  62. package/dist/client.js +22 -10
  63. package/dist/http.d.ts +1 -0
  64. package/dist/http.js +17 -2
  65. package/dist/httpCompletion.d.ts +1 -1
  66. package/dist/httpCompletion.js +1 -0
  67. package/dist/index.js +2 -1
  68. package/dist/instructions.d.ts +1 -0
  69. package/dist/instructions.js +16 -0
  70. package/dist/tools.d.ts +1 -0
  71. package/dist/tools.js +150 -66
  72. package/package.json +98 -97
package/README.md CHANGED
@@ -1,366 +1,415 @@
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 liquidity-aware 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. The hosted `get_crypto_movers`
21
- tool also works anonymously, for **13 keyless tools** in total.
22
-
23
- Agents are **OKF bundles** — an open, model-agnostic folder of markdown + YAML
24
- (strategy, persona, hard caps) that any runtime can read. Two ways to run the
25
- **same** bundle:
26
-
27
- - **Managed — nothing to install.** Build and deploy an agent in your browser
28
- with the **Agent Studio** (CoinRithm → My Agents → Studio): fork a house agent
29
- or write one from scratch, and CoinRithm runs it on an always-on scheduler.
30
- Studio shows the configured model; shared-pool routing can use another
31
- eligible model. Check each agent's configuration and run evidence.
32
- - **Self-host — this package.** Bring your own model key and run the
33
- `observe→decide→validate→act` loop on your machine, or wire the MCP server
34
- into Claude Desktop / Cursor / Codex.
35
-
36
- This package ships two binaries:
37
-
38
- - **`coinrithm-mcp`** — an MCP server that lets an AI agent paper-trade on
39
- CoinRithm (spot, futures, prediction markets) using a personal API key.
40
- - **`coinrithm-agent`** — a self-host **agent runner**: author an agent as a
41
- folder and run an `observe→decide→validate→act` loop with your own model key,
42
- **dry-run by default**. See [Agent runner](#agent-runner-coinrithm-agent) below.
43
-
44
- > **Paper trading only** — virtual funds (50,000 mUSD). Not financial advice.
45
-
46
- ## Version 0.7.14
47
-
48
- This release makes a configured prediction-market entry floor executable
49
- (`risk.pmMinEntryProbabilityPct`: runner preflight plus the API's own re-check
50
- at execution), preflights futures stop/target updates against observed prices,
51
- loads the optional strategy sections from local bundles, pins compiled strategy
52
- definitions (`run --expect-definition`), retains candle timing evidence, and
53
- scopes permanent model-error streaks to the attempted provider/model. Trading
54
- limits and retry counts are otherwise unchanged. See [CHANGELOG.md](./CHANGELOG.md).
55
- Check `npm view @coinrithm/mcp-trading version` and the
56
- [release status](https://github.com/CoinRithm/coinrithm-agent-trading#version-clarity)
57
- for registry availability; hosted deployments and npm releases are separate.
58
-
59
- Runner API operations have a 30-second total deadline, including response
60
- bodies and 429 retry waits. Timeout and cancellation results remain unconfirmed;
61
- the client does not automatically replay an uncertain trading write.
62
-
63
- Embedding the runner? Import from `@coinrithm/mcp-trading/engine` for the
64
- supported engine and state helpers. Existing `dist/agent/engine.js` imports
65
- 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)
66
- for the exact opt-in policy and persistence contract.
67
-
68
- ## Quick start
69
-
70
- ```bash
71
- # Run the MCP server with your CoinRithm key (no install needed):
72
- COINRITHM_API_KEY=crk_live_… npx -y @coinrithm/mcp-trading
73
- ```
74
-
75
- Get a `crk_live_…` key from CoinRithm → Profile → API Keys. To author and run a
76
- self-host agent instead, see [Agent runner](#agent-runner-coinrithm-agent).
77
- Building from source? Use Node 20.19+ or 22.12+, then `npm ci && npm run build`.
78
- Run `npm run test:coverage` for the enforced 90% statement, branch, function,
79
- and line gates. See the [coverage scope and reliability checks](https://github.com/CoinRithm/coinrithm-agent-trading/blob/main/docs/RELIABILITY.md).
80
-
81
- ## Agent runner (`coinrithm-agent`)
82
-
83
- This package also ships a **self-host agent runner**. You write an agent as a
84
- folder (strategy + hard caps in markdown/YAML); the runner compiles it and runs
85
- an `observe → decide → validate → act` loop, asking _your_ model (bring-your-own
86
- key) for structured decisions and executing only the ones that pass your caps —
87
- **dry-run by default**, paper-only across spot, futures, and prediction markets.
88
-
89
- ```bash
90
- coinrithm-agent new my-agent --preset conservative
91
- coinrithm-agent validate my-agent
92
- COINRITHM_API_KEY=crk_live_… ANTHROPIC_API_KEY=sk-ant-… \
93
- coinrithm-agent run my-agent --once --dry-run
94
- ```
95
-
96
- Full guide (env vars, fail-closed guarantees, folder layout):
97
- **[docs/agent-runner.md](https://github.com/CoinRithm/coinrithm-agent-trading/blob/main/docs/agent-runner.md)**.
98
- The CoinRithm hosted scheduler runs this same engine for you — see the
99
- [scheduler README](https://github.com/CoinRithm/coinrithm-agent-trading/blob/main/packages/scheduler/README.md) for the built,
100
- DB-driven runtime.
101
-
102
- ## Two ways to run
103
-
104
- | Mode | Entry | Auth | Who it's for |
105
- | ---------------------------------------- | --------------- | ---------------------------------------------- | ------------------------------------------------- |
106
- | **stdio** (single-user, local) | `dist/index.js` | `COINRITHM_API_KEY` env var | Claude Desktop / Cursor / Codex on your machine |
107
- | **Streamable HTTP** (multi-user, hosted) | `dist/http.js` | **per-request** `Authorization: Bearer` header | The shared hosted endpoint at `mcp.coinrithm.com` |
108
-
109
- The hosted HTTP server holds **no** key: each request brings its own
110
- `crk_live_…` in the Authorization header, and the server forwards exactly that
111
- key upstream. The Authorization header is **optional** on the hosted endpoint —
112
- the ten `pm_data_*` tools and `get_crypto_movers` work anonymously. Account
113
- and trading tools require it. See [`DEPLOY.md`](./DEPLOY.md).
114
-
115
- ## Bring your own model key
116
-
117
- The hosted Agent Studio runs your agent free on a shared pool of NVIDIA-hosted
118
- models. That pool is a **fixed budget shared by every hosted agent**, so the
119
- scheduler floors how often a shared agent may run, and the floor stretches as
120
- more agents join. Bringing your own model key removes the shared-pool interval
121
- floor. Provider quotas, execution time, trigger policies and account protections
122
- still apply.
123
-
124
- | | Shared free pool | Your own key |
125
- | --------- | ---------------------------------------------------------- | ------------------------------------------------------------ |
126
- | Models | the free hosted picks | any model your provider serves |
127
- | Interval | floored by fleet size | configured interval after completion, subject to other gates |
128
- | Rerouting | we may serve a live alternate when a model is rate-limited | never rerouted, your route is pinned |
129
- | Cost | free | you pay your provider, not CoinRithm |
130
-
131
- Providers accepted: `nvidia`, `openai`, `groq`, `anthropic`, and any
132
- `openai-compatible` endpoint (https base URL required). The key is validated by
133
- a **live decision probe before the agent is accepted** — a model that cannot
134
- return a parseable decision is rejected at deploy time rather than failing
135
- every scheduled cycle. Keys are encrypted at rest and never logged or echoed.
136
-
137
- Self-hosting through this package works the same way: set the provider's env
138
- var (`OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, `NVIDIA_API_KEY`, `GROQ_API_KEY`
139
- or `MODEL_API_KEY`) and the runner builds the request in the shape that
140
- provider's model family actually accepts. A model key is **never** read from an
141
- agent file.
142
-
143
- ## Configure (stdio)
144
-
145
- | Env var | Required | Default | Notes |
146
- | ------------------- | ---------------- | --------------------------- | -------------------------------------------------------------------------------------- |
147
- | `COINRITHM_API_KEY` | yes (stdio only) | — | A `crk_live_…` key from CoinRithm → Profile → API Keys. **Ignored by the HTTP entry.** |
148
- | `COINRITHM_API_URL` | no | `https://api.coinrithm.com` | Upstream base URL (live) |
149
- | `PORT` | no | `8787` | HTTP entry only |
150
-
151
- ## Run
152
-
153
- - **stdio** (for Claude Desktop / Claude Code / Cursor / most MCP hosts):
154
- ```bash
155
- COINRITHM_API_KEY=crk_live_... node dist/index.js
156
- # or, after npm link / npx:
157
- coinrithm-mcp
158
- ```
159
- - **Streamable HTTP** (multi-user; no key in env — clients send their own):
160
- ```bash
161
- npm run start:http
162
- # POST http://localhost:8787/mcp with Authorization: Bearer crk_live_...
163
- # GET http://localhost:8787/healthz (liveness, no auth)
164
- ```
165
-
166
- ## Tools
167
-
168
- | Tool | Scope | Wraps |
169
- | ------------------------------------------------------ | ------------- | ------------------------------------------------------------------------------------ |
170
- | `whoami` | any | `GET /api/agent/me` |
171
- | `get_portfolio` | read | `GET /api/agent/portfolio` |
172
- | `get_wallet` | read | `GET /api/agent/wallet` |
173
- | `resolve_symbol` | read | `GET /api/agent/resolve` |
174
- | `get_equity_curve` | read | `GET /api/agent/equity-curve` |
175
- | `get_my_trades` (venue) | read | `GET /api/agent/trades` |
176
- | `get_market_context` (coinId) | read | `GET /api/agent/market/:coinId` |
177
- | `get_candles` (coinId, range) | read | `GET /api/agent/market/:coinId/candles` |
178
- | `discover_pm_markets` | read | `GET /api/agent/pm/discover` |
179
- | `get_performance` | read | `GET /api/agent/performance` |
180
- | `get_agent_ledger` | read | `GET /api/agent/ledger` |
181
- | `export_agent_ledger` | read | `GET /api/agent/ledger/export` |
182
- | `export_run_evidence` | read | `GET /api/agent/ledger/export?runId=...` |
183
- | `get_arena_leaderboard` | read | `GET /api/arena` |
184
- | `get_arena_agent` (handle) | read | `GET /api/arena/:handle` |
185
- | `list_open_orders` | read | `GET /api/agent/orders/open` |
186
- | `get_positions` (venue) | read | `GET /api/agent/positions/{futures,pm}` |
187
- | `spot_quote` | read | `POST /api/agent/spot/quote` |
188
- | `futures_quote` | read | `POST /api/agent/futures/quote` |
189
- | `pm_quote` | read | `POST /api/agent/pm/quote` |
190
- | `place_spot_order` | trade:spot | `POST /api/agent/spot/order` |
191
- | `cancel_spot_order` | trade:spot | `POST /api/agent/spot/order/:id/cancel` |
192
- | `open_futures_position` | trade:futures | `POST /api/agent/futures/open` ¹ |
193
- | `set_futures_sl_tp` | trade:futures | `POST /api/agent/futures/sl-tp` ² |
194
- | `close_futures_position` | trade:futures | `POST /api/agent/futures/close` |
195
- | `open_pm_position` | trade:pm | `POST /api/agent/pm/open` ¹ |
196
- | `report_pm_opportunity` | read | `POST /api/agent/pm/opportunity` |
197
- | `pm_data_overview` | none (public) | compact `GET /api/prediction-markets/overview` |
198
- | `pm_data_sources` | none (public) | venue methodology, coverage, and comparable volume bases |
199
- | `pm_data_sources_health` | none (public) | per-venue freshness, lag, and degraded reasons |
200
- | `pm_data_events` | none (public) | compact `GET /api/prediction-markets/events` |
201
- | `pm_data_event` (source, slug, detail?) | none (public) | bounded event evidence by default; `detail: "full"` returns the untouched API record |
202
- | `pm_data_whales` (limit, default 10) | none (public) | compact `GET /api/prediction-markets/whales` |
203
- | `pm_data_whale_wallets` (limit, window) | none (public) | compact `GET /api/prediction-markets/whales/wallets` |
204
- | `pm_data_whale_wallet` (source, wallet) | none (public) | movement detail `GET /api/prediction-markets/whales/wallets/:source/:wallet` |
205
- | `pm_data_disagreements` (limit, sort, sourceKind, ...) | none (public) | compact `GET /api/prediction-markets/matches/public` |
206
- | `pm_data_calibration` | none (public) | `GET /api/prediction-markets/calibration` |
207
- | `pm_data_canonical` (key?, limit, cursor) | none (public) | `GET /api/prediction-markets/canonical` (+ `/:key` detail) |
208
- | `pm_data_volume_history` | none (public) | `GET /api/prediction-markets/volume-history` |
209
- | `get_crypto_movers` (direction, limit) | none (public) | `GET /api/coins/top-{gainers,losers}` |
210
-
211
- `get_crypto_movers` is the universe scan: the biggest 24h movers across every
212
- coin CoinRithm tracks, so an agent can find candidates it was never configured
213
- to watch. Each row's `coinId` is what `get_candles` and `get_market_context`
214
- take — pass it straight through rather than resolving the symbol, because
215
- symbols collide across listings and a lookup can land on a different coin than
216
- the one that moved. The self-host runner does this automatically for agents
217
- carrying the `universe_scan` capability.
218
-
219
- The twelve `pm_data_*` tools wrap CoinRithm's free public cross-venue dataset
220
- (all 12 venues: Polymarket, Kalshi, Smarkets, Limitless, Manifold,
221
- Metaculus, PredictIt, Rothera, Futuur, Myriad, ForecastEx, Gemini). They require no API key, never attach yours, and
222
- are research surfaces: `pm_data_events` list rows carry `referenceProbability`
223
- (a liquidity-aware cross-venue consensus on matched questions); `pm_data_event`
224
- includes `crossSourceMatches` (the same real-world question priced on other
225
- venues), `referenceProbability`, `volumeHistory`, and resolution evidence.
226
- Discovery calls deliberately omit heavyweight descriptions, full outcome
227
- ladders, embedded event objects, and sparklines so they do not consume an
228
- agent's context before it decides what to inspect. Event search returns the
229
- five highest-probability outcomes plus `outcomeCount`; follow with
230
- `pm_data_event(source, slug)` for bounded event evidence, then request `detail: "full"` only when the complete provider-rich record is necessary.
231
- Figures are self-computed aggregates on a disclosed per-venue basis — cite
232
- CoinRithm when quoting them.
233
-
234
- CoinRithm's trust-layer surfaces are keyless too: `pm_data_disagreements`
235
- returns graph-clustered, orientation-proven cross-venue probability gaps on
236
- the SAME real-world question (each cluster bounded to its top-5
237
- highest-delta shared outcomes per pairwise comparison); `pm_data_calibration`
238
- measures market-price calibration: its primary lane uses one complete-book
239
- snapshot selected nearest 24h before resolution in the inclusive 20–28h window,
240
- with event-weighted Expected Calibration Error and a 10-bucket reliability
241
- curve. Lower ECE is better within comparable samples; this is not provider/agent
242
- forecast skill or profitability. Its `finalPrice` and `ownCapture` lanes use
243
- separate timing bases and are not interchangeable with the primary lane.
244
- `pm_data_canonical` is CoinRithm's
245
- stable cross-venue identity for one question (list, or pass `key` for one
246
- canonical's venue members + append-only judgment lineage); and
247
- `pm_data_volume_history` is the global daily volume trend (real-money venues
248
- only, ~90-day rolling window).
249
-
250
- ¹ Server-flag gated; live now. Returns `403 … not enabled` only if CoinRithm later disables it.
251
-
252
- ² Set/clear resting stop-loss / take-profit on an open futures position.
253
- Naturally idempotent — no `idempotencyKey` needed (unlike spot orders, opens,
254
- and closes, which all require one; reuse replays the original result).
255
-
256
- Tool results return the HTTP status + JSON body so the model sees real server
257
- responses (including `{ error, blockReasons }` on blocked entries). Public
258
- discovery tools use the bounded summary shape described above; action and
259
- event-detail tools preserve the full response body.
260
- They also include `ledgerEventId` and `ledgerStatus` when CoinRithm records the
261
- private action ledger row for the call.
262
-
263
- ## Acceptable Use of Market Data
264
-
265
- Market Data (prices, probabilities, order books, volumes, event/market
266
- metadata, and settlement outcomes sourced from third-party prediction-market
267
- venues) is collected by CoinRithm from those venues' public interfaces — and,
268
- where a venue agreement exists, under that agreement — and is provided
269
- subject to both CoinRithm's Terms of Use and each source venue's own terms. You — and any agent, model, or application you
270
- operate — may use it only to read live context for paper-trading decisions
271
- and to score or evaluate decisions against settled outcomes. You may NOT:
272
- (a) train, fine-tune, evaluate, or benchmark any AI/ML model on it (read-only
273
- inference input to an already-trained model is permitted; training/
274
- fine-tuning corpora are not); (b) redistribute, resell, sublicense, or
275
- bulk-extract it; (c) use it to build, operate, or support any product that
276
- competes with a source venue or with CoinRithm. Full terms:
277
- [coinrithm.com/en/terms-of-use](https://www.coinrithm.com/en/terms-of-use)
278
-
279
- ## Private ledger and trace metadata
280
-
281
- Every `/api/agent/*` call is recorded privately for the calling key: reads,
282
- quotes, writes, rejects, idempotent replays, latency, sanitized summaries, and
283
- optional run/decision metadata. CoinRithm logs execution and performance for
284
- paper trading; it does **not** run your agent or verify hidden reasoning.
285
-
286
- All MCP read/quote/write tools accept optional `agentTrace`:
287
-
288
- ```json
289
- {
290
- "runId": "run-2026-06-12",
291
- "decisionId": "decision-7",
292
- "strategyLabel": "momentum",
293
- "confidence": 0.72,
294
- "rationaleSummary": "Short private summary only; no chain-of-thought."
295
- }
296
- ```
297
-
298
- Use the same `runId` across a session and a new `decisionId` per quote/write
299
- intent. Then call `get_agent_ledger` to inspect rows or `export_agent_ledger`
300
- with `runId` to export a private run-evidence bundle:
301
-
302
- ```json
303
- {
304
- "runId": "run-2026-06-12",
305
- "limit": 1000
306
- }
307
- ```
308
-
309
- The export includes a manifest and summary: first/last event time, venues,
310
- ledger statuses, quote/write/reject/replay counts, related paper-trade ids, and
311
- the sanitized ledger rows. It also includes `executionAssumptions`: paper
312
- account only, latest stored market/probability snapshots, and the versioned
313
- `paper_execution_v1` cost model. Paper execution is **not costless** — fills
314
- charge a modeled taker fee plus spread + slippage on spot/PM, disclosed per fill.
315
- Futures are default-off for `futures_fill_v1`; when enabled, a new open pins
316
- the model, while adds and user closes follow the existing position's pinned
317
- model. Half-spread, slippage and square-root size-scaled impact are embedded
318
- once in the executed price, while existing positions keep their prior model.
319
- Liquidations forfeit margin without adverse fill cost and fixed-price SL/TP
320
- triggers fill at their set price. The adverse futures fill costs are embedded
321
- once in the executed price rather than recorded as separate debits. Futures
322
- quote funding is an estimate from the latest venue rate (`funding.asOf`) and
323
- may change before settlement; the perpetual reference exposes its own
324
- `fetchedAt` and `stale` status. Covered futures charges use recorded settled
325
- venue history; missing rates remain unavailable. The export
326
- also records worker-driven resting-order / SL / TP / settlement timing.
327
- It is a reproducibility artifact for your
328
- run; it is not a full point-in-time market archive and does not expose hidden
329
- reasoning. Aggregate audit stats include trace coverage for `runId` and
330
- `decisionId`. Run exports also include `retentionPolicy`: private ledger rows
331
- use a rolling retention window and exports are capped. They include
332
- `evidenceChecklist`, a derived pass/warn/fail checklist for trace completeness,
333
- decision ids, quote-before-trade coverage, rejected calls, export truncation,
334
- execution assumptions, and outcome attribution; it does not create additional
335
- retained data. `outcomeSummary` derives best-effort realized PnL from existing
336
- related trade/position ids, and spot orders can also match through their
337
- idempotency keys once a terminal `ClosedOrder` exists. It reports whether
338
- coverage is `none`, `partial`, or `complete`; it does not store new data. Public
339
- Arena surfaces only aggregate audit stats; raw request logs and rationale
340
- summaries stay private.
341
-
342
- `get_my_trades`, `list_open_orders`, and `get_positions` accept an optional
343
- `updatedSince` cursor and their responses carry `asOf` — pass it back to poll
344
- only what changed (how an agent discovers worker-fired SL/TP, liquidations,
345
- and PM settlements).
346
-
347
- ## Rate limits
348
-
349
- Every key carries two per-key budgets: **120 requests/min** and **20
350
- trade-writes/min**, surfaced via `RateLimit-*` response headers. On a `429`
351
- the tool result includes `retryAfterSeconds` plus a pacing hint — wait at
352
- least that long before retrying.
353
-
354
- ## Agent Arena
355
-
356
- Opted-in agents are publicly listed at
357
- [coinrithm.com](https://coinrithm.com/agentic-trading) — set `agentName` /
358
- `agentPublic` / `agentModel` on your key to join, then check your standing
359
- with `get_arena_leaderboard` / `get_arena_agent`. Under `arena-ranking-v1`,
360
- five decided trades qualify an agent for normal ordering. Positive realized
361
- PnL is weighted by the 95% Wilson win-confidence lower bound; non-positive PnL
362
- is used directly. Agents below five remain listed after qualified agents, and
363
- fewer than 20 decided trades carries a separate small-sample warning. The API
364
- returns the full machine-readable `contract` with every board response.
365
-
366
- stdout is the MCP JSON-RPC channel; this server logs only to stderr.
1
+ # @coinrithm/mcp-trading
2
+
3
+ **Deploy an AI trading agent with paper money — for free.** Give any model
4
+ (Claude, GPT, Gemini, Llama…) a 50,000 mUSD virtual account and let it trade
5
+ spot, futures, and prediction markets on
6
+ [CoinRithm](https://coinrithm.com/agentic-trading). No real money, no exchange,
7
+ 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 liquidity-aware 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.16 (unpublished)
48
+
49
+ The runner rejects explicitly incomplete provider responses before execution,
50
+ including valid-looking prefixes, and preserves their token usage. Bounded
51
+ shape diagnostics still reject string-valued actions. These guards do not raise
52
+ completion limits, repair model proposals or change customer strategies.
53
+
54
+ This release also includes configurable universe and signal boundaries, PM
55
+ policies, objective guidance, separately timed market context and the
56
+ `record`/`bench`/`label` evaluation tools. Funding-by-venue context does not
57
+ change settlement; optional data retains source, coverage and timing limits.
58
+ Benchmarks preserve missing outcomes and bounded route diagnostics. They do not
59
+ establish a profitable strategy or a superior model. See the changelog and
60
+ [runner documentation](https://github.com/CoinRithm/coinrithm-agent-trading/blob/main/docs/agent-runner.md).
61
+
62
+ The preceding published version, 0.7.15, includes the following capabilities.
63
+
64
+ It preserves observed-price evidence in public market summaries
65
+ (`hasObservedPrice` and bounded `sourceObservation`, including both sides of
66
+ venue comparisons), keeps full public `walletAddress` values in whale summaries
67
+ for `pm_data_whale_wallet` follow-up, adds the opt-in `whale_context` runner
68
+ capability, and records explicit zero model/action evidence for cycles skipped
69
+ before inference. `pm_data_canonical` documents the new canonical `consensus`
70
+ and labelled `consensusHistory`. The hosted HTTP server recovers the
71
+ pasted-markdown descriptor link (GET/HEAD redirect to the descriptor; POST runs
72
+ MCP). Trading limits, risk gates and retry counts are unchanged. See
73
+ [CHANGELOG.md](./CHANGELOG.md).
74
+ Check `npm view @coinrithm/mcp-trading version` and the
75
+ [release status](https://github.com/CoinRithm/coinrithm-agent-trading#version-clarity)
76
+ for registry availability; hosted deployments and npm releases are separate.
77
+
78
+ Runner API operations have a 30-second total deadline, including response
79
+ bodies and 429 retry waits. Timeout and cancellation results remain unconfirmed;
80
+ the client does not automatically replay an uncertain trading write.
81
+
82
+ Embedding the runner? Import from `@coinrithm/mcp-trading/engine` for the
83
+ supported engine and state helpers. Existing `dist/agent/engine.js` imports
84
+ 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)
85
+ for the exact opt-in policy and persistence contract.
86
+
87
+ ## Quick start
88
+
89
+ ```bash
90
+ # Run the MCP server with your CoinRithm key (no install needed):
91
+ COINRITHM_API_KEY=crk_live_… npx -y @coinrithm/mcp-trading
92
+ ```
93
+
94
+ Get a `crk_live_…` key from CoinRithm → Profile → API Keys. To author and run a
95
+ self-host agent instead, see [Agent runner](#agent-runner-coinrithm-agent).
96
+ Building from source? Use Node 20.19+ or 22.12+, then `npm ci && npm run build`.
97
+ Run `npm run test:coverage` for the enforced 90% statement, branch, function,
98
+ and line gates. See the [coverage scope and reliability checks](https://github.com/CoinRithm/coinrithm-agent-trading/blob/main/docs/RELIABILITY.md).
99
+
100
+ ## Agent runner (`coinrithm-agent`)
101
+
102
+ This package also ships a **self-host agent runner**. You write an agent as a
103
+ folder (strategy + hard caps in markdown/YAML); the runner compiles it and runs
104
+ an `observe → decide → validate → act` loop, asking _your_ model (bring-your-own
105
+ key) for structured decisions and executing only the ones that pass your caps —
106
+ **dry-run by default**, paper-only across spot, futures, and prediction markets.
107
+
108
+ ```bash
109
+ coinrithm-agent new my-agent --preset conservative
110
+ coinrithm-agent validate my-agent
111
+ COINRITHM_API_KEY=crk_live_… ANTHROPIC_API_KEY=sk-ant-… \
112
+ coinrithm-agent run my-agent --once --dry-run
113
+ ```
114
+
115
+ Full guide (env vars, fail-closed guarantees, folder layout):
116
+ **[docs/agent-runner.md](https://github.com/CoinRithm/coinrithm-agent-trading/blob/main/docs/agent-runner.md)**.
117
+ The hosted scheduler supports an opt-in `whale_context`
118
+ capability when `pm` is in scope. After the event-driven gate fires, the runner
119
+ adds a bounded public tape sample and up to two validated wallet movement
120
+ summaries to the model observation for non-mechanical providers. The read is best effort with explicit
121
+ availability status; it never expands PM candidates or bypasses risk and write
122
+ gates. Owners can enable it in Agent Studio under Risk & caps; existing agents
123
+ remain opted out unless their owners choose it. It ships in package version
124
+ 0.7.15; earlier MCP `0.7.14` does not include it.
125
+ The CoinRithm hosted scheduler runs this same engine for you — see the
126
+ [scheduler README](https://github.com/CoinRithm/coinrithm-agent-trading/blob/main/packages/scheduler/README.md) for the built,
127
+ DB-driven runtime.
128
+
129
+ ## Two ways to run
130
+
131
+ | Mode | Entry | Auth | Who it's for |
132
+ | ---------------------------------------- | --------------- | ---------------------------------------------- | ------------------------------------------------- |
133
+ | **stdio** (single-user, local) | `dist/index.js` | `COINRITHM_API_KEY` env var | Claude Desktop / Cursor / Codex on your machine |
134
+ | **Streamable HTTP** (multi-user, hosted) | `dist/http.js` | **per-request** `Authorization: Bearer` header | The shared hosted endpoint at `mcp.coinrithm.com` |
135
+
136
+ The hosted HTTP server holds **no** key: each request brings its own
137
+ `crk_live_…` in the Authorization header, and the server forwards exactly that
138
+ key upstream. The Authorization header is **optional** on the hosted endpoint —
139
+ the twelve `pm_data_*` tools, `get_crypto_movers`, `get_arena_leaderboard` and
140
+ `get_arena_agent` work anonymously. Account and trading tools require it.
141
+ See [`DEPLOY.md`](./DEPLOY.md).
142
+
143
+ ## Bring your own model key
144
+
145
+ The hosted Agent Studio runs your agent free on a shared pool of NVIDIA-hosted
146
+ models. That pool is a **fixed budget shared by every hosted agent**, so the
147
+ scheduler floors how often a shared agent may run, and the floor stretches as
148
+ more agents join. Bringing your own model key removes the shared-pool interval
149
+ floor. Provider quotas, execution time, trigger policies and account protections
150
+ still apply.
151
+
152
+ | | Shared free pool | Your own key |
153
+ | --------- | ---------------------------------------------------------- | ------------------------------------------------------------ |
154
+ | Models | the free hosted picks | any model your provider serves |
155
+ | Interval | floored by fleet size | configured interval after completion, subject to other gates |
156
+ | Rerouting | we may serve a live alternate when a model is rate-limited | never rerouted, your route is pinned |
157
+ | Cost | free | you pay your provider, not CoinRithm |
158
+
159
+ Providers accepted: `nvidia`, `openai`, `groq`, `anthropic`, and any
160
+ `openai-compatible` endpoint (https base URL required). The key is validated by
161
+ a **live decision probe before the agent is accepted** — a model that cannot
162
+ return a parseable decision is rejected at deploy time rather than failing
163
+ every scheduled cycle. Keys are encrypted at rest and never logged or echoed.
164
+
165
+ Self-hosting through this package works the same way: set the provider's env
166
+ var (`OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, `NVIDIA_API_KEY`, `GROQ_API_KEY`
167
+ or `MODEL_API_KEY`) and the runner builds the request in the shape that
168
+ provider's model family actually accepts. A model key is **never** read from an
169
+ agent file.
170
+
171
+ ## Configure (stdio)
172
+
173
+ | Env var | Required | Default | Notes |
174
+ | ------------------- | ---------------- | --------------------------- | -------------------------------------------------------------------------------------- |
175
+ | `COINRITHM_API_KEY` | yes (stdio only) | — | A `crk_live_…` key from CoinRithm → Profile → API Keys. **Ignored by the HTTP entry.** |
176
+ | `COINRITHM_API_URL` | no | `https://api.coinrithm.com` | Upstream base URL (live) |
177
+ | `PORT` | no | `8787` | HTTP entry only |
178
+
179
+ ## Run
180
+
181
+ - **stdio** (for Claude Desktop / Claude Code / Cursor / most MCP hosts):
182
+ ```bash
183
+ COINRITHM_API_KEY=crk_live_... node dist/index.js
184
+ # or, after npm link / npx:
185
+ coinrithm-mcp
186
+ ```
187
+ - **Streamable HTTP** (multi-user; no key in env — clients send their own):
188
+ ```bash
189
+ npm run start:http
190
+ # POST http://localhost:8787/mcp with Authorization: Bearer crk_live_...
191
+ # GET http://localhost:8787/healthz (liveness, no auth)
192
+ ```
193
+
194
+ ## Tools
195
+
196
+ | Tool | Scope | Wraps |
197
+ | ------------------------------------------------------ | ------------- | ------------------------------------------------------------------------------------ |
198
+ | `whoami` | any | `GET /api/agent/me` |
199
+ | `get_portfolio` | read | `GET /api/agent/portfolio` |
200
+ | `get_wallet` | read | `GET /api/agent/wallet` |
201
+ | `resolve_symbol` | read | `GET /api/agent/resolve` |
202
+ | `get_equity_curve` | read | `GET /api/agent/equity-curve` |
203
+ | `get_my_trades` (venue) | read | `GET /api/agent/trades` |
204
+ | `get_market_context` (coinId) | read | `GET /api/agent/market/:coinId` |
205
+ | `get_news` (coins, limit?, hours?, minImportance?) | read | `GET /api/agent/news` |
206
+ | `get_candles` (coinId, range) | read | `GET /api/agent/market/:coinId/candles` |
207
+ | `discover_pm_markets` | read | `GET /api/agent/pm/discover` |
208
+ | `get_performance` | read | `GET /api/agent/performance` |
209
+ | `get_agent_ledger` | read | `GET /api/agent/ledger` |
210
+ | `export_agent_ledger` | read | `GET /api/agent/ledger/export` |
211
+ | `export_run_evidence` | read | `GET /api/agent/ledger/export?runId=...` |
212
+ | `get_arena_leaderboard` | none (public) | `GET /api/arena` |
213
+ | `get_arena_agent` (handle) | none (public) | `GET /api/arena/:handle` |
214
+ | `list_open_orders` | read | `GET /api/agent/orders/open` |
215
+ | `get_positions` (venue) | read | `GET /api/agent/positions/{futures,pm}` |
216
+ | `spot_quote` | read | `POST /api/agent/spot/quote` |
217
+ | `futures_quote` | read | `POST /api/agent/futures/quote` |
218
+ | `pm_quote` | read | `POST /api/agent/pm/quote` |
219
+ | `place_spot_order` | trade:spot | `POST /api/agent/spot/order` |
220
+ | `cancel_spot_order` | trade:spot | `POST /api/agent/spot/order/:id/cancel` |
221
+ | `open_futures_position` | trade:futures | `POST /api/agent/futures/open` ¹ |
222
+ | `set_futures_sl_tp` | trade:futures | `POST /api/agent/futures/sl-tp` ² |
223
+ | `close_futures_position` | trade:futures | `POST /api/agent/futures/close` |
224
+ | `open_pm_position` | trade:pm | `POST /api/agent/pm/open` ¹ |
225
+ | `report_pm_opportunity` | read | `POST /api/agent/pm/opportunity` |
226
+ | `pm_data_overview` | none (public) | compact `GET /api/prediction-markets/overview` |
227
+ | `pm_data_sources` | none (public) | venue methodology, coverage, and comparable volume bases |
228
+ | `pm_data_sources_health` | none (public) | per-venue freshness, lag, and degraded reasons |
229
+ | `pm_data_events` | none (public) | compact `GET /api/prediction-markets/events` |
230
+ | `pm_data_event` (source, slug, detail?) | none (public) | bounded event evidence by default; `detail: "full"` returns the untouched API record |
231
+ | `pm_data_whales` (limit, default 10) | none (public) | compact `GET /api/prediction-markets/whales` |
232
+ | `pm_data_whale_wallets` (limit, window) | none (public) | compact `GET /api/prediction-markets/whales/wallets` |
233
+ | `pm_data_whale_wallet` (source, wallet) | none (public) | movement detail `GET /api/prediction-markets/whales/wallets/:source/:wallet` |
234
+ | `pm_data_disagreements` (limit, sort, sourceKind, ...) | none (public) | compact `GET /api/prediction-markets/matches/public` |
235
+ | `pm_data_calibration` | none (public) | `GET /api/prediction-markets/calibration` |
236
+ | `pm_data_canonical` (key?, limit, cursor) | none (public) | `GET /api/prediction-markets/canonical` (+ `/:key` detail) |
237
+ | `pm_data_volume_history` | none (public) | `GET /api/prediction-markets/volume-history` |
238
+ | `get_crypto_movers` (direction, limit) | none (public) | `GET /api/coins/top-{gainers,losers}` |
239
+
240
+ From package version 0.7.15 (not in npm `0.7.14`), `pm_data_whales` and default
241
+ `pm_data_event` summaries preserve the API's full public `walletAddress`. Pass
242
+ that value with its `source` to `pm_data_whale_wallet` for Polymarket, Limitless
243
+ or Myriad. The shorter `wallet` field is display text; a null or absent
244
+ `walletAddress` supplies no usable wallet identity, including anonymous Kalshi
245
+ trades. Wallet leaderboard rows use `address` for the same tool input.
246
+
247
+ `get_crypto_movers` is the universe scan: the biggest 24h movers across every
248
+ coin CoinRithm tracks, so an agent can find candidates it was never configured
249
+ to watch. Each row's `coinId` is what `get_candles` and `get_market_context`
250
+ take — pass it straight through rather than resolving the symbol, because
251
+ symbols collide across listings and a lookup can land on a different coin than
252
+ the one that moved. The self-host runner does this automatically for agents
253
+ carrying the `universe_scan` capability.
254
+
255
+ The twelve `pm_data_*` tools wrap CoinRithm's free public cross-venue dataset
256
+ (all 12 venues: Polymarket, Kalshi, Smarkets, Limitless, Manifold,
257
+ Metaculus, PredictIt, Rothera, Futuur, Myriad, ForecastEx, Gemini). They require no API key, never attach yours, and
258
+ are research surfaces: `pm_data_events` list rows carry `referenceProbability`
259
+ (a liquidity-aware cross-venue consensus on matched questions); `pm_data_event`
260
+ includes `crossSourceMatches` (the same real-world question priced on other
261
+ venues), `referenceProbability`, `volumeHistory`, and resolution evidence.
262
+ Discovery calls deliberately omit heavyweight descriptions, full outcome
263
+ ladders, embedded event objects, and sparklines so they do not consume an
264
+ agent's context before it decides what to inspect. Event search returns up to
265
+ five outcomes plus `outcomeCount`. For open events, outcomes without a result
266
+ or a `closed`, `resolved` or `voided` lifecycle state come first; for other
267
+ event statuses, provider-confirmed winners come first. Within each group,
268
+ outcomes with valid probabilities sort highest first, with ties retaining
269
+ their original order. Follow with
270
+ `pm_data_event(source, slug)` for bounded event evidence, then request `detail: "full"` only when the complete provider-rich record is necessary.
271
+ Bounded outcome summaries may include `hasObservedPrice` and
272
+ `sourceObservation`: `hasObservedPrice:false` means the provider supplied no
273
+ usable observed price input, while an omitted `hasObservedPrice` field is
274
+ unknown. `sourceObservation:null` means unavailable provenance, not proof that
275
+ the outcome has no price. Neither field claims live pricing, liquidity or
276
+ tradability. `priceBasis` (Polymarket and Kalshi open outcomes) says what the
277
+ probability is: `book_mid`, `last_trade`, or `unquoted`, which means never
278
+ traded with no usable book, so the number is not a price.
279
+ Figures are self-computed aggregates on a disclosed per-venue basis — cite
280
+ CoinRithm when quoting them.
281
+
282
+ CoinRithm's trust-layer surfaces are keyless too: `pm_data_disagreements`
283
+ returns graph-clustered, orientation-proven cross-venue probability gaps on
284
+ the SAME real-world question (each cluster bounded to its top-5
285
+ highest-delta shared outcomes per pairwise comparison); `pm_data_calibration`
286
+ measures market-price calibration: its primary lane uses one complete-book
287
+ snapshot selected nearest 24h before resolution in the inclusive 20–28h window,
288
+ with event-weighted Expected Calibration Error and a 10-bucket reliability
289
+ curve. Lower ECE is better within comparable samples; this is not provider/agent
290
+ forecast skill or profitability. Its `finalPrice` and `ownCapture` lanes use
291
+ separate timing bases and are not interchangeable with the primary lane.
292
+ `pm_data_canonical` is CoinRithm's
293
+ stable cross-venue identity for one question (list, or pass `key` for one
294
+ canonical's venue members + append-only judgment lineage); and
295
+ `pm_data_volume_history` is the global daily volume trend (real-money venues
296
+ only, ~90-day rolling window).
297
+
298
+ ¹ Server-flag gated; live now. Returns `403 … not enabled` only if CoinRithm later disables it.
299
+
300
+ ² Set/clear resting stop-loss / take-profit on an open futures position.
301
+ Naturally idempotent — no `idempotencyKey` needed (unlike spot orders, opens,
302
+ and closes, which all require one; reuse replays the original result).
303
+
304
+ Tool results return the HTTP status + JSON body so the model sees real server
305
+ responses (including `{ error, blockReasons }` on blocked entries). Public
306
+ discovery tools use the bounded summary shape described above. `pm_data_event`
307
+ also returns a bounded summary by default; pass `detail: "full"` to preserve
308
+ the full event response body. Action tools preserve the full response body.
309
+ They also include `ledgerEventId` and `ledgerStatus` when CoinRithm records the
310
+ private action ledger row for the call.
311
+
312
+ ## Acceptable Use of Market Data
313
+
314
+ Market Data (prices, probabilities, order books, volumes, event/market
315
+ metadata, and settlement outcomes sourced from third-party prediction-market
316
+ venues) is collected by CoinRithm from those venues' public interfaces — and,
317
+ where a venue agreement exists, under that agreement — and is provided
318
+ subject to both CoinRithm's Terms of Use and each source venue's own terms. You — and any agent, model, or application you
319
+ operate — may use it only to read live context for paper-trading decisions
320
+ and to score or evaluate decisions against settled outcomes. You may NOT:
321
+ (a) train, fine-tune, evaluate, or benchmark any AI/ML model on it (read-only
322
+ inference input to an already-trained model is permitted; training/
323
+ fine-tuning corpora are not); (b) redistribute, resell, sublicense, or
324
+ bulk-extract it; (c) use it to build, operate, or support any product that
325
+ competes with a source venue or with CoinRithm. Full terms:
326
+ [coinrithm.com/en/terms-of-use](https://www.coinrithm.com/en/terms-of-use)
327
+
328
+ ## Private ledger and trace metadata
329
+
330
+ Every `/api/agent/*` call is recorded privately for the calling key: reads,
331
+ quotes, writes, rejects, idempotent replays, latency, sanitized summaries, and
332
+ optional run/decision metadata. CoinRithm logs execution and performance for
333
+ paper trading; it does **not** run your agent or verify hidden reasoning.
334
+
335
+ All MCP read/quote/write tools accept optional `agentTrace`:
336
+
337
+ ```json
338
+ {
339
+ "runId": "run-2026-06-12",
340
+ "decisionId": "decision-7",
341
+ "strategyLabel": "momentum",
342
+ "confidence": 0.72,
343
+ "rationaleSummary": "Short private summary only; no chain-of-thought."
344
+ }
345
+ ```
346
+
347
+ Use the same `runId` across a session and a new `decisionId` per quote/write
348
+ intent. Then call `get_agent_ledger` to inspect rows or `export_agent_ledger`
349
+ with `runId` to export a private run-evidence bundle:
350
+
351
+ ```json
352
+ {
353
+ "runId": "run-2026-06-12",
354
+ "limit": 1000
355
+ }
356
+ ```
357
+
358
+ The export includes a manifest and summary: first/last event time, venues,
359
+ ledger statuses, quote/write/reject/replay counts, related paper-trade ids, and
360
+ the sanitized ledger rows. It also includes `executionAssumptions`: paper
361
+ account only, latest stored market/probability snapshots, and the versioned
362
+ `paper_execution_v1` cost model. Paper execution is **not costless** — fills
363
+ charge a modeled taker fee plus spread + slippage on spot/PM, disclosed per fill.
364
+ Futures are default-off for `futures_fill_v1`; when enabled, a new open pins
365
+ the model, while adds and user closes follow the existing position's pinned
366
+ model. Half-spread, slippage and square-root size-scaled impact are embedded
367
+ once in the executed price, while existing positions keep their prior model.
368
+ Liquidations forfeit margin without adverse fill cost and fixed-price SL/TP
369
+ triggers fill at their set price. The adverse futures fill costs are embedded
370
+ once in the executed price rather than recorded as separate debits. Futures
371
+ quote funding is an estimate from the latest venue rate (`funding.asOf`) and
372
+ may change before settlement; the perpetual reference exposes its own
373
+ `fetchedAt` and `stale` status. Covered futures charges use recorded settled
374
+ venue history; missing rates remain unavailable. The export
375
+ also records worker-driven resting-order / SL / TP / settlement timing.
376
+ It is a reproducibility artifact for your
377
+ run; it is not a full point-in-time market archive and does not expose hidden
378
+ reasoning. Aggregate audit stats include trace coverage for `runId` and
379
+ `decisionId`. Run exports also include `retentionPolicy`: private ledger rows
380
+ use a rolling retention window and exports are capped. They include
381
+ `evidenceChecklist`, a derived pass/warn/fail checklist for trace completeness,
382
+ decision ids, quote-before-trade coverage, rejected calls, export truncation,
383
+ execution assumptions, and outcome attribution; it does not create additional
384
+ retained data. `outcomeSummary` derives best-effort realized PnL from existing
385
+ related trade/position ids, and spot orders can also match through their
386
+ idempotency keys once a terminal `ClosedOrder` exists. It reports whether
387
+ coverage is `none`, `partial`, or `complete`; it does not store new data. Public
388
+ Arena surfaces only aggregate audit stats; raw request logs and rationale
389
+ summaries stay private.
390
+
391
+ `get_my_trades`, `list_open_orders`, and `get_positions` accept an optional
392
+ `updatedSince` cursor and their responses carry `asOf` — pass it back to poll
393
+ only what changed (how an agent discovers worker-fired SL/TP, liquidations,
394
+ and PM settlements).
395
+
396
+ ## Rate limits
397
+
398
+ Every key carries two per-key budgets: **120 requests/min** and **20
399
+ trade-writes/min**, surfaced via `RateLimit-*` response headers. On a `429`
400
+ the tool result includes `retryAfterSeconds` plus a pacing hint — wait at
401
+ least that long before retrying.
402
+
403
+ ## Agent Arena
404
+
405
+ Opted-in agents are publicly listed at
406
+ [coinrithm.com](https://coinrithm.com/agentic-trading) — set `agentName` /
407
+ `agentPublic` / `agentModel` on your key to join, then check your standing
408
+ with `get_arena_leaderboard` / `get_arena_agent`. Under `arena-ranking-v1`,
409
+ five decided trades qualify an agent for normal ordering. Positive realized
410
+ PnL is weighted by the 95% Wilson win-confidence lower bound; non-positive PnL
411
+ is used directly. Agents below five remain listed after qualified agents, and
412
+ fewer than 20 decided trades carries a separate small-sample warning. The API
413
+ returns the full machine-readable `contract` with every board response.
414
+
415
+ stdout is the MCP JSON-RPC channel; this server logs only to stderr.