@outsidedata/dolex 4.0.0 → 5.0.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/dist/src/mcp/index.d.ts +3 -1
- package/dist/src/mcp/index.d.ts.map +1 -1
- package/dist/src/mcp/index.js +18 -1
- package/dist/src/mcp/index.js.map +1 -1
- package/dist/src/mcp/tools/refine-cli.d.ts +145 -0
- package/dist/src/mcp/tools/refine-cli.d.ts.map +1 -0
- package/dist/src/mcp/tools/refine-cli.js +87 -0
- package/dist/src/mcp/tools/refine-cli.js.map +1 -0
- package/dist/src/mcp/tools/refine.d.ts +0 -3
- package/dist/src/mcp/tools/refine.d.ts.map +1 -1
- package/dist/src/mcp/tools/refine.js +2 -4
- package/dist/src/mcp/tools/refine.js.map +1 -1
- package/dist/src/mcp/tools/visualize-cli.d.ts +184 -0
- package/dist/src/mcp/tools/visualize-cli.d.ts.map +1 -0
- package/dist/src/mcp/tools/visualize-cli.js +164 -0
- package/dist/src/mcp/tools/visualize-cli.js.map +1 -0
- package/dist/src/mcp/tools/visualize.d.ts +0 -4
- package/dist/src/mcp/tools/visualize.d.ts.map +1 -1
- package/dist/src/mcp/tools/visualize.js +2 -4
- package/dist/src/mcp/tools/visualize.js.map +1 -1
- package/package.json +1 -1
- package/src/mcp/index.ts +29 -1
- package/src/mcp/tools/refine-cli.ts +98 -0
- package/src/mcp/tools/refine.ts +2 -5
- package/src/mcp/tools/visualize-cli.ts +179 -0
- package/src/mcp/tools/visualize.ts +2 -5
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Tool: visualize_cli_only
|
|
3
|
+
*
|
|
4
|
+
* FOR CLAUDE CODE / CLI USE ONLY. DO NOT USE IN CLAUDE DESKTOP.
|
|
5
|
+
*
|
|
6
|
+
* Same as visualize but:
|
|
7
|
+
* - NEVER returns HTML in response
|
|
8
|
+
* - Writes HTML directly to disk via writeTo parameter
|
|
9
|
+
* - Returns only specId and metadata
|
|
10
|
+
*/
|
|
11
|
+
import { z } from 'zod';
|
|
12
|
+
import type { VisualizeInput, VisualizeOutput } from '../../types.js';
|
|
13
|
+
export declare const visualizeCliInputSchema: z.ZodObject<{
|
|
14
|
+
data: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodAny>, "many">>;
|
|
15
|
+
resultId: z.ZodOptional<z.ZodString>;
|
|
16
|
+
sourceId: z.ZodOptional<z.ZodString>;
|
|
17
|
+
sql: z.ZodOptional<z.ZodString>;
|
|
18
|
+
intent: z.ZodString;
|
|
19
|
+
columns: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
20
|
+
name: z.ZodString;
|
|
21
|
+
type: z.ZodEnum<["numeric", "categorical", "date", "id", "text"]>;
|
|
22
|
+
sampleValues: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
23
|
+
uniqueCount: z.ZodOptional<z.ZodNumber>;
|
|
24
|
+
nullCount: z.ZodOptional<z.ZodNumber>;
|
|
25
|
+
totalCount: z.ZodOptional<z.ZodNumber>;
|
|
26
|
+
}, "strip", z.ZodTypeAny, {
|
|
27
|
+
type: "numeric" | "categorical" | "date" | "id" | "text";
|
|
28
|
+
name: string;
|
|
29
|
+
sampleValues?: string[] | undefined;
|
|
30
|
+
uniqueCount?: number | undefined;
|
|
31
|
+
nullCount?: number | undefined;
|
|
32
|
+
totalCount?: number | undefined;
|
|
33
|
+
}, {
|
|
34
|
+
type: "numeric" | "categorical" | "date" | "id" | "text";
|
|
35
|
+
name: string;
|
|
36
|
+
sampleValues?: string[] | undefined;
|
|
37
|
+
uniqueCount?: number | undefined;
|
|
38
|
+
nullCount?: number | undefined;
|
|
39
|
+
totalCount?: number | undefined;
|
|
40
|
+
}>, "many">>;
|
|
41
|
+
dataShapeHints: z.ZodOptional<z.ZodObject<{
|
|
42
|
+
rowCount: z.ZodOptional<z.ZodNumber>;
|
|
43
|
+
categoryCount: z.ZodOptional<z.ZodNumber>;
|
|
44
|
+
seriesCount: z.ZodOptional<z.ZodNumber>;
|
|
45
|
+
numericColumnCount: z.ZodOptional<z.ZodNumber>;
|
|
46
|
+
categoricalColumnCount: z.ZodOptional<z.ZodNumber>;
|
|
47
|
+
dateColumnCount: z.ZodOptional<z.ZodNumber>;
|
|
48
|
+
hasTimeSeries: z.ZodOptional<z.ZodBoolean>;
|
|
49
|
+
hasHierarchy: z.ZodOptional<z.ZodBoolean>;
|
|
50
|
+
hasNegativeValues: z.ZodOptional<z.ZodBoolean>;
|
|
51
|
+
}, "strip", z.ZodTypeAny, {
|
|
52
|
+
dateColumnCount?: number | undefined;
|
|
53
|
+
categoricalColumnCount?: number | undefined;
|
|
54
|
+
rowCount?: number | undefined;
|
|
55
|
+
categoryCount?: number | undefined;
|
|
56
|
+
seriesCount?: number | undefined;
|
|
57
|
+
numericColumnCount?: number | undefined;
|
|
58
|
+
hasTimeSeries?: boolean | undefined;
|
|
59
|
+
hasHierarchy?: boolean | undefined;
|
|
60
|
+
hasNegativeValues?: boolean | undefined;
|
|
61
|
+
}, {
|
|
62
|
+
dateColumnCount?: number | undefined;
|
|
63
|
+
categoricalColumnCount?: number | undefined;
|
|
64
|
+
rowCount?: number | undefined;
|
|
65
|
+
categoryCount?: number | undefined;
|
|
66
|
+
seriesCount?: number | undefined;
|
|
67
|
+
numericColumnCount?: number | undefined;
|
|
68
|
+
hasTimeSeries?: boolean | undefined;
|
|
69
|
+
hasHierarchy?: boolean | undefined;
|
|
70
|
+
hasNegativeValues?: boolean | undefined;
|
|
71
|
+
}>>;
|
|
72
|
+
pattern: z.ZodOptional<z.ZodString>;
|
|
73
|
+
title: z.ZodOptional<z.ZodString>;
|
|
74
|
+
subtitle: z.ZodOptional<z.ZodString>;
|
|
75
|
+
includeDataTable: z.ZodOptional<z.ZodBoolean>;
|
|
76
|
+
palette: z.ZodOptional<z.ZodEnum<["categorical", "blue", "green", "purple", "warm", "blueRed", "greenPurple", "tealOrange", "redGreen", "traffic-light", "profit-loss", "temperature"]>>;
|
|
77
|
+
highlight: z.ZodOptional<z.ZodObject<{
|
|
78
|
+
values: z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber]>, "many">;
|
|
79
|
+
color: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
80
|
+
mutedColor: z.ZodOptional<z.ZodString>;
|
|
81
|
+
mutedOpacity: z.ZodOptional<z.ZodNumber>;
|
|
82
|
+
}, "strip", z.ZodTypeAny, {
|
|
83
|
+
values: (string | number)[];
|
|
84
|
+
color?: string | string[] | undefined;
|
|
85
|
+
mutedColor?: string | undefined;
|
|
86
|
+
mutedOpacity?: number | undefined;
|
|
87
|
+
}, {
|
|
88
|
+
values: (string | number)[];
|
|
89
|
+
color?: string | string[] | undefined;
|
|
90
|
+
mutedColor?: string | undefined;
|
|
91
|
+
mutedOpacity?: number | undefined;
|
|
92
|
+
}>>;
|
|
93
|
+
colorField: z.ZodOptional<z.ZodString>;
|
|
94
|
+
maxAlternativeChartTypes: z.ZodOptional<z.ZodNumber>;
|
|
95
|
+
geoLevel: z.ZodOptional<z.ZodEnum<["country", "subdivision"]>>;
|
|
96
|
+
geoRegion: z.ZodOptional<z.ZodString>;
|
|
97
|
+
writeTo: z.ZodString;
|
|
98
|
+
}, "strip", z.ZodTypeAny, {
|
|
99
|
+
intent: string;
|
|
100
|
+
writeTo: string;
|
|
101
|
+
columns?: {
|
|
102
|
+
type: "numeric" | "categorical" | "date" | "id" | "text";
|
|
103
|
+
name: string;
|
|
104
|
+
sampleValues?: string[] | undefined;
|
|
105
|
+
uniqueCount?: number | undefined;
|
|
106
|
+
nullCount?: number | undefined;
|
|
107
|
+
totalCount?: number | undefined;
|
|
108
|
+
}[] | undefined;
|
|
109
|
+
data?: Record<string, any>[] | undefined;
|
|
110
|
+
pattern?: string | undefined;
|
|
111
|
+
title?: string | undefined;
|
|
112
|
+
highlight?: {
|
|
113
|
+
values: (string | number)[];
|
|
114
|
+
color?: string | string[] | undefined;
|
|
115
|
+
mutedColor?: string | undefined;
|
|
116
|
+
mutedOpacity?: number | undefined;
|
|
117
|
+
} | undefined;
|
|
118
|
+
colorField?: string | undefined;
|
|
119
|
+
palette?: "categorical" | "blue" | "green" | "purple" | "warm" | "blueRed" | "greenPurple" | "tealOrange" | "redGreen" | "traffic-light" | "profit-loss" | "temperature" | undefined;
|
|
120
|
+
geoRegion?: string | undefined;
|
|
121
|
+
resultId?: string | undefined;
|
|
122
|
+
sourceId?: string | undefined;
|
|
123
|
+
sql?: string | undefined;
|
|
124
|
+
dataShapeHints?: {
|
|
125
|
+
dateColumnCount?: number | undefined;
|
|
126
|
+
categoricalColumnCount?: number | undefined;
|
|
127
|
+
rowCount?: number | undefined;
|
|
128
|
+
categoryCount?: number | undefined;
|
|
129
|
+
seriesCount?: number | undefined;
|
|
130
|
+
numericColumnCount?: number | undefined;
|
|
131
|
+
hasTimeSeries?: boolean | undefined;
|
|
132
|
+
hasHierarchy?: boolean | undefined;
|
|
133
|
+
hasNegativeValues?: boolean | undefined;
|
|
134
|
+
} | undefined;
|
|
135
|
+
subtitle?: string | undefined;
|
|
136
|
+
includeDataTable?: boolean | undefined;
|
|
137
|
+
maxAlternativeChartTypes?: number | undefined;
|
|
138
|
+
geoLevel?: "country" | "subdivision" | undefined;
|
|
139
|
+
}, {
|
|
140
|
+
intent: string;
|
|
141
|
+
writeTo: string;
|
|
142
|
+
columns?: {
|
|
143
|
+
type: "numeric" | "categorical" | "date" | "id" | "text";
|
|
144
|
+
name: string;
|
|
145
|
+
sampleValues?: string[] | undefined;
|
|
146
|
+
uniqueCount?: number | undefined;
|
|
147
|
+
nullCount?: number | undefined;
|
|
148
|
+
totalCount?: number | undefined;
|
|
149
|
+
}[] | undefined;
|
|
150
|
+
data?: Record<string, any>[] | undefined;
|
|
151
|
+
pattern?: string | undefined;
|
|
152
|
+
title?: string | undefined;
|
|
153
|
+
highlight?: {
|
|
154
|
+
values: (string | number)[];
|
|
155
|
+
color?: string | string[] | undefined;
|
|
156
|
+
mutedColor?: string | undefined;
|
|
157
|
+
mutedOpacity?: number | undefined;
|
|
158
|
+
} | undefined;
|
|
159
|
+
colorField?: string | undefined;
|
|
160
|
+
palette?: "categorical" | "blue" | "green" | "purple" | "warm" | "blueRed" | "greenPurple" | "tealOrange" | "redGreen" | "traffic-light" | "profit-loss" | "temperature" | undefined;
|
|
161
|
+
geoRegion?: string | undefined;
|
|
162
|
+
resultId?: string | undefined;
|
|
163
|
+
sourceId?: string | undefined;
|
|
164
|
+
sql?: string | undefined;
|
|
165
|
+
dataShapeHints?: {
|
|
166
|
+
dateColumnCount?: number | undefined;
|
|
167
|
+
categoricalColumnCount?: number | undefined;
|
|
168
|
+
rowCount?: number | undefined;
|
|
169
|
+
categoryCount?: number | undefined;
|
|
170
|
+
seriesCount?: number | undefined;
|
|
171
|
+
numericColumnCount?: number | undefined;
|
|
172
|
+
hasTimeSeries?: boolean | undefined;
|
|
173
|
+
hasHierarchy?: boolean | undefined;
|
|
174
|
+
hasNegativeValues?: boolean | undefined;
|
|
175
|
+
} | undefined;
|
|
176
|
+
subtitle?: string | undefined;
|
|
177
|
+
includeDataTable?: boolean | undefined;
|
|
178
|
+
maxAlternativeChartTypes?: number | undefined;
|
|
179
|
+
geoLevel?: "country" | "subdivision" | undefined;
|
|
180
|
+
}>;
|
|
181
|
+
export declare function handleVisualizeCli(selectPatterns: (input: VisualizeInput) => VisualizeOutput, deps?: {
|
|
182
|
+
sourceManager?: any;
|
|
183
|
+
}): (args: z.infer<typeof visualizeCliInputSchema>) => Promise<import("./shared.js").McpResponse>;
|
|
184
|
+
//# sourceMappingURL=visualize-cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"visualize-cli.d.ts","sourceRoot":"","sources":["../../../../src/mcp/tools/visualize-cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAiC,MAAM,gBAAgB,CAAC;AAWrG,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwBlC,CAAC;AAEH,wBAAgB,kBAAkB,CAChC,cAAc,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,eAAe,EAC1D,IAAI,CAAC,EAAE;IAAE,aAAa,CAAC,EAAE,GAAG,CAAA;CAAE,IAEhB,MAAM,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,gDA2H5D"}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Tool: visualize_cli_only
|
|
3
|
+
*
|
|
4
|
+
* FOR CLAUDE CODE / CLI USE ONLY. DO NOT USE IN CLAUDE DESKTOP.
|
|
5
|
+
*
|
|
6
|
+
* Same as visualize but:
|
|
7
|
+
* - NEVER returns HTML in response
|
|
8
|
+
* - Writes HTML directly to disk via writeTo parameter
|
|
9
|
+
* - Returns only specId and metadata
|
|
10
|
+
*/
|
|
11
|
+
import { z } from 'zod';
|
|
12
|
+
import { writeFileSync, mkdirSync } from 'fs';
|
|
13
|
+
import { dirname } from 'path';
|
|
14
|
+
import { isCompoundSpec } from '../../types.js';
|
|
15
|
+
import { ALL_PALETTE_NAMES } from './sql-schemas.js';
|
|
16
|
+
import { buildChartHtml, isHtmlPatternSupported } from '../../renderers/html/index.js';
|
|
17
|
+
import { shouldCompound, buildCompoundSpec } from '../../renderers/html/compound.js';
|
|
18
|
+
import { buildCompoundHtml } from '../../renderers/html/builders/compound.js';
|
|
19
|
+
import { specStore } from '../spec-store.js';
|
|
20
|
+
import { getResult } from './result-cache.js';
|
|
21
|
+
import { errorResponse, inferColumns, applyColorPreferences } from './shared.js';
|
|
22
|
+
import { columnsSchema, dataShapeHintsSchema } from './visualize.js';
|
|
23
|
+
export const visualizeCliInputSchema = z.object({
|
|
24
|
+
data: z.array(z.record(z.any())).optional().describe('Array of data rows to visualize. Optional if resultId or sourceId+sql is provided.'),
|
|
25
|
+
resultId: z.string().optional().describe('Result ID from a previous query_data call'),
|
|
26
|
+
sourceId: z.string().optional().describe('Dataset ID returned by load_csv'),
|
|
27
|
+
sql: z.string().optional().describe('SQL SELECT query to slice/aggregate the data before visualizing.'),
|
|
28
|
+
intent: z.string().describe('What the user wants to see'),
|
|
29
|
+
columns: columnsSchema,
|
|
30
|
+
dataShapeHints: dataShapeHintsSchema,
|
|
31
|
+
pattern: z.string().optional().describe('Force a specific chart pattern by ID'),
|
|
32
|
+
title: z.string().optional().describe('Chart title'),
|
|
33
|
+
subtitle: z.string().optional().describe('Chart subtitle'),
|
|
34
|
+
includeDataTable: z.boolean().optional().describe('Whether to add a companion data table. Default: true'),
|
|
35
|
+
palette: z.enum(ALL_PALETTE_NAMES).optional().describe('Named palette'),
|
|
36
|
+
highlight: z.object({
|
|
37
|
+
values: z.array(z.union([z.string(), z.number()])).describe('Values to emphasize'),
|
|
38
|
+
color: z.union([z.string(), z.array(z.string())]).optional(),
|
|
39
|
+
mutedColor: z.string().optional(),
|
|
40
|
+
mutedOpacity: z.number().optional(),
|
|
41
|
+
}).optional(),
|
|
42
|
+
colorField: z.string().optional().describe('Which data field to base colors on'),
|
|
43
|
+
maxAlternativeChartTypes: z.number().optional().describe('Max alternative chart type recommendations to return (default: 2)'),
|
|
44
|
+
geoLevel: z.enum(['country', 'subdivision']).optional().describe('Geographic level'),
|
|
45
|
+
geoRegion: z.string().optional().describe('Geographic region code'),
|
|
46
|
+
writeTo: z.string().describe('REQUIRED. File path to write the HTML chart to. The HTML is written to disk and NOT returned in the response.'),
|
|
47
|
+
});
|
|
48
|
+
export function handleVisualizeCli(selectPatterns, deps) {
|
|
49
|
+
return async (args) => {
|
|
50
|
+
let data = args.data;
|
|
51
|
+
let queryMeta;
|
|
52
|
+
// Path 1: sourceId + sql → server-side query
|
|
53
|
+
if (args.sourceId && args.sql) {
|
|
54
|
+
if (!deps?.sourceManager) {
|
|
55
|
+
return errorResponse('Source manager not available.');
|
|
56
|
+
}
|
|
57
|
+
const result = await deps.sourceManager.querySql(args.sourceId, args.sql);
|
|
58
|
+
if (!result.ok) {
|
|
59
|
+
return errorResponse(result.error);
|
|
60
|
+
}
|
|
61
|
+
data = result.rows;
|
|
62
|
+
queryMeta = { truncated: result.truncated, totalSourceRows: result.totalRows };
|
|
63
|
+
}
|
|
64
|
+
// Path 2: resultId → cached query result
|
|
65
|
+
if (!data && args.resultId) {
|
|
66
|
+
const cached = getResult(args.resultId);
|
|
67
|
+
if (!cached) {
|
|
68
|
+
return errorResponse(`Result "${args.resultId}" not found or expired. Re-run query_data to get a new resultId.`);
|
|
69
|
+
}
|
|
70
|
+
data = cached.rows;
|
|
71
|
+
}
|
|
72
|
+
if (!data || data.length === 0) {
|
|
73
|
+
return errorResponse('No data provided. Pass data array, resultId from query_data, or sourceId + sql.');
|
|
74
|
+
}
|
|
75
|
+
const notes = [];
|
|
76
|
+
const columns = args.columns || inferColumns(data);
|
|
77
|
+
const maxAlternativeChartTypes = args.maxAlternativeChartTypes ?? 2;
|
|
78
|
+
const input = {
|
|
79
|
+
data,
|
|
80
|
+
intent: args.intent,
|
|
81
|
+
columns,
|
|
82
|
+
dataShapeHints: args.dataShapeHints,
|
|
83
|
+
forcePattern: args.pattern,
|
|
84
|
+
geoLevel: args.geoLevel,
|
|
85
|
+
geoRegion: args.geoRegion,
|
|
86
|
+
};
|
|
87
|
+
const result = selectPatterns(input);
|
|
88
|
+
const alternatives = result.alternatives.slice(0, maxAlternativeChartTypes);
|
|
89
|
+
const colorPrefs = (args.palette || args.highlight || args.colorField)
|
|
90
|
+
? { palette: args.palette, highlight: args.highlight, colorField: args.colorField }
|
|
91
|
+
: undefined;
|
|
92
|
+
if (colorPrefs) {
|
|
93
|
+
const colorResult = applyColorPreferences(result.recommended.spec, colorPrefs, data);
|
|
94
|
+
notes.push(...colorResult.notes);
|
|
95
|
+
}
|
|
96
|
+
const spec = result.recommended.spec;
|
|
97
|
+
if (args.title)
|
|
98
|
+
spec.title = args.title;
|
|
99
|
+
if (args.subtitle)
|
|
100
|
+
spec.config = { ...spec.config, subtitle: args.subtitle };
|
|
101
|
+
const hasHtmlBuilder = spec && isHtmlPatternSupported(spec.pattern);
|
|
102
|
+
let outputHtml;
|
|
103
|
+
let finalSpec = spec;
|
|
104
|
+
if (hasHtmlBuilder && shouldCompound(spec, { compound: args.includeDataTable })) {
|
|
105
|
+
const compoundSpec = buildCompoundSpec(spec, columns);
|
|
106
|
+
outputHtml = buildCompoundHtml(compoundSpec);
|
|
107
|
+
finalSpec = compoundSpec;
|
|
108
|
+
}
|
|
109
|
+
else if (hasHtmlBuilder) {
|
|
110
|
+
outputHtml = buildChartHtml(spec);
|
|
111
|
+
}
|
|
112
|
+
const alternativesMap = new Map();
|
|
113
|
+
for (const alt of alternatives) {
|
|
114
|
+
alternativesMap.set(alt.pattern, alt.spec);
|
|
115
|
+
}
|
|
116
|
+
const specId = specStore.save(finalSpec, columns, alternativesMap, data);
|
|
117
|
+
// Write HTML to disk
|
|
118
|
+
let writeResult;
|
|
119
|
+
if (outputHtml) {
|
|
120
|
+
try {
|
|
121
|
+
mkdirSync(dirname(args.writeTo), { recursive: true });
|
|
122
|
+
writeFileSync(args.writeTo, outputHtml, 'utf-8');
|
|
123
|
+
writeResult = `Wrote ${outputHtml.length} bytes to ${args.writeTo}`;
|
|
124
|
+
}
|
|
125
|
+
catch (err) {
|
|
126
|
+
return errorResponse(`Failed to write to ${args.writeTo}: ${err instanceof Error ? err.message : String(err)}`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
writeResult = `No HTML builder for pattern "${spec.pattern}"`;
|
|
131
|
+
}
|
|
132
|
+
const compactResponse = {
|
|
133
|
+
specId,
|
|
134
|
+
writeTo: args.writeTo,
|
|
135
|
+
writeResult,
|
|
136
|
+
...(notes.length > 0 ? { notes } : {}),
|
|
137
|
+
recommended: {
|
|
138
|
+
pattern: result.recommended.pattern,
|
|
139
|
+
title: spec.title,
|
|
140
|
+
reasoning: result.recommended.reasoning,
|
|
141
|
+
},
|
|
142
|
+
alternatives: alternatives.map(a => ({
|
|
143
|
+
pattern: a.pattern,
|
|
144
|
+
reasoning: a.reasoning,
|
|
145
|
+
})),
|
|
146
|
+
dataShape: {
|
|
147
|
+
rowCount: data.length,
|
|
148
|
+
columnCount: columns.length,
|
|
149
|
+
...(queryMeta?.truncated ? { truncated: true, totalSourceRows: queryMeta.totalSourceRows } : {}),
|
|
150
|
+
},
|
|
151
|
+
};
|
|
152
|
+
if (isCompoundSpec(finalSpec)) {
|
|
153
|
+
compactResponse.compound = true;
|
|
154
|
+
}
|
|
155
|
+
// CLI tools NEVER return structuredContent - just text
|
|
156
|
+
return {
|
|
157
|
+
content: [{
|
|
158
|
+
type: 'text',
|
|
159
|
+
text: JSON.stringify(compactResponse, null, 2),
|
|
160
|
+
}],
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
//# sourceMappingURL=visualize-cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"visualize-cli.js","sourceRoot":"","sources":["../../../../src/mcp/tools/visualize-cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAE/B,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,cAA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CAAC,SAAS,CAAC,EAAE,CAAC;YAC9B,eAAe,CAAC,QAAQ,GAAG,IAAI,CAAC;QAClC,CAAC;QAED,uDAAuD;QACvD,OAAO;YACL,OAAO,EAAE,CAAC;oBACR,IAAI,EAAE,MAAe;oBACrB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,eAAe,EAAE,IAAI,EAAE,CAAC,CAAC;iBAC/C,CAAC;SACH,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -146,7 +146,6 @@ export declare const visualizeInputSchema: z.ZodObject<{
|
|
|
146
146
|
maxAlternativeChartTypes: z.ZodOptional<z.ZodNumber>;
|
|
147
147
|
geoLevel: z.ZodOptional<z.ZodEnum<["country", "subdivision"]>>;
|
|
148
148
|
geoRegion: z.ZodOptional<z.ZodString>;
|
|
149
|
-
returnHtml: z.ZodOptional<z.ZodBoolean>;
|
|
150
149
|
}, "strip", z.ZodTypeAny, {
|
|
151
150
|
intent: string;
|
|
152
151
|
columns?: {
|
|
@@ -187,7 +186,6 @@ export declare const visualizeInputSchema: z.ZodObject<{
|
|
|
187
186
|
includeDataTable?: boolean | undefined;
|
|
188
187
|
maxAlternativeChartTypes?: number | undefined;
|
|
189
188
|
geoLevel?: "country" | "subdivision" | undefined;
|
|
190
|
-
returnHtml?: boolean | undefined;
|
|
191
189
|
}, {
|
|
192
190
|
intent: string;
|
|
193
191
|
columns?: {
|
|
@@ -228,7 +226,6 @@ export declare const visualizeInputSchema: z.ZodObject<{
|
|
|
228
226
|
includeDataTable?: boolean | undefined;
|
|
229
227
|
maxAlternativeChartTypes?: number | undefined;
|
|
230
228
|
geoLevel?: "country" | "subdivision" | undefined;
|
|
231
|
-
returnHtml?: boolean | undefined;
|
|
232
229
|
}>;
|
|
233
230
|
/**
|
|
234
231
|
* Shared core logic for all visualize data paths (inline, cached, source query).
|
|
@@ -253,7 +250,6 @@ export declare function handleVisualizeCore(selectPatterns: (input: VisualizeInp
|
|
|
253
250
|
maxAlternativeChartTypes?: number;
|
|
254
251
|
geoLevel?: "country" | "subdivision";
|
|
255
252
|
geoRegion?: string;
|
|
256
|
-
returnHtml?: boolean;
|
|
257
253
|
}, queryMeta?: {
|
|
258
254
|
truncated?: boolean;
|
|
259
255
|
totalSourceRows?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"visualize.d.ts","sourceRoot":"","sources":["../../../../src/mcp/tools/visualize.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAiC,MAAM,gBAAgB,CAAC;AAUrG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;YAO8D,CAAC;AAEzF,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAU6C,CAAC;AAE/E,eAAO,MAAM,oBAAoB
|
|
1
|
+
{"version":3,"file":"visualize.d.ts","sourceRoot":"","sources":["../../../../src/mcp/tools/visualize.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAiC,MAAM,gBAAgB,CAAC;AAUrG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;YAO8D,CAAC;AAEzF,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAU6C,CAAC;AAE/E,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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CAAC,EAAE,GAAG,CAAA;CAAE,IAIhB,MAAM,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC;;;;;;;;;GAoDzD"}
|
|
@@ -61,8 +61,6 @@ export const visualizeInputSchema = z.object({
|
|
|
61
61
|
.describe('Geographic level: "country" (each row = a nation) or "subdivision" (each row = a state/province). Auto-detected if omitted.'),
|
|
62
62
|
geoRegion: z.string().optional()
|
|
63
63
|
.describe('Geographic region code: "world", ISO country code (US, CN, AU, etc.), or continent (EU, AF, AS, SA, NA, OC). Auto-detected if omitted.'),
|
|
64
|
-
returnHtml: z.boolean().optional()
|
|
65
|
-
.describe('Whether to return pre-rendered HTML in the response. Default: true. Set to false to save tokens — use screenshot(specId) to render later.'),
|
|
66
64
|
});
|
|
67
65
|
/**
|
|
68
66
|
* Shared core logic for all visualize data paths (inline, cached, source query).
|
|
@@ -159,13 +157,13 @@ export function handleVisualizeCore(selectPatterns, toolName = 'visualize') {
|
|
|
159
157
|
...extraMeta,
|
|
160
158
|
},
|
|
161
159
|
});
|
|
162
|
-
|
|
160
|
+
// Always include HTML — Desktop requires it for inline chart rendering
|
|
163
161
|
return {
|
|
164
162
|
content: [{
|
|
165
163
|
type: 'text',
|
|
166
164
|
text: JSON.stringify(compactResponse, null, 2),
|
|
167
165
|
}],
|
|
168
|
-
...(outputHtml
|
|
166
|
+
...(outputHtml ? {
|
|
169
167
|
structuredContent: {
|
|
170
168
|
specId,
|
|
171
169
|
html: outputHtml,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"visualize.js","sourceRoot":"","sources":["../../../../src/mcp/tools/visualize.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,sBAAsB,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C,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@outsidedata/dolex",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "AI data analyst — 43 handcrafted visualization patterns, SQL query engine with custom aggregates, and auto-analysis planning via MCP",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
package/src/mcp/index.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* An MCP server that provides visualization intelligence from a handcrafted
|
|
6
6
|
* pattern library that goes far beyond bar/line/pie.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
8
|
+
* 19 tools:
|
|
9
9
|
* visualize — Data (inline, cached, or CSV+SQL) + intent → ranked visualization recommendations
|
|
10
10
|
* list_patterns — Browse all available visualization patterns
|
|
11
11
|
* refine_visualization — Tweak a visualization spec
|
|
@@ -23,6 +23,8 @@
|
|
|
23
23
|
* promote_columns — Promote working columns to derived (persisted)
|
|
24
24
|
* list_transforms — List columns by layer (source/derived/working)
|
|
25
25
|
* drop_columns — Drop derived or working columns
|
|
26
|
+
* visualize_cli_only — CLI ONLY: visualize + write to disk (no HTML in response)
|
|
27
|
+
* refine_visualization_cli_only — CLI ONLY: refine + write to disk (no HTML in response)
|
|
26
28
|
*/
|
|
27
29
|
|
|
28
30
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
@@ -54,6 +56,8 @@ import {
|
|
|
54
56
|
} from './tools/server-privacy.js';
|
|
55
57
|
import { exportHtmlInputSchema, handleExportHtml } from './tools/export-html.js';
|
|
56
58
|
import { screenshotInputSchema, handleScreenshot, closeBrowser } from './tools/screenshot.js';
|
|
59
|
+
import { visualizeCliInputSchema, handleVisualizeCli } from './tools/visualize-cli.js';
|
|
60
|
+
import { refineCliInputSchema, handleRefineCli } from './tools/refine-cli.js';
|
|
57
61
|
import {
|
|
58
62
|
transformDataBaseSchema,
|
|
59
63
|
transformDataSchema,
|
|
@@ -359,6 +363,30 @@ server.registerTool(
|
|
|
359
363
|
handleScreenshot(),
|
|
360
364
|
);
|
|
361
365
|
|
|
366
|
+
// ─── CLI-ONLY TOOLS ────────────────────────────────────────────────────────
|
|
367
|
+
// These tools are for Claude Code / CLI use ONLY. They write HTML to disk
|
|
368
|
+
// instead of returning it. DO NOT use these in Claude Desktop.
|
|
369
|
+
|
|
370
|
+
server.registerTool(
|
|
371
|
+
'visualize_cli_only',
|
|
372
|
+
{
|
|
373
|
+
title: 'CLI ONLY: Visualize to File',
|
|
374
|
+
description: 'FOR CLAUDE CODE / CLI USE ONLY. DO NOT USE IN CLAUDE DESKTOP.\n\nSame as visualize but writes HTML directly to disk via writeTo parameter. NEVER returns HTML in response. Use this for article mode and programmatic workflows.',
|
|
375
|
+
inputSchema: visualizeCliInputSchema.shape,
|
|
376
|
+
},
|
|
377
|
+
handleVisualizeCli(selectPatternCallback, { sourceManager }),
|
|
378
|
+
);
|
|
379
|
+
|
|
380
|
+
server.registerTool(
|
|
381
|
+
'refine_visualization_cli_only',
|
|
382
|
+
{
|
|
383
|
+
title: 'CLI ONLY: Refine to File',
|
|
384
|
+
description: 'FOR CLAUDE CODE / CLI USE ONLY. DO NOT USE IN CLAUDE DESKTOP.\n\nSame as refine_visualization but writes HTML directly to disk via writeTo parameter. NEVER returns HTML in response.',
|
|
385
|
+
inputSchema: refineCliInputSchema.shape,
|
|
386
|
+
},
|
|
387
|
+
handleRefineCli(),
|
|
388
|
+
);
|
|
389
|
+
|
|
362
390
|
// ─── MCP APPS RESOURCE ─────────────────────────────────────────────────────
|
|
363
391
|
|
|
364
392
|
registerAppResource(
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Tool: refine_visualization_cli_only
|
|
3
|
+
*
|
|
4
|
+
* FOR CLAUDE CODE / CLI USE ONLY. DO NOT USE IN CLAUDE DESKTOP.
|
|
5
|
+
*
|
|
6
|
+
* Same as refine_visualization but:
|
|
7
|
+
* - NEVER returns HTML in response
|
|
8
|
+
* - Writes HTML directly to disk via writeTo parameter
|
|
9
|
+
* - Returns only specId and changes
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { z } from 'zod';
|
|
13
|
+
import { writeFileSync, mkdirSync } from 'fs';
|
|
14
|
+
import { dirname } from 'path';
|
|
15
|
+
import type { VisualizationSpec, CompoundVisualizationSpec } from '../../types.js';
|
|
16
|
+
import { isCompoundSpec } from '../../types.js';
|
|
17
|
+
import { buildChartHtml, isHtmlPatternSupported } from '../../renderers/html/index.js';
|
|
18
|
+
import { buildCompoundHtml } from '../../renderers/html/builders/compound.js';
|
|
19
|
+
import { specStore } from '../spec-store.js';
|
|
20
|
+
import { errorResponse } from './shared.js';
|
|
21
|
+
import { refineInputSchema, handleRefine } from './refine.js';
|
|
22
|
+
|
|
23
|
+
// Extend the refine schema with required writeTo
|
|
24
|
+
export const refineCliInputSchema = refineInputSchema.extend({
|
|
25
|
+
writeTo: z.string().describe('REQUIRED. File path to write the refined HTML chart to. The HTML is written to disk and NOT returned in the response.'),
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
function buildOutputHtml(spec: VisualizationSpec | CompoundVisualizationSpec): string | undefined {
|
|
29
|
+
if (isCompoundSpec(spec)) {
|
|
30
|
+
return buildCompoundHtml(spec);
|
|
31
|
+
}
|
|
32
|
+
if (isHtmlPatternSupported(spec.pattern)) {
|
|
33
|
+
return buildChartHtml(spec);
|
|
34
|
+
}
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function handleRefineCli() {
|
|
39
|
+
// Get the base refine handler to reuse its logic
|
|
40
|
+
const baseRefine = handleRefine();
|
|
41
|
+
|
|
42
|
+
return async (args: z.infer<typeof refineCliInputSchema>) => {
|
|
43
|
+
// Call the base refine to do all the spec manipulation
|
|
44
|
+
const stored = specStore.get(args.specId);
|
|
45
|
+
if (!stored) {
|
|
46
|
+
return errorResponse(`Spec "${args.specId}" not found. It may have expired. Re-run visualize to get a new specId.`);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Run base refine (it will update the spec store)
|
|
50
|
+
const baseResult = await baseRefine(args);
|
|
51
|
+
|
|
52
|
+
// Extract the response body from base result
|
|
53
|
+
const textContent = baseResult.content.find((c: any) => c.type === 'text');
|
|
54
|
+
if (!textContent) {
|
|
55
|
+
return errorResponse('Unexpected error: no text content from refine');
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const body = JSON.parse(textContent.text);
|
|
59
|
+
const newSpecId = body.specId;
|
|
60
|
+
|
|
61
|
+
// Get the updated spec and build HTML
|
|
62
|
+
const updatedStored = specStore.get(newSpecId);
|
|
63
|
+
if (!updatedStored) {
|
|
64
|
+
return errorResponse('Unexpected error: refined spec not found');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const outputHtml = buildOutputHtml(updatedStored.spec);
|
|
68
|
+
|
|
69
|
+
// Write HTML to disk
|
|
70
|
+
let writeResult: string;
|
|
71
|
+
if (outputHtml) {
|
|
72
|
+
try {
|
|
73
|
+
mkdirSync(dirname(args.writeTo), { recursive: true });
|
|
74
|
+
writeFileSync(args.writeTo, outputHtml, 'utf-8');
|
|
75
|
+
writeResult = `Wrote ${outputHtml.length} bytes to ${args.writeTo}`;
|
|
76
|
+
} catch (err) {
|
|
77
|
+
return errorResponse(`Failed to write to ${args.writeTo}: ${err instanceof Error ? err.message : String(err)}`);
|
|
78
|
+
}
|
|
79
|
+
} else {
|
|
80
|
+
const pattern = isCompoundSpec(updatedStored.spec)
|
|
81
|
+
? (updatedStored.spec as any).views?.find((v: any) => v.type === 'chart')?.chart?.pattern
|
|
82
|
+
: (updatedStored.spec as VisualizationSpec).pattern;
|
|
83
|
+
writeResult = `No HTML builder for pattern "${pattern}"`;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Add write info to response
|
|
87
|
+
body.writeTo = args.writeTo;
|
|
88
|
+
body.writeResult = writeResult;
|
|
89
|
+
|
|
90
|
+
// CLI tools NEVER return structuredContent - just text
|
|
91
|
+
return {
|
|
92
|
+
content: [{
|
|
93
|
+
type: 'text' as const,
|
|
94
|
+
text: JSON.stringify(body, null, 2),
|
|
95
|
+
}],
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
}
|