@dritan/mcp 0.3.1 → 0.4.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 +1 -0
- package/dist/index.js +70 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -75,6 +75,7 @@ npm run build && npm start
|
|
|
75
75
|
- Private keys never leave local files; only public address/signature are returned.
|
|
76
76
|
- `swap_sign_and_broadcast` signs locally, then broadcasts via Dritan.
|
|
77
77
|
- `token_get_ohlcv_chart` returns a shareable chart URL plus a ready-to-send markdown image snippet.
|
|
78
|
+
- `token_get_ohlcv_chart` supports `chartType: "line-volume" | "candlestick"` (default is `line-volume`).
|
|
78
79
|
- Ticker workflow for chart requests: `token_search` -> extract mint -> `token_get_ohlcv` or `token_get_ohlcv_chart`.
|
|
79
80
|
- If users ask for `$WIF` style symbols, always resolve mint with `token_search` first.
|
|
80
81
|
- If Solana CLI is missing, run `system_check_prereqs` and follow returned install steps.
|
package/dist/index.js
CHANGED
|
@@ -117,7 +117,7 @@ function formatChartLabel(ts) {
|
|
|
117
117
|
return String(ts);
|
|
118
118
|
return date.toISOString().replace("T", " ").slice(0, 16);
|
|
119
119
|
}
|
|
120
|
-
function
|
|
120
|
+
function buildLineVolumeOhlcvChartUrl(mint, timeframe, bars, width, height) {
|
|
121
121
|
const labels = bars.map((bar) => formatChartLabel(bar.time));
|
|
122
122
|
const closeSeries = bars.map((bar) => Number(bar.close.toFixed(12)));
|
|
123
123
|
const volumeSeries = bars.map((bar) => Number(bar.volume.toFixed(12)));
|
|
@@ -166,6 +166,66 @@ function buildOhlcvChartUrl(mint, timeframe, bars, width, height) {
|
|
|
166
166
|
// so pinning `v=4` prevents runtime render errors like "Cannot read properties of undefined (reading 'options')".
|
|
167
167
|
return `https://quickchart.io/chart?w=${width}&h=${height}&f=png&v=4&c=${encoded}`;
|
|
168
168
|
}
|
|
169
|
+
function buildCandlestickOhlcvChartUrl(mint, timeframe, bars, width, height) {
|
|
170
|
+
const labels = bars.map((bar) => formatChartLabel(bar.time));
|
|
171
|
+
const candles = bars.map((bar, index) => ({
|
|
172
|
+
x: labels[index],
|
|
173
|
+
o: Number(bar.open.toFixed(12)),
|
|
174
|
+
h: Number(bar.high.toFixed(12)),
|
|
175
|
+
l: Number(bar.low.toFixed(12)),
|
|
176
|
+
c: Number(bar.close.toFixed(12)),
|
|
177
|
+
}));
|
|
178
|
+
const volumeSeries = bars.map((bar) => Number(bar.volume.toFixed(12)));
|
|
179
|
+
const volumeColors = bars.map((bar) => bar.close >= bar.open ? "rgba(16,185,129,0.25)" : "rgba(239,68,68,0.25)");
|
|
180
|
+
const config = {
|
|
181
|
+
type: "candlestick",
|
|
182
|
+
data: {
|
|
183
|
+
labels,
|
|
184
|
+
datasets: [
|
|
185
|
+
{
|
|
186
|
+
label: "OHLC",
|
|
187
|
+
data: candles,
|
|
188
|
+
color: {
|
|
189
|
+
up: "#10b981",
|
|
190
|
+
down: "#ef4444",
|
|
191
|
+
unchanged: "#94a3b8",
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
type: "bar",
|
|
196
|
+
label: "Volume",
|
|
197
|
+
data: volumeSeries,
|
|
198
|
+
backgroundColor: volumeColors,
|
|
199
|
+
borderWidth: 0,
|
|
200
|
+
yAxisID: "volume",
|
|
201
|
+
},
|
|
202
|
+
],
|
|
203
|
+
},
|
|
204
|
+
options: {
|
|
205
|
+
plugins: {
|
|
206
|
+
legend: { display: true },
|
|
207
|
+
title: {
|
|
208
|
+
display: true,
|
|
209
|
+
text: `${mint} ${timeframe.toUpperCase()} Candlestick`,
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
scales: {
|
|
213
|
+
x: { type: "category" },
|
|
214
|
+
y: { type: "linear", position: "left" },
|
|
215
|
+
volume: { type: "linear", position: "right", grid: { drawOnChartArea: false } },
|
|
216
|
+
},
|
|
217
|
+
},
|
|
218
|
+
};
|
|
219
|
+
const encoded = encodeURIComponent(JSON.stringify(config));
|
|
220
|
+
// Pin Chart.js v4 for stable scale behavior and financial chart rendering.
|
|
221
|
+
return `https://quickchart.io/chart?w=${width}&h=${height}&f=png&v=4&c=${encoded}`;
|
|
222
|
+
}
|
|
223
|
+
function buildOhlcvChartUrl(chartType, mint, timeframe, bars, width, height) {
|
|
224
|
+
if (chartType === "candlestick") {
|
|
225
|
+
return buildCandlestickOhlcvChartUrl(mint, timeframe, bars, width, height);
|
|
226
|
+
}
|
|
227
|
+
return buildLineVolumeOhlcvChartUrl(mint, timeframe, bars, width, height);
|
|
228
|
+
}
|
|
169
229
|
function getPlatformInstallHint(binary) {
|
|
170
230
|
switch (process.platform) {
|
|
171
231
|
case "darwin":
|
|
@@ -300,6 +360,7 @@ const tokenOhlcvSchema = z.object({
|
|
|
300
360
|
timeTo: z.number().int().positive().optional(),
|
|
301
361
|
});
|
|
302
362
|
const tokenOhlcvChartSchema = tokenOhlcvSchema.extend({
|
|
363
|
+
chartType: z.enum(["line-volume", "candlestick"]).default("line-volume"),
|
|
303
364
|
includeActive: z.boolean().default(true),
|
|
304
365
|
maxPoints: z.number().int().min(10).max(500).default(120),
|
|
305
366
|
width: z.number().int().min(300).max(2000).default(1200),
|
|
@@ -515,7 +576,7 @@ const tools = [
|
|
|
515
576
|
},
|
|
516
577
|
{
|
|
517
578
|
name: "token_get_ohlcv_chart",
|
|
518
|
-
description: "Build a shareable chart URL from token OHLCV candles so agents can send an actual chart in chat (resolve ticker with token_search first).",
|
|
579
|
+
description: "Build a shareable chart URL from token OHLCV candles so agents can send an actual chart in chat (resolve ticker with token_search first). Supports line-volume or candlestick charts.",
|
|
519
580
|
inputSchema: {
|
|
520
581
|
type: "object",
|
|
521
582
|
required: ["mint", "timeframe"],
|
|
@@ -523,6 +584,11 @@ const tools = [
|
|
|
523
584
|
mint: { type: "string" },
|
|
524
585
|
timeframe: { type: "string", description: "e.g. 1m, 5m, 1h, 1d" },
|
|
525
586
|
timeTo: { type: "number" },
|
|
587
|
+
chartType: {
|
|
588
|
+
type: "string",
|
|
589
|
+
enum: ["line-volume", "candlestick"],
|
|
590
|
+
description: "Chart style. Default line-volume.",
|
|
591
|
+
},
|
|
526
592
|
includeActive: { type: "boolean" },
|
|
527
593
|
maxPoints: { type: "number" },
|
|
528
594
|
width: { type: "number" },
|
|
@@ -868,10 +934,11 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
868
934
|
if (trimmedBars.length === 0) {
|
|
869
935
|
throw new Error(`No OHLCV data available for ${input.mint} (${input.timeframe})`);
|
|
870
936
|
}
|
|
871
|
-
const chartUrl = buildOhlcvChartUrl(input.mint, input.timeframe, trimmedBars, input.width, input.height);
|
|
937
|
+
const chartUrl = buildOhlcvChartUrl(input.chartType, input.mint, input.timeframe, trimmedBars, input.width, input.height);
|
|
872
938
|
return ok({
|
|
873
939
|
mint: input.mint,
|
|
874
940
|
timeframe: input.timeframe,
|
|
941
|
+
chartType: input.chartType,
|
|
875
942
|
points: trimmedBars.length,
|
|
876
943
|
chartUrl,
|
|
877
944
|
markdown: ``,
|