@coinrithm/mcp-trading 0.7.15 → 0.7.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +885 -692
- package/README.md +486 -400
- package/dist/agent/bench/bench.d.ts +59 -0
- package/dist/agent/bench/bench.js +319 -0
- package/dist/agent/bench/cassette.d.ts +97 -0
- package/dist/agent/bench/cassette.js +181 -0
- package/dist/agent/bench/costs.d.ts +28 -0
- package/dist/agent/bench/costs.js +60 -0
- package/dist/agent/bench/labelBuilder.d.ts +123 -0
- package/dist/agent/bench/labelBuilder.js +282 -0
- package/dist/agent/bench/labels.d.ts +75 -0
- package/dist/agent/bench/labels.js +259 -0
- package/dist/agent/bench/recordingClient.d.ts +51 -0
- package/dist/agent/bench/recordingClient.js +193 -0
- package/dist/agent/bench/replayClient.d.ts +41 -0
- package/dist/agent/bench/replayClient.js +262 -0
- package/dist/agent/bench/report.d.ts +115 -0
- package/dist/agent/bench/report.js +435 -0
- package/dist/agent/capitalSizing.d.ts +10 -1
- package/dist/agent/capitalSizing.js +28 -4
- package/dist/agent/cli.d.ts +25 -0
- package/dist/agent/cli.js +300 -2
- package/dist/agent/client.d.ts +14 -0
- package/dist/agent/client.js +23 -6
- package/dist/agent/configurationWarnings.js +11 -0
- package/dist/agent/decision.d.ts +24 -16
- package/dist/agent/decision.js +92 -3
- package/dist/agent/decisionValidator.d.ts +31 -0
- package/dist/agent/decisionValidator.js +148 -3
- package/dist/agent/engine.d.ts +5 -3
- package/dist/agent/engine.js +5 -3
- package/dist/agent/futuresCloseOutcome.d.ts +19 -0
- package/dist/agent/futuresCloseOutcome.js +54 -0
- package/dist/agent/futuresEligibility.d.ts +13 -0
- package/dist/agent/futuresEligibility.js +43 -5
- package/dist/agent/observe.d.ts +28 -2
- package/dist/agent/observe.js +530 -90
- package/dist/agent/pmPaperCandidates.d.ts +17 -0
- package/dist/agent/pmPaperCandidates.js +125 -0
- package/dist/agent/pmPaperCycle.d.ts +16 -0
- package/dist/agent/pmPaperCycle.js +372 -0
- package/dist/agent/pmPaperDecision.d.ts +187 -0
- package/dist/agent/pmPaperDecision.js +101 -0
- package/dist/agent/pmPaperPolicy.d.ts +71 -0
- package/dist/agent/pmPaperPolicy.js +46 -0
- package/dist/agent/prompt.d.ts +15 -1
- package/dist/agent/prompt.js +187 -9
- package/dist/agent/promptTables.d.ts +1 -0
- package/dist/agent/promptTables.js +33 -0
- package/dist/agent/providerCapabilities.d.ts +7 -0
- package/dist/agent/providerCapabilities.js +27 -1
- package/dist/agent/providers.d.ts +26 -7
- package/dist/agent/providers.js +193 -48
- package/dist/agent/resolve.js +3 -0
- package/dist/agent/runner.d.ts +17 -1
- package/dist/agent/runner.js +210 -38
- package/dist/agent/setups.d.ts +2 -1
- package/dist/agent/setups.js +17 -16
- package/dist/agent/signals.d.ts +33 -0
- package/dist/agent/signals.js +89 -0
- package/dist/agent/skill.js +46 -0
- package/dist/agent/skillValidator.js +56 -0
- package/dist/agent/strictLint.js +30 -0
- package/dist/agent/templates.js +30 -30
- package/dist/agent/types.d.ts +180 -12
- package/dist/agent/universe.d.ts +78 -0
- package/dist/agent/universe.js +215 -0
- package/dist/agent/version.d.ts +1 -1
- package/dist/agent/version.js +1 -1
- package/dist/client.d.ts +14 -0
- package/dist/client.js +31 -1
- package/dist/http.js +1 -1
- package/dist/pmPaperV2.d.ts +81 -0
- package/dist/pmPaperV2.js +53 -0
- package/dist/tools.js +84 -6
- package/package.json +100 -97
package/dist/tools.js
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
//
|
|
3
|
-
// Every tool wraps exactly one /api/agent/* call. Tool results return the raw
|
|
4
|
-
// JSON body as text so the model sees the real server response (incl. error
|
|
5
|
-
// shapes like { error, blockReasons }). HTTP-level failures are surfaced as
|
|
6
|
-
// isError results rather than thrown so the model can react.
|
|
1
|
+
import { pmPaperAgentOpenSchema, pmPaperCloseSchema } from "./pmPaperV2.js";
|
|
7
2
|
import { z } from "zod";
|
|
8
3
|
import { bearerFromHeader } from "./client.js";
|
|
9
4
|
import { PAPER_EXECUTION_VERSION } from "./executionPolicy.js";
|
|
@@ -725,6 +720,32 @@ function mapSuccessfulBody(result, transform) {
|
|
|
725
720
|
return result.ok ? { ...result, data: transform(result.data) } : result;
|
|
726
721
|
}
|
|
727
722
|
export function registerTools(server, client) {
|
|
723
|
+
// Separate opt-in inventory: never enrich existing market context or prompts.
|
|
724
|
+
if (process.env.COINRITHM_SPOT_REFERENCE_TOOLS_ENABLED === "true") {
|
|
725
|
+
server.registerTool("get_spot_reference", {
|
|
726
|
+
title: "Get optional spot reference",
|
|
727
|
+
description: "Read a separate Binance spot last-ticker reference and stored REST " +
|
|
728
|
+
"consensus fallback for one coinId (read scope). Reference only: " +
|
|
729
|
+
"stream price and rolling 24h quote volume are USDT; fallback price " +
|
|
730
|
+
"is USD, with no currency conversion. A 200 response can contain " +
|
|
731
|
+
"an unavailable stream or stale/unavailable fallback: inspect each " +
|
|
732
|
+
"status, reason and expiresAt. preferredSource does not establish " +
|
|
733
|
+
"freshness or execution eligibility. eventAt is emission, " +
|
|
734
|
+
"statisticsCloseAt is the ticker window close, receivedAt is " +
|
|
735
|
+
"acquisition and localPriceChangedAt is a local observation; " +
|
|
736
|
+
"lastTradeAt is unknown. This is not an executable quote, order-book " +
|
|
737
|
+
"depth or fill guarantee and does not replace get_market_context.",
|
|
738
|
+
inputSchema: {
|
|
739
|
+
coinId: z
|
|
740
|
+
.string()
|
|
741
|
+
.regex(/^[a-zA-Z0-9_-]{1,64}$/)
|
|
742
|
+
.describe("CoinRithm coinId from resolve_symbol; not an exchange pair."),
|
|
743
|
+
agentTrace: AGENT_TRACE_SCHEMA,
|
|
744
|
+
},
|
|
745
|
+
outputSchema: API_RESULT_OUTPUT_SCHEMA,
|
|
746
|
+
annotations: readOnlyAnnotations("Get optional spot reference"),
|
|
747
|
+
}, async ({ coinId, agentTrace }, extra) => present(await client.getSpotReference(coinId, requestKey(extra), agentTrace)));
|
|
748
|
+
}
|
|
728
749
|
// ---------------- identity ----------------
|
|
729
750
|
server.registerTool("whoami", {
|
|
730
751
|
title: "Who am I (CoinRithm)",
|
|
@@ -1571,6 +1592,63 @@ export function registerTools(server, client) {
|
|
|
1571
1592
|
provenance,
|
|
1572
1593
|
agentTrace,
|
|
1573
1594
|
}, requestKey(extra))));
|
|
1595
|
+
if (process.env.COINRITHM_PM_PAPER_V2_TOOLS_ENABLED === "true") {
|
|
1596
|
+
server.registerTool("discover_pm_paper_v2_markets", {
|
|
1597
|
+
title: "Discover PM paper v2 candidates",
|
|
1598
|
+
description: "For server-configured PM paper v2 house keys only (other keys get 403 house_opt_in_required). Returns Kalshi/Polymarket outcomes with exact stored native identity (nativeMarket.key) and scheduled native end, filtered to the house's configured horizon; meta.boundedSelection reports how many were excluded and why. Candidate evidence only: open_pm_paper_v2 reacquires native identity, maturity, book and fees, and may still refuse. nativeEndAt is a scheduled end, not a settlement-time guarantee. " +
|
|
1599
|
+
PAPER_NOTE_SHORT,
|
|
1600
|
+
inputSchema: {
|
|
1601
|
+
q: z
|
|
1602
|
+
.string()
|
|
1603
|
+
.max(100)
|
|
1604
|
+
.optional()
|
|
1605
|
+
.describe("Optional search text (title, outcome, topic)."),
|
|
1606
|
+
limit: z
|
|
1607
|
+
.number()
|
|
1608
|
+
.int()
|
|
1609
|
+
.min(1)
|
|
1610
|
+
.max(50)
|
|
1611
|
+
.optional()
|
|
1612
|
+
.describe("Max events before filtering (1-50, default 20)."),
|
|
1613
|
+
agentTrace: AGENT_TRACE_SCHEMA,
|
|
1614
|
+
},
|
|
1615
|
+
outputSchema: API_RESULT_OUTPUT_SCHEMA,
|
|
1616
|
+
annotations: readOnlyAnnotations("Discover PM paper v2 candidates"),
|
|
1617
|
+
}, async ({ q, limit, agentTrace }, extra) => present(await client.discoverPmPaperV2({ q, limit }, requestKey(extra), agentTrace)));
|
|
1618
|
+
server.registerTool("open_pm_paper_v2", {
|
|
1619
|
+
title: "Open opted-in PM paper position",
|
|
1620
|
+
description: "For server-configured PM paper v2 house keys only. Opens against freshly acquired native Kalshi/Polymarket depth. maxCashBudget is an explicit exact decimal TOTAL cash budget including fees, not legacy stakeMusd. forecastProbability is required: the chance the side you buy pays out (percent above 1 and below 100, or a fraction above 0 and below 1; exactly 1 is refused as ambiguous); the API refuses an open whose forecast does not exceed the fee-inclusive cost per share. Server admission defaults off. Reuse the identical pm-entry key and body after uncertain delivery. Existing legacy tools keep their behavior. " +
|
|
1621
|
+
PAPER_NOTE_SHORT,
|
|
1622
|
+
inputSchema: pmPaperAgentOpenSchema.shape,
|
|
1623
|
+
outputSchema: API_RESULT_OUTPUT_SCHEMA,
|
|
1624
|
+
annotations: mutatingAnnotations("Open opted-in PM paper position", {
|
|
1625
|
+
idempotent: true,
|
|
1626
|
+
}),
|
|
1627
|
+
}, async (body, extra) => present(await client.openPmPaperV2(pmPaperAgentOpenSchema.parse(body), requestKey(extra))));
|
|
1628
|
+
server.registerTool("close_pm_paper_v2", {
|
|
1629
|
+
title: "Request full PM paper exit",
|
|
1630
|
+
description: "Request a durable FULL exit for an owned PM paper v2 position. A 202 accepted response is pending, NOT an executed sale or final PnL. Native depth and settlement can leave an exit pending or requiring attention. Reuse the identical pm-exit key/body to reconcile; only executed:true confirms completion. Entry pauses do not stop existing exits. " +
|
|
1631
|
+
PAPER_NOTE_SHORT,
|
|
1632
|
+
inputSchema: pmPaperCloseSchema.shape,
|
|
1633
|
+
outputSchema: API_RESULT_OUTPUT_SCHEMA,
|
|
1634
|
+
annotations: mutatingAnnotations("Request full PM paper exit", {
|
|
1635
|
+
destructive: true,
|
|
1636
|
+
idempotent: true,
|
|
1637
|
+
}),
|
|
1638
|
+
}, async (body, extra) => present(await client.closePmPaperV2(pmPaperCloseSchema.parse(body), requestKey(extra))));
|
|
1639
|
+
server.registerTool("get_pm_paper_v2_positions", {
|
|
1640
|
+
title: "Read PM paper v2 positions and exit receipts",
|
|
1641
|
+
description: "Read the caller's bounded PM paper v2 positions, persisted exit intents and terminal accounting receipts. Pending/leased/retry/manual_attention do not establish execution or final PnL. " +
|
|
1642
|
+
PAPER_NOTE_SHORT,
|
|
1643
|
+
inputSchema: {
|
|
1644
|
+
status: z.literal("open").optional(),
|
|
1645
|
+
beforeId: z.number().int().positive().max(2147483647).optional(),
|
|
1646
|
+
limit: z.number().int().min(1).max(50).optional(),
|
|
1647
|
+
},
|
|
1648
|
+
outputSchema: API_RESULT_OUTPUT_SCHEMA,
|
|
1649
|
+
annotations: readOnlyAnnotations("Read PM paper v2 positions"),
|
|
1650
|
+
}, async (query, extra) => present(await client.pmPaperV2Positions(requestKey(extra), query)));
|
|
1651
|
+
}
|
|
1574
1652
|
server.registerTool("report_pm_opportunity", {
|
|
1575
1653
|
title: "Report a non-opened PM opportunity",
|
|
1576
1654
|
description: "Save a durable SELF-REPORT of a prediction-market evaluation for a " +
|
package/package.json
CHANGED
|
@@ -1,97 +1,100 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@coinrithm/mcp-trading",
|
|
3
|
-
"version": "0.7.
|
|
4
|
-
"mcpName": "io.github.CoinRithm/mcp-trading",
|
|
5
|
-
"description": "CoinRithm
|
|
6
|
-
"type": "module",
|
|
7
|
-
"author": "CoinRithm",
|
|
8
|
-
"homepage": "https://coinrithm.com/agentic-trading",
|
|
9
|
-
"repository": {
|
|
10
|
-
"type": "git",
|
|
11
|
-
"url": "git+https://github.com/CoinRithm/coinrithm-agent-trading.git",
|
|
12
|
-
"directory": "packages/mcp-trading"
|
|
13
|
-
},
|
|
14
|
-
"bugs": {
|
|
15
|
-
"url": "https://github.com/CoinRithm/coinrithm-agent-trading/issues"
|
|
16
|
-
},
|
|
17
|
-
"publishConfig": {
|
|
18
|
-
"access": "public"
|
|
19
|
-
},
|
|
20
|
-
"bin": {
|
|
21
|
-
"coinrithm-mcp": "dist/index.js",
|
|
22
|
-
"coinrithm-agent": "dist/agent/index.js"
|
|
23
|
-
},
|
|
24
|
-
"main": "dist/index.js",
|
|
25
|
-
"files": [
|
|
26
|
-
"dist",
|
|
27
|
-
"README.md",
|
|
28
|
-
"CHANGELOG.md"
|
|
29
|
-
],
|
|
30
|
-
"scripts": {
|
|
31
|
-
"build": "tsc -p tsconfig.json",
|
|
32
|
-
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
33
|
-
"test": "vitest run",
|
|
34
|
-
"test:coverage": "vitest run --coverage",
|
|
35
|
-
"lint": "eslint src",
|
|
36
|
-
"lint:fix": "eslint src --fix",
|
|
37
|
-
"format": "prettier --write \"src/**/*.ts\"",
|
|
38
|
-
"format:check": "prettier --check \"src/**/*.ts\"",
|
|
39
|
-
"start": "node dist/index.js",
|
|
40
|
-
"start:http": "node dist/http.js",
|
|
41
|
-
"smoke:agent": "npm run build && node scripts/agent-smoke.mjs",
|
|
42
|
-
"prepare": "npm run build"
|
|
43
|
-
},
|
|
44
|
-
"engines": {
|
|
45
|
-
"node": ">=18"
|
|
46
|
-
},
|
|
47
|
-
"keywords": [
|
|
48
|
-
"mcp",
|
|
49
|
-
"mcp-server",
|
|
50
|
-
"model-context-protocol",
|
|
51
|
-
"ai-agent",
|
|
52
|
-
"agent-trading",
|
|
53
|
-
"trading",
|
|
54
|
-
"paper-trading",
|
|
55
|
-
"crypto",
|
|
56
|
-
"futures",
|
|
57
|
-
"prediction-markets",
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
"
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
"@
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
"
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@coinrithm/mcp-trading",
|
|
3
|
+
"version": "0.7.17",
|
|
4
|
+
"mcpName": "io.github.CoinRithm/mcp-trading",
|
|
5
|
+
"description": "CoinRithm MCP server (coinrithm-mcp) and self-host agent runner (coinrithm-agent): keyless prediction-market data across 12 venues, plus paper trading of crypto spot, futures, and prediction markets with a user-minted API key.",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"author": "CoinRithm",
|
|
8
|
+
"homepage": "https://coinrithm.com/agentic-trading",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/CoinRithm/coinrithm-agent-trading.git",
|
|
12
|
+
"directory": "packages/mcp-trading"
|
|
13
|
+
},
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/CoinRithm/coinrithm-agent-trading/issues"
|
|
16
|
+
},
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public"
|
|
19
|
+
},
|
|
20
|
+
"bin": {
|
|
21
|
+
"coinrithm-mcp": "dist/index.js",
|
|
22
|
+
"coinrithm-agent": "dist/agent/index.js"
|
|
23
|
+
},
|
|
24
|
+
"main": "dist/index.js",
|
|
25
|
+
"files": [
|
|
26
|
+
"dist",
|
|
27
|
+
"README.md",
|
|
28
|
+
"CHANGELOG.md"
|
|
29
|
+
],
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "tsc -p tsconfig.json",
|
|
32
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
33
|
+
"test": "vitest run",
|
|
34
|
+
"test:coverage": "vitest run --coverage",
|
|
35
|
+
"lint": "eslint src",
|
|
36
|
+
"lint:fix": "eslint src --fix",
|
|
37
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
38
|
+
"format:check": "prettier --check \"src/**/*.ts\"",
|
|
39
|
+
"start": "node dist/index.js",
|
|
40
|
+
"start:http": "node dist/http.js",
|
|
41
|
+
"smoke:agent": "npm run build && node scripts/agent-smoke.mjs",
|
|
42
|
+
"prepare": "npm run build"
|
|
43
|
+
},
|
|
44
|
+
"engines": {
|
|
45
|
+
"node": ">=18"
|
|
46
|
+
},
|
|
47
|
+
"keywords": [
|
|
48
|
+
"mcp",
|
|
49
|
+
"mcp-server",
|
|
50
|
+
"model-context-protocol",
|
|
51
|
+
"ai-agent",
|
|
52
|
+
"agent-trading",
|
|
53
|
+
"trading",
|
|
54
|
+
"paper-trading",
|
|
55
|
+
"crypto",
|
|
56
|
+
"futures",
|
|
57
|
+
"prediction-markets",
|
|
58
|
+
"prediction-market-data",
|
|
59
|
+
"market-data",
|
|
60
|
+
"polymarket",
|
|
61
|
+
"kalshi",
|
|
62
|
+
"claude",
|
|
63
|
+
"chatgpt",
|
|
64
|
+
"gemini",
|
|
65
|
+
"cursor",
|
|
66
|
+
"open-knowledge-format",
|
|
67
|
+
"okf",
|
|
68
|
+
"model-agnostic",
|
|
69
|
+
"leaderboard",
|
|
70
|
+
"coinrithm"
|
|
71
|
+
],
|
|
72
|
+
"license": "MIT",
|
|
73
|
+
"dependencies": {
|
|
74
|
+
"@modelcontextprotocol/sdk": "^1.31.0",
|
|
75
|
+
"express": "^4.21.0",
|
|
76
|
+
"json5": "2.2.3",
|
|
77
|
+
"yaml": "^2.5.0",
|
|
78
|
+
"zod": "^3.23.8"
|
|
79
|
+
},
|
|
80
|
+
"devDependencies": {
|
|
81
|
+
"@eslint/js": "^9.13.0",
|
|
82
|
+
"@types/express": "^4.17.21",
|
|
83
|
+
"@types/node": "^20.14.0",
|
|
84
|
+
"@vitest/coverage-v8": "4.1.11",
|
|
85
|
+
"eslint": "^9.13.0",
|
|
86
|
+
"prettier": "^3.3.3",
|
|
87
|
+
"typescript": "^5.5.0",
|
|
88
|
+
"typescript-eslint": "^8.11.0",
|
|
89
|
+
"vitest": "4.1.11"
|
|
90
|
+
},
|
|
91
|
+
"exports": {
|
|
92
|
+
".": "./dist/index.js",
|
|
93
|
+
"./engine": {
|
|
94
|
+
"types": "./dist/agent/engine.d.ts",
|
|
95
|
+
"import": "./dist/agent/engine.js"
|
|
96
|
+
},
|
|
97
|
+
"./package.json": "./package.json",
|
|
98
|
+
"./dist/*": "./dist/*"
|
|
99
|
+
}
|
|
100
|
+
}
|