@dritan/mcp 0.3.0 → 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 +73 -4
- 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)));
|
|
@@ -162,7 +162,69 @@ function buildOhlcvChartUrl(mint, timeframe, bars, width, height) {
|
|
|
162
162
|
},
|
|
163
163
|
};
|
|
164
164
|
const encoded = encodeURIComponent(JSON.stringify(config));
|
|
165
|
-
|
|
165
|
+
// QuickChart defaults to Chart.js v2. Our config uses v3+/v4 scale syntax (`options.scales.{id}`),
|
|
166
|
+
// so pinning `v=4` prevents runtime render errors like "Cannot read properties of undefined (reading 'options')".
|
|
167
|
+
return `https://quickchart.io/chart?w=${width}&h=${height}&f=png&v=4&c=${encoded}`;
|
|
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);
|
|
166
228
|
}
|
|
167
229
|
function getPlatformInstallHint(binary) {
|
|
168
230
|
switch (process.platform) {
|
|
@@ -298,6 +360,7 @@ const tokenOhlcvSchema = z.object({
|
|
|
298
360
|
timeTo: z.number().int().positive().optional(),
|
|
299
361
|
});
|
|
300
362
|
const tokenOhlcvChartSchema = tokenOhlcvSchema.extend({
|
|
363
|
+
chartType: z.enum(["line-volume", "candlestick"]).default("line-volume"),
|
|
301
364
|
includeActive: z.boolean().default(true),
|
|
302
365
|
maxPoints: z.number().int().min(10).max(500).default(120),
|
|
303
366
|
width: z.number().int().min(300).max(2000).default(1200),
|
|
@@ -513,7 +576,7 @@ const tools = [
|
|
|
513
576
|
},
|
|
514
577
|
{
|
|
515
578
|
name: "token_get_ohlcv_chart",
|
|
516
|
-
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.",
|
|
517
580
|
inputSchema: {
|
|
518
581
|
type: "object",
|
|
519
582
|
required: ["mint", "timeframe"],
|
|
@@ -521,6 +584,11 @@ const tools = [
|
|
|
521
584
|
mint: { type: "string" },
|
|
522
585
|
timeframe: { type: "string", description: "e.g. 1m, 5m, 1h, 1d" },
|
|
523
586
|
timeTo: { type: "number" },
|
|
587
|
+
chartType: {
|
|
588
|
+
type: "string",
|
|
589
|
+
enum: ["line-volume", "candlestick"],
|
|
590
|
+
description: "Chart style. Default line-volume.",
|
|
591
|
+
},
|
|
524
592
|
includeActive: { type: "boolean" },
|
|
525
593
|
maxPoints: { type: "number" },
|
|
526
594
|
width: { type: "number" },
|
|
@@ -866,10 +934,11 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
866
934
|
if (trimmedBars.length === 0) {
|
|
867
935
|
throw new Error(`No OHLCV data available for ${input.mint} (${input.timeframe})`);
|
|
868
936
|
}
|
|
869
|
-
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);
|
|
870
938
|
return ok({
|
|
871
939
|
mint: input.mint,
|
|
872
940
|
timeframe: input.timeframe,
|
|
941
|
+
chartType: input.chartType,
|
|
873
942
|
points: trimmedBars.length,
|
|
874
943
|
chartUrl,
|
|
875
944
|
markdown: ``,
|