@coinrithm/mcp-trading 0.5.0 → 0.7.0
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 +12 -0
- package/dist/client.d.ts +17 -0
- package/dist/client.js +56 -0
- package/dist/tools.js +111 -0
- package/package.json +78 -78
package/README.md
CHANGED
|
@@ -125,6 +125,18 @@ key upstream. See [`DEPLOY.md`](./DEPLOY.md).
|
|
|
125
125
|
| `set_futures_sl_tp` | trade:futures | `POST /api/agent/futures/sl-tp` ² |
|
|
126
126
|
| `close_futures_position` | trade:futures | `POST /api/agent/futures/close` |
|
|
127
127
|
| `open_pm_position` | trade:pm | `POST /api/agent/pm/open` ¹ |
|
|
128
|
+
| `pm_data_overview` | none (public) | `GET /api/prediction-markets/overview` |
|
|
129
|
+
| `pm_data_events` | none (public) | `GET /api/prediction-markets/events` |
|
|
130
|
+
| `pm_data_event` (source, slug) | none (public) | `GET /api/prediction-markets/events/:source/:slug` |
|
|
131
|
+
| `pm_data_whales` | none (public) | `GET /api/prediction-markets/whales` |
|
|
132
|
+
|
|
133
|
+
The four `pm_data_*` tools wrap CoinRithm's free public cross-venue dataset
|
|
134
|
+
(all seven venues: Polymarket, Kalshi, Metaculus, PredictIt, Limitless,
|
|
135
|
+
Manifold, Smarkets). They require no API key, never attach yours, and are
|
|
136
|
+
research surfaces: `pm_data_event` includes `crossSourceMatches` (the same
|
|
137
|
+
real-world question priced on other venues) and resolution evidence. Figures
|
|
138
|
+
are self-computed aggregates on a disclosed per-venue basis — cite CoinRithm
|
|
139
|
+
when quoting them.
|
|
128
140
|
|
|
129
141
|
¹ Server-flag gated; live now. Returns `403 … not enabled` only if CoinRithm later disables it.
|
|
130
142
|
|
package/dist/client.d.ts
CHANGED
|
@@ -29,6 +29,23 @@ export declare class CoinRithmClient {
|
|
|
29
29
|
private readonly baseUrl;
|
|
30
30
|
constructor(config: ClientConfig);
|
|
31
31
|
private request;
|
|
32
|
+
private publicRequest;
|
|
33
|
+
getPublicPmOverview(query?: {
|
|
34
|
+
fiat?: string;
|
|
35
|
+
}): Promise<ApiResult>;
|
|
36
|
+
listPublicPmEvents(query?: {
|
|
37
|
+
q?: string;
|
|
38
|
+
source?: string;
|
|
39
|
+
status?: string;
|
|
40
|
+
sort?: string;
|
|
41
|
+
limit?: number;
|
|
42
|
+
offset?: number;
|
|
43
|
+
fiat?: string;
|
|
44
|
+
}): Promise<ApiResult>;
|
|
45
|
+
getPublicPmEvent(source: string, slug: string, query?: {
|
|
46
|
+
fiat?: string;
|
|
47
|
+
}): Promise<ApiResult>;
|
|
48
|
+
getPublicPmWhales(): Promise<ApiResult>;
|
|
32
49
|
whoami(apiKey?: string, agentTrace?: AgentTrace): Promise<ApiResult>;
|
|
33
50
|
getPortfolio(query?: {
|
|
34
51
|
fiat?: string;
|
package/dist/client.js
CHANGED
|
@@ -157,6 +157,62 @@ export class CoinRithmClient {
|
|
|
157
157
|
data,
|
|
158
158
|
};
|
|
159
159
|
}
|
|
160
|
+
// Public, keyless GET against the free cross-venue data API
|
|
161
|
+
// (/api/prediction-markets/*). No Authorization header is ever attached:
|
|
162
|
+
// these endpoints require no key, and the caller's trading key must not
|
|
163
|
+
// leak into them. No ledger headers exist on this surface either.
|
|
164
|
+
async publicRequest(path, query) {
|
|
165
|
+
const url = new URL(this.baseUrl + path);
|
|
166
|
+
if (query) {
|
|
167
|
+
for (const [k, v] of Object.entries(query)) {
|
|
168
|
+
if (v !== undefined && v !== null && v !== "") {
|
|
169
|
+
url.searchParams.set(k, String(v));
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
let res;
|
|
174
|
+
try {
|
|
175
|
+
res = await fetch(url.toString(), {
|
|
176
|
+
method: "GET",
|
|
177
|
+
headers: { Accept: "application/json" },
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
catch (err) {
|
|
181
|
+
log(`network error calling GET ${path}:`, err);
|
|
182
|
+
return {
|
|
183
|
+
ok: false,
|
|
184
|
+
status: 0,
|
|
185
|
+
data: {
|
|
186
|
+
error: "network_error",
|
|
187
|
+
message: err instanceof Error ? err.message : String(err),
|
|
188
|
+
},
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
const text = await res.text();
|
|
192
|
+
let data = text;
|
|
193
|
+
if (text) {
|
|
194
|
+
try {
|
|
195
|
+
data = JSON.parse(text);
|
|
196
|
+
}
|
|
197
|
+
catch {
|
|
198
|
+
// leave as text
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return { ok: res.ok, status: res.status, data };
|
|
202
|
+
}
|
|
203
|
+
// ---- public PM data (no key required) ----
|
|
204
|
+
getPublicPmOverview(query) {
|
|
205
|
+
return this.publicRequest("/api/prediction-markets/overview", query);
|
|
206
|
+
}
|
|
207
|
+
listPublicPmEvents(query) {
|
|
208
|
+
return this.publicRequest("/api/prediction-markets/events", query);
|
|
209
|
+
}
|
|
210
|
+
getPublicPmEvent(source, slug, query) {
|
|
211
|
+
return this.publicRequest(`/api/prediction-markets/events/${encodeURIComponent(source)}/${encodeURIComponent(slug)}`, query);
|
|
212
|
+
}
|
|
213
|
+
getPublicPmWhales() {
|
|
214
|
+
return this.publicRequest("/api/prediction-markets/whales");
|
|
215
|
+
}
|
|
160
216
|
// Every method takes an optional trailing `apiKey` (the per-request key for
|
|
161
217
|
// the multi-user HTTP path). When omitted, the constructor key (stdio) is used.
|
|
162
218
|
// ---- reads (scope: read) ----
|
package/dist/tools.js
CHANGED
|
@@ -852,4 +852,115 @@ export function registerTools(server, client) {
|
|
|
852
852
|
idempotencyKey,
|
|
853
853
|
agentTrace,
|
|
854
854
|
}, requestKey(extra))));
|
|
855
|
+
// ---- Public cross-venue PM data (no API key required) ----
|
|
856
|
+
// These wrap the free /api/prediction-markets/* endpoints — CoinRithm's
|
|
857
|
+
// citable cross-venue dataset. They never attach the caller's key.
|
|
858
|
+
server.registerTool("pm_data_overview", {
|
|
859
|
+
title: "Cross-venue prediction-market statistics",
|
|
860
|
+
description: "Free public cross-venue prediction-market statistics: total/open/" +
|
|
861
|
+
"closed market counts, total volume, 24h volume, and liquidity " +
|
|
862
|
+
"aggregated across Polymarket, Kalshi, Metaculus, PredictIt, " +
|
|
863
|
+
"Limitless, Manifold, and Smarkets, plus market highlights. Volume is " +
|
|
864
|
+
"reported on each venue's own basis (see the methodology at " +
|
|
865
|
+
"https://coinrithm.com/en/prediction-markets/stats) and monetary " +
|
|
866
|
+
"totals cover real-money venues only — these are self-computed " +
|
|
867
|
+
"aggregates, so cite CoinRithm when quoting them. No API key required.",
|
|
868
|
+
inputSchema: {
|
|
869
|
+
fiat: z
|
|
870
|
+
.string()
|
|
871
|
+
.optional()
|
|
872
|
+
.describe("Fiat currency code for monetary figures (default usd)."),
|
|
873
|
+
},
|
|
874
|
+
outputSchema: API_RESULT_OUTPUT_SCHEMA,
|
|
875
|
+
annotations: readOnlyAnnotations("Cross-venue prediction-market statistics"),
|
|
876
|
+
}, async ({ fiat }) => present(await client.getPublicPmOverview({ fiat })));
|
|
877
|
+
server.registerTool("pm_data_events", {
|
|
878
|
+
title: "Search prediction markets across all venues",
|
|
879
|
+
description: "Free public search over prediction-market events across ALL seven " +
|
|
880
|
+
"venues (Polymarket, Kalshi, Metaculus, PredictIt, Limitless, " +
|
|
881
|
+
"Manifold, Smarkets) — broader than discover_pm_markets, which is " +
|
|
882
|
+
"scoped to the paper-tradeable venues. Returns titles, probabilities, " +
|
|
883
|
+
"volume/liquidity, status, and source per event. Research/data only: " +
|
|
884
|
+
"to trade, use discover_pm_markets + pm_quote instead. No API key " +
|
|
885
|
+
"required.",
|
|
886
|
+
inputSchema: {
|
|
887
|
+
q: z.string().optional().describe("Optional search text."),
|
|
888
|
+
source: z
|
|
889
|
+
.string()
|
|
890
|
+
.optional()
|
|
891
|
+
.describe("Optional venue filter: polymarket, kalshi, metaculus, predictit, " +
|
|
892
|
+
"limitless, manifold, or smarkets."),
|
|
893
|
+
status: z
|
|
894
|
+
.string()
|
|
895
|
+
.optional()
|
|
896
|
+
.describe("Optional status filter (e.g. open or closed)."),
|
|
897
|
+
sort: z.string().optional().describe("Optional sort key."),
|
|
898
|
+
limit: z
|
|
899
|
+
.number()
|
|
900
|
+
.int()
|
|
901
|
+
.min(1)
|
|
902
|
+
.max(50)
|
|
903
|
+
.optional()
|
|
904
|
+
.describe("Max rows (1-50, default 20)."),
|
|
905
|
+
offset: z
|
|
906
|
+
.number()
|
|
907
|
+
.int()
|
|
908
|
+
.min(0)
|
|
909
|
+
.optional()
|
|
910
|
+
.describe("Pagination offset (default 0)."),
|
|
911
|
+
fiat: z
|
|
912
|
+
.string()
|
|
913
|
+
.optional()
|
|
914
|
+
.describe("Fiat currency code for monetary figures (default usd)."),
|
|
915
|
+
},
|
|
916
|
+
outputSchema: API_RESULT_OUTPUT_SCHEMA,
|
|
917
|
+
annotations: readOnlyAnnotations("Search prediction markets across all venues"),
|
|
918
|
+
}, async ({ q, source, status, sort, limit, offset, fiat }) => present(await client.listPublicPmEvents({
|
|
919
|
+
q,
|
|
920
|
+
source,
|
|
921
|
+
status,
|
|
922
|
+
sort,
|
|
923
|
+
limit,
|
|
924
|
+
offset,
|
|
925
|
+
fiat,
|
|
926
|
+
})));
|
|
927
|
+
server.registerTool("pm_data_event", {
|
|
928
|
+
title: "Get full prediction-market event detail",
|
|
929
|
+
description: "Free public detail for one prediction-market event by venue + slug: " +
|
|
930
|
+
"outcomes with probabilities, price snapshots, resolution evidence, " +
|
|
931
|
+
"crossSourceMatches (the SAME real-world question priced on other " +
|
|
932
|
+
"venues — read probability divergence directly from it), " +
|
|
933
|
+
"referenceProbability when present (CoinRithm's canonical cross-venue " +
|
|
934
|
+
"number: the liquidity-weighted median Yes probability across matched " +
|
|
935
|
+
"real-money venues, with venueCount and spreadPoints — quote all " +
|
|
936
|
+
"three together, venues disagree and the spread says by how much), " +
|
|
937
|
+
"recent whale trades on the event, related events, and related news. " +
|
|
938
|
+
"This is the cross-venue research view; for tradability use pm_quote. " +
|
|
939
|
+
"No API key required.",
|
|
940
|
+
inputSchema: {
|
|
941
|
+
source: z
|
|
942
|
+
.string()
|
|
943
|
+
.describe("Venue slug: polymarket, kalshi, metaculus, predictit, limitless, " +
|
|
944
|
+
"manifold, or smarkets."),
|
|
945
|
+
slug: z.string().describe("Event slug on that venue."),
|
|
946
|
+
fiat: z
|
|
947
|
+
.string()
|
|
948
|
+
.optional()
|
|
949
|
+
.describe("Fiat currency code for monetary figures (default usd)."),
|
|
950
|
+
},
|
|
951
|
+
outputSchema: API_RESULT_OUTPUT_SCHEMA,
|
|
952
|
+
annotations: readOnlyAnnotations("Get full prediction-market event detail"),
|
|
953
|
+
}, async ({ source, slug, fiat }) => present(await client.getPublicPmEvent(source, slug, { fiat })));
|
|
954
|
+
server.registerTool("pm_data_whales", {
|
|
955
|
+
title: "Get latest prediction-market whale trades",
|
|
956
|
+
description: "Free public tape of the latest large prediction-market trades " +
|
|
957
|
+
"(roughly $1k+ notional) across venues, newest first (top 50): side, " +
|
|
958
|
+
"outcome, USD value, price, market question, and the event it printed " +
|
|
959
|
+
"on. Polymarket rows are wallet-attributed; Kalshi rows are anonymized " +
|
|
960
|
+
"exchange prints. A large print is information, not a recommendation. " +
|
|
961
|
+
"No API key required.",
|
|
962
|
+
inputSchema: {},
|
|
963
|
+
outputSchema: API_RESULT_OUTPUT_SCHEMA,
|
|
964
|
+
annotations: readOnlyAnnotations("Get latest prediction-market whale trades"),
|
|
965
|
+
}, async () => present(await client.getPublicPmWhales()));
|
|
855
966
|
}
|
package/package.json
CHANGED
|
@@ -1,78 +1,78 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@coinrithm/mcp-trading",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"mcpName": "io.github.CoinRithm/mcp-trading",
|
|
5
|
-
"description": "CoinRithm paper-trading toolkit: an MCP server (coinrithm-mcp) AND a self-host agent runner (coinrithm-agent) for spot, futures, and prediction markets with a user-minted API key.",
|
|
6
|
-
"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
|
-
"start": "node dist/index.js",
|
|
35
|
-
"start:http": "node dist/http.js",
|
|
36
|
-
"smoke:agent": "npm run build && node scripts/agent-smoke.mjs",
|
|
37
|
-
"prepare": "npm run build"
|
|
38
|
-
},
|
|
39
|
-
"engines": {
|
|
40
|
-
"node": ">=18"
|
|
41
|
-
},
|
|
42
|
-
"keywords": [
|
|
43
|
-
"mcp",
|
|
44
|
-
"mcp-server",
|
|
45
|
-
"model-context-protocol",
|
|
46
|
-
"ai-agent",
|
|
47
|
-
"agent-trading",
|
|
48
|
-
"trading",
|
|
49
|
-
"paper-trading",
|
|
50
|
-
"crypto",
|
|
51
|
-
"futures",
|
|
52
|
-
"prediction-markets",
|
|
53
|
-
"polymarket",
|
|
54
|
-
"kalshi",
|
|
55
|
-
"claude",
|
|
56
|
-
"chatgpt",
|
|
57
|
-
"gemini",
|
|
58
|
-
"cursor",
|
|
59
|
-
"open-knowledge-format",
|
|
60
|
-
"okf",
|
|
61
|
-
"model-agnostic",
|
|
62
|
-
"leaderboard",
|
|
63
|
-
"coinrithm"
|
|
64
|
-
],
|
|
65
|
-
"license": "MIT",
|
|
66
|
-
"dependencies": {
|
|
67
|
-
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
68
|
-
"express": "^4.21.0",
|
|
69
|
-
"yaml": "^2.5.0",
|
|
70
|
-
"zod": "^3.23.8"
|
|
71
|
-
},
|
|
72
|
-
"devDependencies": {
|
|
73
|
-
"@types/express": "^4.17.21",
|
|
74
|
-
"@types/node": "^20.14.0",
|
|
75
|
-
"typescript": "^5.5.0",
|
|
76
|
-
"vitest": "^2.1.0"
|
|
77
|
-
}
|
|
78
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@coinrithm/mcp-trading",
|
|
3
|
+
"version": "0.7.0",
|
|
4
|
+
"mcpName": "io.github.CoinRithm/mcp-trading",
|
|
5
|
+
"description": "CoinRithm paper-trading toolkit: an MCP server (coinrithm-mcp) AND a self-host agent runner (coinrithm-agent) for spot, futures, and prediction markets with a user-minted API key.",
|
|
6
|
+
"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
|
+
"start": "node dist/index.js",
|
|
35
|
+
"start:http": "node dist/http.js",
|
|
36
|
+
"smoke:agent": "npm run build && node scripts/agent-smoke.mjs",
|
|
37
|
+
"prepare": "npm run build"
|
|
38
|
+
},
|
|
39
|
+
"engines": {
|
|
40
|
+
"node": ">=18"
|
|
41
|
+
},
|
|
42
|
+
"keywords": [
|
|
43
|
+
"mcp",
|
|
44
|
+
"mcp-server",
|
|
45
|
+
"model-context-protocol",
|
|
46
|
+
"ai-agent",
|
|
47
|
+
"agent-trading",
|
|
48
|
+
"trading",
|
|
49
|
+
"paper-trading",
|
|
50
|
+
"crypto",
|
|
51
|
+
"futures",
|
|
52
|
+
"prediction-markets",
|
|
53
|
+
"polymarket",
|
|
54
|
+
"kalshi",
|
|
55
|
+
"claude",
|
|
56
|
+
"chatgpt",
|
|
57
|
+
"gemini",
|
|
58
|
+
"cursor",
|
|
59
|
+
"open-knowledge-format",
|
|
60
|
+
"okf",
|
|
61
|
+
"model-agnostic",
|
|
62
|
+
"leaderboard",
|
|
63
|
+
"coinrithm"
|
|
64
|
+
],
|
|
65
|
+
"license": "MIT",
|
|
66
|
+
"dependencies": {
|
|
67
|
+
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
68
|
+
"express": "^4.21.0",
|
|
69
|
+
"yaml": "^2.5.0",
|
|
70
|
+
"zod": "^3.23.8"
|
|
71
|
+
},
|
|
72
|
+
"devDependencies": {
|
|
73
|
+
"@types/express": "^4.17.21",
|
|
74
|
+
"@types/node": "^20.14.0",
|
|
75
|
+
"typescript": "^5.5.0",
|
|
76
|
+
"vitest": "^2.1.0"
|
|
77
|
+
}
|
|
78
|
+
}
|