coinopai-mcp 1.0.0 → 1.0.2
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/index.js +59 -18
- package/package.json +1 -2
package/index.js
CHANGED
|
@@ -5,13 +5,9 @@ const { Server } = require("@modelcontextprotocol/sdk/server/index.js");
|
|
|
5
5
|
const { StdioServerTransport } = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
6
6
|
const { CallToolRequestSchema, ListToolsRequestSchema } = require("@modelcontextprotocol/sdk/types.js");
|
|
7
7
|
const { x402Client, x402HTTPClient } = require("@x402/core/client");
|
|
8
|
-
const { ExactEvmScheme
|
|
8
|
+
const { ExactEvmScheme } = require("@x402/evm/exact/client");
|
|
9
9
|
const { toClientEvmSigner } = require("@x402/evm");
|
|
10
|
-
const { x402Facilitator } = require("@x402/core/facilitator");
|
|
11
|
-
const { createWalletClient, http, publicActions } = require("viem");
|
|
12
|
-
const { base } = require("viem/chains");
|
|
13
10
|
const { privateKeyToAccount } = require("viem/accounts");
|
|
14
|
-
const { facilitator: coinbaseFacilitator } = require("@coinbase/x402");
|
|
15
11
|
|
|
16
12
|
const BASE_URL = "https://x402.coinopai.com";
|
|
17
13
|
|
|
@@ -56,13 +52,35 @@ const TOOLS = [
|
|
|
56
52
|
},
|
|
57
53
|
{
|
|
58
54
|
name: "get_crypto_signal_history",
|
|
59
|
-
description: "Historical
|
|
55
|
+
description: "Historical 15-minute crypto signals from Kronos — up to 168 hours of BTC/ETH/SOL/XRP/ADA data. Costs $0.05 USDC.",
|
|
60
56
|
inputSchema: {
|
|
61
57
|
type: "object",
|
|
62
58
|
properties: {
|
|
63
59
|
hours: { type: "number", description: "Hours of history to fetch (default 24, max 168)" }
|
|
64
60
|
}
|
|
65
61
|
}
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: "get_crypto_decision",
|
|
65
|
+
description: "Interpreted trade decision from Kronos for a crypto symbol. Returns suggested_action (CONSIDER_LONG/CONSIDER_SHORT/NO_ACTION), confidence, regime, risk level, and conservative position guidance. Probabilistic — not financial advice. Costs $0.15 USDC.",
|
|
66
|
+
inputSchema: {
|
|
67
|
+
type: "object",
|
|
68
|
+
properties: {
|
|
69
|
+
symbol: { type: "string", description: "Symbol to evaluate: BTC, ETH, SOL, XRP, or ADA" }
|
|
70
|
+
},
|
|
71
|
+
required: ["symbol"]
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
name: "check_trade_preflight",
|
|
76
|
+
description: "Gate check before opening any position. Returns allowed:true/false, market state, cooldown status, signal strength, and warnings. Call this before executing any trade. Costs $0.05 USDC.",
|
|
77
|
+
inputSchema: {
|
|
78
|
+
type: "object",
|
|
79
|
+
properties: {
|
|
80
|
+
symbol: { type: "string", description: "Symbol to check: BTC, ETH, SOL, XRP, or ADA" }
|
|
81
|
+
},
|
|
82
|
+
required: ["symbol"]
|
|
83
|
+
}
|
|
66
84
|
}
|
|
67
85
|
];
|
|
68
86
|
|
|
@@ -72,21 +90,38 @@ function buildHttpClient() {
|
|
|
72
90
|
|
|
73
91
|
const pk = key.startsWith("0x") ? key : "0x" + key;
|
|
74
92
|
const account = privateKeyToAccount(pk);
|
|
75
|
-
const
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
const client = x402Client.from({ schemes: [registerExactEvmScheme(new ExactEvmScheme(), signer)] });
|
|
79
|
-
|
|
80
|
-
return new x402HTTPClient(client);
|
|
93
|
+
const signer = toClientEvmSigner(account);
|
|
94
|
+
const coreClient = new x402Client().register("eip155:*", new ExactEvmScheme(signer));
|
|
95
|
+
return new x402HTTPClient(coreClient);
|
|
81
96
|
}
|
|
82
97
|
|
|
83
98
|
async function call(httpClient, path) {
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
99
|
+
const url = BASE_URL + path;
|
|
100
|
+
const res = await fetch(url);
|
|
101
|
+
|
|
102
|
+
if (res.status === 402) {
|
|
103
|
+
let body;
|
|
104
|
+
try { body = await res.clone().json(); } catch (_) {}
|
|
105
|
+
const paymentRequired = httpClient.getPaymentRequiredResponse(
|
|
106
|
+
(name) => res.headers.get(name),
|
|
107
|
+
body
|
|
108
|
+
);
|
|
109
|
+
const paymentPayload = await httpClient.createPaymentPayload(paymentRequired);
|
|
110
|
+
const paidRes = await fetch(url, {
|
|
111
|
+
headers: httpClient.encodePaymentSignatureHeader(paymentPayload),
|
|
112
|
+
});
|
|
113
|
+
if (!paidRes.ok) {
|
|
114
|
+
const errBody = await paidRes.text().catch(() => paidRes.statusText);
|
|
115
|
+
throw new Error(`HTTP ${paidRes.status}: ${errBody.slice(0, 200)}`);
|
|
116
|
+
}
|
|
117
|
+
return paidRes.json();
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (!res.ok) {
|
|
121
|
+
const errBody = await res.text().catch(() => res.statusText);
|
|
122
|
+
throw new Error(`HTTP ${res.status}: ${errBody.slice(0, 200)}`);
|
|
88
123
|
}
|
|
89
|
-
return
|
|
124
|
+
return res.json();
|
|
90
125
|
}
|
|
91
126
|
|
|
92
127
|
async function main() {
|
|
@@ -99,7 +134,7 @@ async function main() {
|
|
|
99
134
|
}
|
|
100
135
|
|
|
101
136
|
const server = new Server(
|
|
102
|
-
{ name: "coinopai-mcp", version: "1.0.
|
|
137
|
+
{ name: "coinopai-mcp", version: "1.0.2" },
|
|
103
138
|
{ capabilities: { tools: {} } }
|
|
104
139
|
);
|
|
105
140
|
|
|
@@ -128,6 +163,12 @@ async function main() {
|
|
|
128
163
|
case "get_crypto_signal_history":
|
|
129
164
|
data = await call(httpClient, `/api/kronos/history?hours=${args.hours || 24}`);
|
|
130
165
|
break;
|
|
166
|
+
case "get_crypto_decision":
|
|
167
|
+
data = await call(httpClient, `/api/kronos/decision?symbol=${encodeURIComponent(args.symbol || "BTC")}`);
|
|
168
|
+
break;
|
|
169
|
+
case "check_trade_preflight":
|
|
170
|
+
data = await call(httpClient, `/api/kronos/preflight?symbol=${encodeURIComponent(args.symbol || "BTC")}`);
|
|
171
|
+
break;
|
|
131
172
|
default:
|
|
132
173
|
throw new Error("Unknown tool: " + name);
|
|
133
174
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "coinopai-mcp",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "MCP server for CoinOpAI — agent automation prompts and crypto signals via x402 micropayments on Base",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -37,7 +37,6 @@
|
|
|
37
37
|
},
|
|
38
38
|
"homepage": "https://x402.coinopai.com",
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@coinbase/x402": "^2.1.0",
|
|
41
40
|
"@modelcontextprotocol/sdk": "^1.10.1",
|
|
42
41
|
"@x402/core": "^2.11.0",
|
|
43
42
|
"@x402/evm": "^2.11.0",
|