@outsidedata/dolex 0.1.13 → 1.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/README.md +8 -8
- package/dist/src/analysis/rules.d.ts.map +1 -1
- package/dist/src/analysis/rules.js +8 -2
- package/dist/src/analysis/rules.js.map +1 -1
- package/dist/src/connectors/csv.d.ts.map +1 -1
- package/dist/src/connectors/csv.js +31 -1
- package/dist/src/connectors/csv.js.map +1 -1
- package/dist/src/connectors/dsl-compiler.d.ts +7 -6
- package/dist/src/connectors/dsl-compiler.d.ts.map +1 -1
- package/dist/src/connectors/dsl-compiler.js +72 -79
- package/dist/src/connectors/dsl-compiler.js.map +1 -1
- package/dist/src/connectors/dsl-validator.js +6 -1
- package/dist/src/connectors/dsl-validator.js.map +1 -1
- package/dist/src/connectors/index.d.ts +0 -3
- package/dist/src/connectors/index.d.ts.map +1 -1
- package/dist/src/connectors/index.js +0 -3
- package/dist/src/connectors/index.js.map +1 -1
- package/dist/src/connectors/js-aggregation.d.ts +4 -4
- package/dist/src/connectors/js-aggregation.d.ts.map +1 -1
- package/dist/src/connectors/js-aggregation.js +22 -16
- package/dist/src/connectors/js-aggregation.js.map +1 -1
- package/dist/src/connectors/manager.d.ts.map +1 -1
- package/dist/src/connectors/manager.js +4 -21
- package/dist/src/connectors/manager.js.map +1 -1
- package/dist/src/mcp/app-shell.js +1 -1
- package/dist/src/mcp/index.d.ts +8 -8
- package/dist/src/mcp/index.js +87 -53
- package/dist/src/mcp/index.js.map +1 -1
- package/dist/src/mcp/prompts.js +4 -4
- package/dist/src/mcp/prompts.js.map +1 -1
- package/dist/src/mcp/spec-store.d.ts +2 -1
- package/dist/src/mcp/spec-store.d.ts.map +1 -1
- package/dist/src/mcp/spec-store.js +4 -2
- package/dist/src/mcp/spec-store.js.map +1 -1
- package/dist/src/mcp/tools/analyze.d.ts +1 -1
- package/dist/src/mcp/tools/analyze.js +2 -2
- package/dist/src/mcp/tools/analyze.js.map +1 -1
- package/dist/src/mcp/tools/bug-report.d.ts.map +1 -1
- package/dist/src/mcp/tools/bug-report.js +2 -10
- package/dist/src/mcp/tools/bug-report.js.map +1 -1
- package/dist/src/mcp/tools/dashboard.js +1 -1
- package/dist/src/mcp/tools/dashboard.js.map +1 -1
- package/dist/src/mcp/tools/dsl-schemas.d.ts +53 -52
- package/dist/src/mcp/tools/dsl-schemas.d.ts.map +1 -1
- package/dist/src/mcp/tools/dsl-schemas.js +3 -3
- package/dist/src/mcp/tools/dsl-schemas.js.map +1 -1
- package/dist/src/mcp/tools/export-html.d.ts +1 -1
- package/dist/src/mcp/tools/export-html.js +2 -2
- package/dist/src/mcp/tools/export-html.js.map +1 -1
- package/dist/src/mcp/tools/list-patterns.js +2 -2
- package/dist/src/mcp/tools/list-patterns.js.map +1 -1
- package/dist/src/mcp/tools/query-source.d.ts +17 -17
- package/dist/src/mcp/tools/query-source.js +4 -4
- package/dist/src/mcp/tools/query-source.js.map +1 -1
- package/dist/src/mcp/tools/refine.d.ts +124 -15
- package/dist/src/mcp/tools/refine.d.ts.map +1 -1
- package/dist/src/mcp/tools/refine.js +335 -253
- package/dist/src/mcp/tools/refine.js.map +1 -1
- package/dist/src/mcp/tools/result-cache.d.ts +1 -1
- package/dist/src/mcp/tools/result-cache.js +1 -1
- package/dist/src/mcp/tools/screenshot.js +1 -1
- package/dist/src/mcp/tools/screenshot.js.map +1 -1
- package/dist/src/mcp/tools/server-privacy.d.ts.map +1 -1
- package/dist/src/mcp/tools/server-privacy.js +6 -7
- package/dist/src/mcp/tools/server-privacy.js.map +1 -1
- package/dist/src/mcp/tools/shared.d.ts +15 -2
- package/dist/src/mcp/tools/shared.d.ts.map +1 -1
- package/dist/src/mcp/tools/shared.js +64 -6
- package/dist/src/mcp/tools/shared.js.map +1 -1
- package/dist/src/mcp/tools/sources.d.ts +5 -113
- package/dist/src/mcp/tools/sources.d.ts.map +1 -1
- package/dist/src/mcp/tools/sources.js +15 -44
- package/dist/src/mcp/tools/sources.js.map +1 -1
- package/dist/src/mcp/tools/visualize-from-source.d.ts +53 -77
- package/dist/src/mcp/tools/visualize-from-source.d.ts.map +1 -1
- package/dist/src/mcp/tools/visualize-from-source.js +24 -9
- package/dist/src/mcp/tools/visualize-from-source.js.map +1 -1
- package/dist/src/mcp/tools/visualize.d.ts +47 -102
- package/dist/src/mcp/tools/visualize.d.ts.map +1 -1
- package/dist/src/mcp/tools/visualize.js +24 -24
- package/dist/src/mcp/tools/visualize.js.map +1 -1
- package/dist/src/patterns/definitions/comparison/grouped-bar.js +5 -5
- package/dist/src/patterns/definitions/comparison/grouped-bar.js.map +1 -1
- package/dist/src/patterns/definitions/composition/waffle.d.ts.map +1 -1
- package/dist/src/patterns/definitions/composition/waffle.js +17 -3
- package/dist/src/patterns/definitions/composition/waffle.js.map +1 -1
- package/dist/src/patterns/definitions/distribution/strip-plot.d.ts.map +1 -1
- package/dist/src/patterns/definitions/distribution/strip-plot.js +12 -3
- package/dist/src/patterns/definitions/distribution/strip-plot.js.map +1 -1
- package/dist/src/patterns/definitions/time/sparkline-grid.js +2 -2
- package/dist/src/patterns/definitions/time/sparkline-grid.js.map +1 -1
- package/dist/src/patterns/selector.d.ts.map +1 -1
- package/dist/src/patterns/selector.js +46 -1
- package/dist/src/patterns/selector.js.map +1 -1
- package/dist/src/renderers/d3/comparison/bar.d.ts.map +1 -1
- package/dist/src/renderers/d3/comparison/bar.js +24 -1
- package/dist/src/renderers/d3/comparison/bar.js.map +1 -1
- package/dist/src/renderers/d3/comparison/grouped-bar.d.ts.map +1 -1
- package/dist/src/renderers/d3/comparison/grouped-bar.js +9 -4
- package/dist/src/renderers/d3/comparison/grouped-bar.js.map +1 -1
- package/dist/src/renderers/d3/composition/donut.d.ts.map +1 -1
- package/dist/src/renderers/d3/composition/donut.js +12 -0
- package/dist/src/renderers/d3/composition/donut.js.map +1 -1
- package/dist/src/renderers/d3/composition/stacked-bar.d.ts.map +1 -1
- package/dist/src/renderers/d3/composition/stacked-bar.js +4 -0
- package/dist/src/renderers/d3/composition/stacked-bar.js.map +1 -1
- package/dist/src/renderers/d3/composition/treemap.js +2 -1
- package/dist/src/renderers/d3/composition/treemap.js.map +1 -1
- package/dist/src/renderers/d3/distribution/beeswarm.d.ts.map +1 -1
- package/dist/src/renderers/d3/distribution/beeswarm.js +8 -0
- package/dist/src/renderers/d3/distribution/beeswarm.js.map +1 -1
- package/dist/src/renderers/d3/distribution/histogram.js +36 -2
- package/dist/src/renderers/d3/distribution/histogram.js.map +1 -1
- package/dist/src/renderers/d3/flow/funnel.d.ts.map +1 -1
- package/dist/src/renderers/d3/flow/funnel.js +4 -0
- package/dist/src/renderers/d3/flow/funnel.js.map +1 -1
- package/dist/src/renderers/d3/flow/sankey-layout.js +20 -3
- package/dist/src/renderers/d3/flow/sankey-layout.js.map +1 -1
- package/dist/src/renderers/d3/heatmap.d.ts.map +1 -1
- package/dist/src/renderers/d3/heatmap.js +18 -3
- package/dist/src/renderers/d3/heatmap.js.map +1 -1
- package/dist/src/renderers/d3/radar.d.ts.map +1 -1
- package/dist/src/renderers/d3/radar.js +3 -1
- package/dist/src/renderers/d3/radar.js.map +1 -1
- package/dist/src/renderers/d3/relationship.d.ts.map +1 -1
- package/dist/src/renderers/d3/relationship.js +29 -7
- package/dist/src/renderers/d3/relationship.js.map +1 -1
- package/dist/src/renderers/d3/shared.js +7 -7
- package/dist/src/renderers/d3/shared.js.map +1 -1
- package/dist/src/renderers/d3/time/area.js +21 -7
- package/dist/src/renderers/d3/time/area.js.map +1 -1
- package/dist/src/renderers/d3/time/calendar-heatmap.js +6 -0
- package/dist/src/renderers/d3/time/calendar-heatmap.js.map +1 -1
- package/dist/src/renderers/d3/time/horizon-chart.d.ts.map +1 -1
- package/dist/src/renderers/d3/time/horizon-chart.js +10 -0
- package/dist/src/renderers/d3/time/horizon-chart.js.map +1 -1
- package/dist/src/renderers/d3/time/line.d.ts.map +1 -1
- package/dist/src/renderers/d3/time/line.js +27 -7
- package/dist/src/renderers/d3/time/line.js.map +1 -1
- package/dist/src/renderers/d3/time/small-multiples.js +8 -0
- package/dist/src/renderers/d3/time/small-multiples.js.map +1 -1
- package/dist/src/renderers/d3/time/sparkline-grid.d.ts.map +1 -1
- package/dist/src/renderers/d3/time/sparkline-grid.js +5 -2
- package/dist/src/renderers/d3/time/sparkline-grid.js.map +1 -1
- package/dist/src/renderers/d3/time/stream-graph.js +6 -0
- package/dist/src/renderers/d3/time/stream-graph.js.map +1 -1
- package/dist/src/renderers/html/_generated/bundles.d.ts +39 -39
- package/dist/src/renderers/html/_generated/bundles.d.ts.map +1 -1
- package/dist/src/renderers/html/_generated/bundles.js +39 -39
- package/dist/src/renderers/html/_generated/bundles.js.map +1 -1
- package/dist/src/renderers/html/builders/dashboard.js +2 -2
- package/dist/src/renderers/html/template.js +2 -2
- package/dist/src/renderers/html/template.js.map +1 -1
- package/dist/src/types.d.ts +33 -26
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js.map +1 -1
- package/package.json +2 -4
- package/src/analysis/rules.ts +10 -2
- package/src/connectors/csv.ts +31 -1
- package/src/connectors/dsl-compiler.ts +76 -82
- package/src/connectors/dsl-validator.ts +6 -1
- package/src/connectors/index.ts +0 -3
- package/src/connectors/js-aggregation.ts +20 -15
- package/src/connectors/manager.ts +4 -24
- package/src/mcp/app-shell.ts +1 -1
- package/src/mcp/index.ts +87 -53
- package/src/mcp/prompts.ts +4 -4
- package/src/mcp/spec-store.ts +5 -1
- package/src/mcp/tools/analyze.ts +2 -2
- package/src/mcp/tools/bug-report.ts +2 -10
- package/src/mcp/tools/dashboard.ts +1 -1
- package/src/mcp/tools/dsl-schemas.ts +3 -3
- package/src/mcp/tools/export-html.ts +2 -2
- package/src/mcp/tools/list-patterns.ts +2 -2
- package/src/mcp/tools/query-source.ts +4 -4
- package/src/mcp/tools/refine.ts +333 -258
- package/src/mcp/tools/result-cache.ts +1 -1
- package/src/mcp/tools/screenshot.ts +1 -1
- package/src/mcp/tools/server-privacy.ts +6 -7
- package/src/mcp/tools/shared.ts +70 -7
- package/src/mcp/tools/sources.ts +18 -46
- package/src/mcp/tools/visualize-from-source.ts +24 -9
- package/src/mcp/tools/visualize.ts +27 -27
- package/src/patterns/definitions/comparison/grouped-bar.ts +5 -5
- package/src/patterns/definitions/composition/waffle.ts +17 -3
- package/src/patterns/definitions/distribution/strip-plot.ts +12 -3
- package/src/patterns/definitions/time/sparkline-grid.ts +2 -2
- package/src/patterns/selector.ts +47 -1
- package/src/renderers/d3/comparison/bar.ts +24 -1
- package/src/renderers/d3/comparison/grouped-bar.ts +9 -4
- package/src/renderers/d3/composition/donut.ts +14 -0
- package/src/renderers/d3/composition/stacked-bar.ts +5 -0
- package/src/renderers/d3/composition/treemap.ts +2 -1
- package/src/renderers/d3/distribution/beeswarm.ts +12 -0
- package/src/renderers/d3/distribution/histogram.ts +44 -2
- package/src/renderers/d3/flow/funnel.ts +8 -0
- package/src/renderers/d3/flow/sankey-layout.ts +23 -3
- package/src/renderers/d3/heatmap.ts +20 -2
- package/src/renderers/d3/radar.ts +4 -1
- package/src/renderers/d3/relationship.ts +31 -6
- package/src/renderers/d3/shared.ts +7 -7
- package/src/renderers/d3/time/area.ts +22 -7
- package/src/renderers/d3/time/calendar-heatmap.ts +5 -0
- package/src/renderers/d3/time/horizon-chart.ts +11 -0
- package/src/renderers/d3/time/line.ts +24 -9
- package/src/renderers/d3/time/small-multiples.ts +6 -0
- package/src/renderers/d3/time/sparkline-grid.ts +5 -2
- package/src/renderers/d3/time/stream-graph.ts +5 -0
- package/src/renderers/html/_generated/bundles.ts +39 -39
- package/src/renderers/html/builders/dashboard.ts +2 -2
- package/src/renderers/html/template.ts +2 -2
- package/src/types.ts +21 -33
- package/src/connectors/mysql.ts +0 -378
- package/src/connectors/postgres.ts +0 -367
- package/src/connectors/sqlite.ts +0 -364
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* JS-based aggregation and window function helpers.
|
|
3
3
|
*
|
|
4
|
-
* Used when
|
|
5
|
-
* (e.g., median, stddev, percentile
|
|
4
|
+
* Used when SQLite doesn't support certain aggregates natively
|
|
5
|
+
* (e.g., median, stddev, percentile) or window functions.
|
|
6
6
|
* All functions are pure — no side effects or class dependencies.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import type { DslQuery, DslOrderBy, DslWindowField } from '../types.js';
|
|
10
10
|
import { isDslAggregateField, isDslWindowField } from '../types.js';
|
|
11
11
|
import type { ConnectedSource } from './types.js';
|
|
12
|
-
import { compileDsl } from './dsl-compiler.js';
|
|
12
|
+
import { compileDsl, fieldAlias } from './dsl-compiler.js';
|
|
13
13
|
|
|
14
14
|
const MAX_RESULT_LIMIT = 10000;
|
|
15
15
|
|
|
@@ -102,9 +102,7 @@ function pad2(n: number): string {
|
|
|
102
102
|
return String(n).padStart(2, '0');
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
function
|
|
106
|
-
const d = new Date(dateStr);
|
|
107
|
-
if (isNaN(d.getTime())) return dateStr;
|
|
105
|
+
function bucketDateFromParsed(d: Date, bucket: string): string {
|
|
108
106
|
const year = d.getUTCFullYear();
|
|
109
107
|
const month = d.getUTCMonth() + 1;
|
|
110
108
|
|
|
@@ -125,12 +123,19 @@ function bucketDate(dateStr: string, bucket: string): string {
|
|
|
125
123
|
case 'year':
|
|
126
124
|
return String(year);
|
|
127
125
|
default:
|
|
128
|
-
return
|
|
126
|
+
return String(d);
|
|
129
127
|
}
|
|
130
128
|
}
|
|
131
129
|
|
|
132
|
-
function
|
|
133
|
-
|
|
130
|
+
function bucketDate(dateStr: string, bucket: string): string {
|
|
131
|
+
const numVal = Number(dateStr);
|
|
132
|
+
if (!isNaN(numVal) && numVal > 1800 && numVal < 2200 && Math.floor(numVal) === numVal) {
|
|
133
|
+
if (bucket === 'year') return String(numVal);
|
|
134
|
+
return bucketDateFromParsed(new Date(Date.UTC(numVal, 0, 1)), bucket);
|
|
135
|
+
}
|
|
136
|
+
const d = new Date(dateStr);
|
|
137
|
+
if (isNaN(d.getTime())) return dateStr;
|
|
138
|
+
return bucketDateFromParsed(d, bucket);
|
|
134
139
|
}
|
|
135
140
|
|
|
136
141
|
// ─── Window Functions ────────────────────────────────────────────────────────
|
|
@@ -296,7 +301,7 @@ export async function executeJsAggregation(
|
|
|
296
301
|
source: ConnectedSource,
|
|
297
302
|
table: string,
|
|
298
303
|
query: DslQuery,
|
|
299
|
-
dialect: 'sqlite'
|
|
304
|
+
dialect: 'sqlite' = 'sqlite'
|
|
300
305
|
): Promise<DslQueryResult> {
|
|
301
306
|
const fieldsNeeded = new Set<string>();
|
|
302
307
|
for (const s of query.select) {
|
|
@@ -321,10 +326,10 @@ export async function executeJsAggregation(
|
|
|
321
326
|
|
|
322
327
|
const groupKeys = groupBySpecs.map(g => {
|
|
323
328
|
if (typeof g === 'string') {
|
|
324
|
-
const col =
|
|
329
|
+
const col = fieldAlias(g);
|
|
325
330
|
return { name: col, extract: (row: Record<string, any>) => String(row[col] ?? '') };
|
|
326
331
|
}
|
|
327
|
-
const col =
|
|
332
|
+
const col = fieldAlias(g.field);
|
|
328
333
|
const alias = `${g.field.replace('.', '_')}_${g.bucket}`;
|
|
329
334
|
return { name: alias, extract: (row: Record<string, any>) => bucketDate(String(row[col] ?? ''), g.bucket) };
|
|
330
335
|
});
|
|
@@ -353,12 +358,12 @@ export async function executeJsAggregation(
|
|
|
353
358
|
|
|
354
359
|
for (const s of query.select) {
|
|
355
360
|
if (typeof s === 'string') {
|
|
356
|
-
const col =
|
|
361
|
+
const col = fieldAlias(s);
|
|
357
362
|
if (!(col in row)) {
|
|
358
363
|
row[col] = groupRows[0]?.[col];
|
|
359
364
|
}
|
|
360
365
|
} else if (isDslAggregateField(s)) {
|
|
361
|
-
const col =
|
|
366
|
+
const col = fieldAlias(s.field);
|
|
362
367
|
row[s.as] = jsAggregate(groupRows.map(r => r[col]), s.aggregate, s.percentile);
|
|
363
368
|
}
|
|
364
369
|
}
|
|
@@ -379,7 +384,7 @@ export async function executeJsAggregationWithWindows(
|
|
|
379
384
|
source: ConnectedSource,
|
|
380
385
|
table: string,
|
|
381
386
|
query: DslQuery,
|
|
382
|
-
dialect: 'sqlite'
|
|
387
|
+
dialect: 'sqlite' = 'sqlite'
|
|
383
388
|
): Promise<DslQueryResult> {
|
|
384
389
|
const windowFields = query.select.filter(isDslWindowField);
|
|
385
390
|
const baseFields = query.select.filter(f => !isDslWindowField(f));
|
|
@@ -20,9 +20,6 @@ import type {
|
|
|
20
20
|
import { compileDsl, hasJsAggregates, hasWindowFunctions } from './dsl-compiler.js';
|
|
21
21
|
import { validateDsl, validateDslWithJoins } from './dsl-validator.js';
|
|
22
22
|
import { csvConnector } from './csv.js';
|
|
23
|
-
import { sqliteConnector } from './sqlite.js';
|
|
24
|
-
import { postgresConnector } from './postgres.js';
|
|
25
|
-
import { mysqlConnector } from './mysql.js';
|
|
26
23
|
import type { DslQueryResult } from './js-aggregation.js';
|
|
27
24
|
import { executeJsAggregation, executeJsAggregationWithWindows } from './js-aggregation.js';
|
|
28
25
|
|
|
@@ -37,26 +34,12 @@ function generateSourceId(name: string): string {
|
|
|
37
34
|
|
|
38
35
|
const CONNECTOR_MAP: Record<string, typeof csvConnector> = {
|
|
39
36
|
csv: csvConnector,
|
|
40
|
-
sqlite: sqliteConnector,
|
|
41
|
-
postgres: postgresConnector,
|
|
42
|
-
mysql: mysqlConnector,
|
|
43
37
|
};
|
|
44
38
|
|
|
45
39
|
function getConnectorForType(type: DataSourceType): typeof csvConnector | undefined {
|
|
46
40
|
return CONNECTOR_MAP[type];
|
|
47
41
|
}
|
|
48
42
|
|
|
49
|
-
const DIALECT_MAP: Record<string, 'sqlite' | 'postgres' | 'mysql'> = {
|
|
50
|
-
csv: 'sqlite',
|
|
51
|
-
sqlite: 'sqlite',
|
|
52
|
-
postgres: 'postgres',
|
|
53
|
-
mysql: 'mysql',
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
function dialectForType(type: DataSourceType): 'sqlite' | 'postgres' | 'mysql' {
|
|
57
|
-
return DIALECT_MAP[type] ?? 'sqlite';
|
|
58
|
-
}
|
|
59
|
-
|
|
60
43
|
/**
|
|
61
44
|
* Check if a query result contains an error encoded in the rows.
|
|
62
45
|
* Some connectors return errors this way instead of throwing.
|
|
@@ -297,21 +280,18 @@ export class SourceManager {
|
|
|
297
280
|
const validationError = await this.validateDslQuery(idOrName, table, dslQuery);
|
|
298
281
|
if (validationError) return { ok: false, error: validationError };
|
|
299
282
|
|
|
300
|
-
const
|
|
301
|
-
const dialect = dialectForType(entry.type);
|
|
302
|
-
|
|
303
|
-
const needsJsAgg = dialect !== 'postgres' && hasJsAggregates(dslQuery);
|
|
283
|
+
const needsJsAgg = hasJsAggregates(dslQuery);
|
|
304
284
|
const needsWindows = hasWindowFunctions(dslQuery);
|
|
305
285
|
|
|
306
286
|
if (needsJsAgg && needsWindows) {
|
|
307
|
-
return executeJsAggregationWithWindows(resolved.source, table, dslQuery,
|
|
287
|
+
return executeJsAggregationWithWindows(resolved.source, table, dslQuery, 'sqlite');
|
|
308
288
|
}
|
|
309
289
|
if (needsJsAgg) {
|
|
310
|
-
return executeJsAggregation(resolved.source, table, dslQuery,
|
|
290
|
+
return executeJsAggregation(resolved.source, table, dslQuery, 'sqlite');
|
|
311
291
|
}
|
|
312
292
|
|
|
313
293
|
// Pure SQL path — compileDsl handles CTE wrapping for window functions
|
|
314
|
-
const sql = compileDsl(table, dslQuery,
|
|
294
|
+
const sql = compileDsl(table, dslQuery, 'sqlite');
|
|
315
295
|
const result = await resolved.source.executeQuery(sql);
|
|
316
296
|
const errorMsg = hasErrorRow(result);
|
|
317
297
|
if (errorMsg) return { ok: false, error: errorMsg };
|
package/src/mcp/app-shell.ts
CHANGED
|
@@ -51,7 +51,7 @@ html, body {
|
|
|
51
51
|
.error-text { color: #ef4444; }
|
|
52
52
|
.spinner {
|
|
53
53
|
width: 24px; height: 24px; margin: 0 auto 12px;
|
|
54
|
-
border: 2px solid #374151; border-top-color: #
|
|
54
|
+
border: 2px solid #374151; border-top-color: #3366AA;
|
|
55
55
|
border-radius: 50%; animation: spin 0.8s linear infinite;
|
|
56
56
|
}
|
|
57
57
|
@keyframes spin { to { transform: rotate(360deg); } }
|
package/src/mcp/index.ts
CHANGED
|
@@ -7,17 +7,17 @@
|
|
|
7
7
|
*
|
|
8
8
|
* 17 tools:
|
|
9
9
|
* visualize — Inline data + intent → ranked visualization recommendations
|
|
10
|
-
*
|
|
10
|
+
* visualize_data — CSV data (DSL query) + intent → ranked visualization recommendations
|
|
11
11
|
* list_patterns — Browse all available visualization patterns
|
|
12
12
|
* refine_visualization — Tweak a visualization spec
|
|
13
|
-
* create_dashboard — Multi-view dashboard from a
|
|
13
|
+
* create_dashboard — Multi-view dashboard from a CSV dataset
|
|
14
14
|
* refine_dashboard — Iterate on a dashboard (add/remove views, layout, filters, theme)
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
15
|
+
* load_csv — Load a CSV file or directory
|
|
16
|
+
* list_data — List loaded datasets
|
|
17
|
+
* remove_data — Remove a loaded dataset
|
|
18
|
+
* describe_data — Re-examine column profiles and sample rows for a dataset
|
|
19
|
+
* analyze_data — Generate a structured analysis plan with DSL queries
|
|
20
|
+
* query_data — Run a declarative DSL query and see tabular results
|
|
21
21
|
* server_status — Inspect cached data in server memory
|
|
22
22
|
* clear_cache — Clear cached specs, results, and sessions
|
|
23
23
|
* export_html — Get the full rendered HTML for a visualization by specId
|
|
@@ -61,9 +61,10 @@ import { screenshotInputSchema, handleScreenshot, closeBrowser } from './tools/s
|
|
|
61
61
|
import { specStore } from './spec-store.js';
|
|
62
62
|
import { registerPrompts } from './prompts.js';
|
|
63
63
|
|
|
64
|
-
import { mkdirSync } from 'fs';
|
|
64
|
+
import { mkdirSync, readFileSync } from 'fs';
|
|
65
65
|
import { join } from 'path';
|
|
66
66
|
import { homedir } from 'os';
|
|
67
|
+
import { fileURLToPath } from 'url';
|
|
67
68
|
|
|
68
69
|
// Pattern library imports
|
|
69
70
|
import { registry } from '../patterns/registry.js';
|
|
@@ -81,29 +82,62 @@ const sourceManager = new SourceManager(join(dolexDir, 'sources.json'));
|
|
|
81
82
|
|
|
82
83
|
const serverStartTime = Date.now();
|
|
83
84
|
|
|
85
|
+
const __dirname = join(fileURLToPath(import.meta.url), '..');
|
|
86
|
+
const iconPath = join(__dirname, '..', '..', 'assets', 'icon.svg');
|
|
87
|
+
let serverIcons: Array<{ src: string; mimeType: string }> | undefined;
|
|
88
|
+
try {
|
|
89
|
+
const svgData = readFileSync(iconPath);
|
|
90
|
+
serverIcons = [{ src: `data:image/svg+xml;base64,${svgData.toString('base64')}`, mimeType: 'image/svg+xml' }];
|
|
91
|
+
} catch {}
|
|
92
|
+
|
|
84
93
|
// ─── CREATE SERVER ──────────────────────────────────────────────────────────
|
|
85
94
|
|
|
86
95
|
const server = new McpServer(
|
|
87
96
|
{
|
|
88
97
|
name: 'dolex',
|
|
89
|
-
version: '0.
|
|
98
|
+
version: '1.0.0',
|
|
99
|
+
...(serverIcons && { icons: serverIcons }),
|
|
90
100
|
},
|
|
91
101
|
{
|
|
92
102
|
instructions: [
|
|
93
|
-
'
|
|
103
|
+
'Dolex — CSV data analysis with 43 chart types.',
|
|
104
|
+
'',
|
|
105
|
+
'WORKFLOW:',
|
|
106
|
+
'• Got a CSV file? → load_csv(name, path) immediately, don\'t verify — this server runs locally on the user\'s machine',
|
|
107
|
+
'• Got inline data? → visualize(data, intent) directly',
|
|
108
|
+
'• Need to explore? → load_csv → analyze_data → visualize_data per step',
|
|
109
|
+
'• Need a dashboard? → load_csv → create_dashboard with views array',
|
|
110
|
+
'',
|
|
111
|
+
'CONTINUATION (dataset already loaded):',
|
|
112
|
+
'• Chart from data → visualize_data(sourceId, table, query, intent)',
|
|
113
|
+
'• Want to SEE rows (answer a question, validate data, show a table)? → query_data',
|
|
114
|
+
'• Want to CHART rows you already queried? → visualize(resultId=...) to reuse cached data',
|
|
115
|
+
'• Want a table view? → query_data for raw data, or visualize with includeDataTable=true for a formatted table with chart',
|
|
116
|
+
'• Tweak a chart → refine_visualization(specId, ...) — always use the MOST RECENT specId',
|
|
117
|
+
'• Tweak a dashboard → refine_dashboard(currentSpec, refinement)',
|
|
118
|
+
'• specId expired? → re-run the original visualize/visualize_data call, then continue refining from the new specId',
|
|
94
119
|
'',
|
|
95
|
-
'
|
|
96
|
-
'
|
|
97
|
-
'
|
|
120
|
+
'TOOL GUIDE:',
|
|
121
|
+
'• load_csv: Load a CSV file or directory. Returns sourceId.',
|
|
122
|
+
'• describe_data: See schema, stats, samples. Use detail="compact" for large schemas.',
|
|
123
|
+
'• analyze_data: Auto-generate analysis plan with ready DSL queries. Execute each step with visualize_data; present results one at a time.',
|
|
124
|
+
'• query_data: Run DSL query, get rows. Returns resultId for visualize().',
|
|
125
|
+
'• visualize: Chart from inline data OR resultId from query_data. Auto-selects best pattern. Set title/subtitle here to avoid a refine round-trip.',
|
|
126
|
+
'• visualize_data: Chart from loaded CSV + DSL query. Same as visualize but queries server-side — saves tokens.',
|
|
127
|
+
'• refine_visualization: Tweak a chart — sort, limit, filter, palette, highlight, flip, title, format. Each call returns a new specId.',
|
|
128
|
+
'• create_dashboard: Multi-chart layout from loaded data with per-view queries.',
|
|
129
|
+
'• refine_dashboard: Iterate dashboard — add/remove views, filters, layout, theme.',
|
|
130
|
+
'• list_patterns: Browse available chart types. Only needed when the user asks what charts are available or you need a pattern ID.',
|
|
98
131
|
'',
|
|
99
|
-
'
|
|
100
|
-
'add_source CANNOT access: /mnt/user-data/*, /home/claude/* (cloud sandbox only).',
|
|
132
|
+
'Utility tools: list_data, remove_data, server_status (inspect cached data), clear_cache, report_bug (generate GitHub issue), export_html (get chart HTML by specId), screenshot (render to PNG).',
|
|
101
133
|
'',
|
|
102
|
-
'
|
|
103
|
-
'
|
|
134
|
+
'COLOR: Set palette (categorical/blue/warm/blueRed/etc.) and/or highlight specific values. Use colorField to control which column drives color.',
|
|
135
|
+
'PATTERNS: 43 types auto-selected by data shape + intent. When user names a specific chart type, pass pattern="<id>" to force it. Use list_patterns to browse.',
|
|
104
136
|
'',
|
|
105
|
-
'
|
|
106
|
-
'
|
|
137
|
+
'ERRORS: If a DSL query fails with field name suggestions, retry with the corrected name. If specId is expired, re-run visualize.',
|
|
138
|
+
'',
|
|
139
|
+
'DON\'T use Dolex for: simple arithmetic, explanations of chart types, non-data questions, or file format conversions (CSV export, PowerPoint, etc.).',
|
|
140
|
+
'DO use Dolex when the user asks "what chart should I use" — run visualize and let the pattern selector recommend.',
|
|
107
141
|
].join('\n'),
|
|
108
142
|
},
|
|
109
143
|
);
|
|
@@ -138,7 +172,7 @@ registerAppTool(
|
|
|
138
172
|
'visualize',
|
|
139
173
|
{
|
|
140
174
|
title: 'Visualize Data',
|
|
141
|
-
description: '
|
|
175
|
+
description: 'Chart inline data or cached query results. Pass data array + intent, OR resultId from query_data.\n\nWhen to use: You have data in the conversation (pasted, generated, or from query_data resultId). Use visualize_data instead when data lives in a loaded CSV — saves tokens.\n\nKey params: pattern (force a specific chart type), palette, highlight, colorField, title, subtitle.\n\nResponse: specId (use in refine calls — always use the most recent one), recommended pattern + reasoning, alternatives, data shape summary. Chart HTML in structuredContent. If the response includes notes, present each note to the user — they explain decisions the system made automatically.',
|
|
142
176
|
inputSchema: visualizeInputSchema.shape,
|
|
143
177
|
_meta: {
|
|
144
178
|
ui: {
|
|
@@ -152,13 +186,13 @@ registerAppTool(
|
|
|
152
186
|
handleVisualize(selectPatternCallback),
|
|
153
187
|
);
|
|
154
188
|
|
|
155
|
-
//
|
|
189
|
+
// CSV data visualization tool
|
|
156
190
|
registerAppTool(
|
|
157
191
|
server,
|
|
158
|
-
'
|
|
192
|
+
'visualize_data',
|
|
159
193
|
{
|
|
160
|
-
title: 'Visualize
|
|
161
|
-
description: '
|
|
194
|
+
title: 'Visualize Data',
|
|
195
|
+
description: 'Chart data from a loaded CSV. Queries server-side — no data in the context window.\n\nWhen to use: CSV already loaded via load_csv. Prefer this over query_data + visualize for one-step charting.\n\nKey params: sourceId, table, query (DSL: { select, groupBy, filter, orderBy, limit }), intent, pattern, palette, highlight, colorField.\n\nResponse: Same as visualize — specId, pattern, alternatives, chart HTML.',
|
|
162
196
|
inputSchema: visualizeFromSourceInputSchema.shape,
|
|
163
197
|
_meta: {
|
|
164
198
|
ui: {
|
|
@@ -176,7 +210,7 @@ server.registerTool(
|
|
|
176
210
|
'list_patterns',
|
|
177
211
|
{
|
|
178
212
|
title: 'List Visualization Patterns',
|
|
179
|
-
description: 'Browse all
|
|
213
|
+
description: 'Browse all 43 chart types with data requirements, capabilities, and examples. Returns per-pattern color encoding support and config options.\n\nWhen to use: User asks what charts are available, or you need to look up a pattern ID for the pattern parameter.',
|
|
180
214
|
},
|
|
181
215
|
handleListPatterns(() => registry.getAll()),
|
|
182
216
|
);
|
|
@@ -186,7 +220,7 @@ registerAppTool(
|
|
|
186
220
|
'refine_visualization',
|
|
187
221
|
{
|
|
188
222
|
title: 'Refine Visualization',
|
|
189
|
-
description: 'Tweak a
|
|
223
|
+
description: 'Tweak a chart using structured parameters. Pass specId from a previous visualize or refine call.\n\nAlways use the most recent specId — each refine returns a new one that includes all previous changes. If the response includes notes, present each note to the user.\n\nParameters (all optional except specId):\n• sort: { direction: "asc"|"desc", field?: "column_name" } — if field omitted, sorts by primary measure axis\n• limit: number (top N rows)\n• filter: [{ field: "col", op: "in"|"not_in"|"gt"|"gte"|"lt"|"lte", values: [...] }] — pass [] to clear filters\n• flip: true (swap axes — Cartesian charts only)\n• title / subtitle / xLabel / yLabel: strings\n• palette: "categorical"|"blue"|"warm"|"blueRed"|"green"|"purple"|"greenPurple"|"tealOrange"|"redGreen"|"traffic-light"|"profit-loss"|"temperature"\n• highlight: { values: ["val1", "val2"], color?: "css-color", mutedOpacity?: 0.3 } — pass null to clear\n• colorField: "column_name" (which field drives color)\n• flowColorBy: "source"|"target" (alluvial charts only)\n• format: "percent"|"dollar"|"integer"|"decimal"|"compact"\n• switchPattern: "pattern-id" (switch chart type)\n\nCompound chart params: removeTable, layout ("rows"|"columns"), hideColumns (array of column names to hide from data table).\n\nReturns new specId + changes applied + available alternatives.',
|
|
190
224
|
inputSchema: refineInputSchema.shape,
|
|
191
225
|
_meta: {
|
|
192
226
|
ui: {
|
|
@@ -200,61 +234,61 @@ registerAppTool(
|
|
|
200
234
|
handleRefine(),
|
|
201
235
|
);
|
|
202
236
|
|
|
203
|
-
//
|
|
237
|
+
// CSV data management tools
|
|
204
238
|
server.registerTool(
|
|
205
|
-
'
|
|
239
|
+
'load_csv',
|
|
206
240
|
{
|
|
207
|
-
title: '
|
|
208
|
-
description: '
|
|
241
|
+
title: 'Load CSV Data',
|
|
242
|
+
description: 'Load a CSV file or directory of CSV files. Call this immediately with any user-provided path — this server runs locally on the user\'s machine.\n\nDatasets persist across restarts.\n\nKey params: detail="compact" for just column names/types (saves tokens), detail="full" for stats + samples (default).\n\nReturns sourceId (use in all subsequent data operations).',
|
|
209
243
|
inputSchema: addSourceInputSchema,
|
|
210
244
|
},
|
|
211
245
|
handleAddSource({ sourceManager }),
|
|
212
246
|
);
|
|
213
247
|
|
|
214
248
|
server.registerTool(
|
|
215
|
-
'
|
|
249
|
+
'list_data',
|
|
216
250
|
{
|
|
217
|
-
title: 'List Data
|
|
218
|
-
description: 'List all
|
|
251
|
+
title: 'List Loaded Data',
|
|
252
|
+
description: 'List all loaded datasets with IDs and table counts.',
|
|
219
253
|
},
|
|
220
254
|
handleListSources({ sourceManager }),
|
|
221
255
|
);
|
|
222
256
|
|
|
223
257
|
server.registerTool(
|
|
224
|
-
'
|
|
258
|
+
'remove_data',
|
|
225
259
|
{
|
|
226
|
-
title: 'Remove Data
|
|
227
|
-
description: '
|
|
260
|
+
title: 'Remove Data',
|
|
261
|
+
description: 'Remove a loaded dataset by ID.',
|
|
228
262
|
inputSchema: removeSourceInputSchema,
|
|
229
263
|
},
|
|
230
264
|
handleRemoveSource({ sourceManager }),
|
|
231
265
|
);
|
|
232
266
|
|
|
233
267
|
server.registerTool(
|
|
234
|
-
'
|
|
268
|
+
'describe_data',
|
|
235
269
|
{
|
|
236
|
-
title: 'Describe Data
|
|
237
|
-
description: '
|
|
270
|
+
title: 'Describe Data',
|
|
271
|
+
description: 'Examine column profiles for a loaded dataset. Use to re-inspect data mid-conversation.\n\nKey params: detail="compact" for column names/types only (saves tokens), detail="full" for stats + samples (default).',
|
|
238
272
|
inputSchema: describeSourceInputSchema,
|
|
239
273
|
},
|
|
240
274
|
handleDescribeSource({ sourceManager }),
|
|
241
275
|
);
|
|
242
276
|
|
|
243
277
|
server.registerTool(
|
|
244
|
-
'
|
|
278
|
+
'analyze_data',
|
|
245
279
|
{
|
|
246
|
-
title: 'Analyze Data
|
|
247
|
-
description: '
|
|
280
|
+
title: 'Analyze Data',
|
|
281
|
+
description: 'Auto-generate a structured analysis plan with ready-to-execute DSL queries. Returns 4-6 analysis steps covering trends, comparisons, distributions, and relationships.\n\nWhen to use: After load_csv, to get an automatic data exploration plan. Execute each step with visualize_data and present results one at a time.',
|
|
248
282
|
inputSchema: analyzeSourceInputSchema.shape,
|
|
249
283
|
},
|
|
250
284
|
handleAnalyzeSource({ sourceManager }),
|
|
251
285
|
);
|
|
252
286
|
|
|
253
287
|
server.registerTool(
|
|
254
|
-
'
|
|
288
|
+
'query_data',
|
|
255
289
|
{
|
|
256
|
-
title: 'Query Data
|
|
257
|
-
description: 'Run a
|
|
290
|
+
title: 'Query Data',
|
|
291
|
+
description: 'Run a DSL query and get tabular results. Returns resultId — pass to visualize(resultId=...) to chart the same data without re-sending rows.\n\nWhen to use: Need to see raw data, answer a data question, or validate before charting. For one-step charting, use visualize_data instead.\n\nKey params: sourceId, table, query (DSL: { select, groupBy, filter, join, orderBy, limit }).',
|
|
258
292
|
inputSchema: querySourceInputSchema,
|
|
259
293
|
},
|
|
260
294
|
handleQuerySource({ sourceManager }),
|
|
@@ -266,7 +300,7 @@ registerAppTool(
|
|
|
266
300
|
'create_dashboard',
|
|
267
301
|
{
|
|
268
302
|
title: 'Create Dashboard',
|
|
269
|
-
description: 'Create a multi-view dashboard from a
|
|
303
|
+
description: 'Create a multi-view dashboard from a loaded CSV dataset. Each view has its own DSL query and intent.\n\nKey params: sourceId, table, views (array with id, title, intent, query per view), layout, filters.\n\nReturns DashboardSpec (pass to refine_dashboard for iterations) + rendered HTML.',
|
|
270
304
|
inputSchema: createDashboardInputSchema.shape,
|
|
271
305
|
_meta: {
|
|
272
306
|
ui: {
|
|
@@ -285,7 +319,7 @@ registerAppTool(
|
|
|
285
319
|
'refine_dashboard',
|
|
286
320
|
{
|
|
287
321
|
title: 'Refine Dashboard',
|
|
288
|
-
description: 'Iterate on a dashboard
|
|
322
|
+
description: 'Iterate on a dashboard using natural language. Pass currentSpec from create_dashboard or previous refine.\n\nUnlike refine_visualization which uses structured parameters, this tool accepts natural language descriptions of changes.\n\nExamples: "add a chart showing revenue by month", "remove the bar chart", "3 columns", "add region filter", "dark mode".\n\nReturns updated DashboardSpec + rendered HTML.',
|
|
289
323
|
inputSchema: refineDashboardInputSchema.shape,
|
|
290
324
|
_meta: {
|
|
291
325
|
ui: {
|
|
@@ -306,7 +340,7 @@ server.registerTool(
|
|
|
306
340
|
'server_status',
|
|
307
341
|
{
|
|
308
342
|
title: 'Server Status',
|
|
309
|
-
description: '
|
|
343
|
+
description: 'Inspect cached data in server memory: specs with row counts, query results, connected sources, uptime. Use before clear_cache.',
|
|
310
344
|
},
|
|
311
345
|
handleServerStatus(privacyDeps),
|
|
312
346
|
);
|
|
@@ -315,7 +349,7 @@ server.registerTool(
|
|
|
315
349
|
'clear_cache',
|
|
316
350
|
{
|
|
317
351
|
title: 'Clear Cache',
|
|
318
|
-
description: '
|
|
352
|
+
description: 'Clear cached data from memory. Scope: "all" (specs + results), "specs" (visualization specs), "results" (query cache). Use after working with sensitive data.',
|
|
319
353
|
inputSchema: clearCacheInputSchema,
|
|
320
354
|
},
|
|
321
355
|
handleClearCache(privacyDeps),
|
|
@@ -325,7 +359,7 @@ server.registerTool(
|
|
|
325
359
|
'report_bug',
|
|
326
360
|
{
|
|
327
361
|
title: 'Report Bug',
|
|
328
|
-
description: 'Generate a sanitized bug report for
|
|
362
|
+
description: 'Generate a sanitized bug report for GitHub issues. Includes environment info and recent operations — never includes data values or file paths.',
|
|
329
363
|
inputSchema: bugReportInputSchema.shape,
|
|
330
364
|
},
|
|
331
365
|
handleReportBug({ sourceManager, serverStartTime }),
|
|
@@ -335,7 +369,7 @@ server.registerTool(
|
|
|
335
369
|
'export_html',
|
|
336
370
|
{
|
|
337
371
|
title: 'Export Chart HTML',
|
|
338
|
-
description: '
|
|
372
|
+
description: 'Get the full self-contained HTML for a visualization by specId. Suitable for saving to file or opening in a browser.',
|
|
339
373
|
inputSchema: exportHtmlInputSchema.shape,
|
|
340
374
|
},
|
|
341
375
|
handleExportHtml(),
|
|
@@ -345,7 +379,7 @@ server.registerTool(
|
|
|
345
379
|
'screenshot',
|
|
346
380
|
{
|
|
347
381
|
title: 'Screenshot Visualization',
|
|
348
|
-
description: 'Render a visualization to
|
|
382
|
+
description: 'Render a visualization to PNG via headless Chromium. Returns base64-encoded image. Requires Playwright: npm install playwright && npx playwright install chromium.',
|
|
349
383
|
inputSchema: screenshotInputSchema.shape,
|
|
350
384
|
},
|
|
351
385
|
handleScreenshot(),
|
package/src/mcp/prompts.ts
CHANGED
|
@@ -8,7 +8,7 @@ export function registerPrompts(server: McpServer) {
|
|
|
8
8
|
title: 'Explore a Dataset',
|
|
9
9
|
description: 'Drop a data file and get automatic analysis — like having a data analyst at your desk',
|
|
10
10
|
argsSchema: {
|
|
11
|
-
path: z.string().describe('
|
|
11
|
+
path: z.string().describe('Path to a CSV file or directory of CSV files'),
|
|
12
12
|
},
|
|
13
13
|
},
|
|
14
14
|
async ({ path }) => ({
|
|
@@ -20,9 +20,9 @@ export function registerPrompts(server: McpServer) {
|
|
|
20
20
|
`I want to explore a dataset. The file path is: ${path}`,
|
|
21
21
|
'',
|
|
22
22
|
'Please:',
|
|
23
|
-
'1.
|
|
24
|
-
'2. Call
|
|
25
|
-
'3. For each step in the plan, call
|
|
23
|
+
'1. Load it using load_csv',
|
|
24
|
+
'2. Call analyze_data to get an automatic analysis plan',
|
|
25
|
+
'3. For each step in the plan, call visualize_data with the provided query and use one of the suggested patterns',
|
|
26
26
|
'4. After each chart, write a 2-3 sentence finding explaining what the data reveals — be specific about numbers, trends, and outliers',
|
|
27
27
|
'5. End with a "Key Takeaways" summary',
|
|
28
28
|
'',
|
package/src/mcp/spec-store.ts
CHANGED
|
@@ -18,6 +18,7 @@ export interface StoredSpec {
|
|
|
18
18
|
spec: VisualizationSpec | CompoundVisualizationSpec;
|
|
19
19
|
columns: DataColumn[];
|
|
20
20
|
alternatives: Map<string, VisualizationSpec>;
|
|
21
|
+
originalData?: Record<string, any>[];
|
|
21
22
|
createdAt: number;
|
|
22
23
|
}
|
|
23
24
|
|
|
@@ -47,6 +48,7 @@ export class SpecStore {
|
|
|
47
48
|
spec: VisualizationSpec | CompoundVisualizationSpec,
|
|
48
49
|
columns: DataColumn[],
|
|
49
50
|
alternatives: Map<string, VisualizationSpec> = new Map(),
|
|
51
|
+
originalData?: Record<string, any>[],
|
|
50
52
|
): string {
|
|
51
53
|
this.purgeExpired();
|
|
52
54
|
|
|
@@ -60,6 +62,7 @@ export class SpecStore {
|
|
|
60
62
|
spec,
|
|
61
63
|
columns,
|
|
62
64
|
alternatives,
|
|
65
|
+
originalData,
|
|
63
66
|
createdAt: Date.now(),
|
|
64
67
|
});
|
|
65
68
|
return id;
|
|
@@ -82,7 +85,8 @@ export class SpecStore {
|
|
|
82
85
|
const existing = this.store.get(specId);
|
|
83
86
|
const columns = existing?.columns ?? [];
|
|
84
87
|
const alternatives = existing?.alternatives ?? new Map<string, VisualizationSpec>();
|
|
85
|
-
|
|
88
|
+
const originalData = existing?.originalData;
|
|
89
|
+
return this.save(newSpec, columns, alternatives, originalData);
|
|
86
90
|
}
|
|
87
91
|
|
|
88
92
|
getAlternative(specId: string, patternId: string): VisualizationSpec | null {
|
package/src/mcp/tools/analyze.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* MCP Tool:
|
|
2
|
+
* MCP Tool: analyze_data
|
|
3
3
|
* Examines a data source and generates a structured analysis plan with DSL queries.
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -8,7 +8,7 @@ import { buildAnalysisPlan } from '../../analysis/planner.js';
|
|
|
8
8
|
import { errorResponse, jsonResponse } from './shared.js';
|
|
9
9
|
|
|
10
10
|
export const analyzeSourceInputSchema = z.object({
|
|
11
|
-
sourceId: z.string().describe('
|
|
11
|
+
sourceId: z.string().describe('Dataset ID returned by load_csv'),
|
|
12
12
|
table: z.string().optional().describe('Table to analyze (defaults to first table)'),
|
|
13
13
|
maxSteps: z.number().min(1).max(10).optional().describe('Maximum analysis steps (default: 6)'),
|
|
14
14
|
});
|
|
@@ -56,7 +56,6 @@ export function sanitizeSpecConfig(config: Record<string, unknown>): Record<stri
|
|
|
56
56
|
|
|
57
57
|
export function sanitizeError(error: string): string {
|
|
58
58
|
return error
|
|
59
|
-
.replace(/(?:postgres|mysql|sqlite):\/\/[^\s]+/g, '<connection-string>')
|
|
60
59
|
.replace(/\/[\w/.~-]+/g, '<path>')
|
|
61
60
|
.replace(/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z]{2,}\b/gi, '<email>');
|
|
62
61
|
}
|
|
@@ -158,14 +157,7 @@ export function handleReportBug(deps: ReportDeps) {
|
|
|
158
157
|
|
|
159
158
|
const specStats = specStore.stats();
|
|
160
159
|
const resultStats = resultCacheStats();
|
|
161
|
-
const
|
|
162
|
-
const sourceTypes: Record<string, number> = {};
|
|
163
|
-
for (const s of sources) {
|
|
164
|
-
sourceTypes[s.type] = (sourceTypes[s.type] || 0) + 1;
|
|
165
|
-
}
|
|
166
|
-
const sourceTypeSummary = Object.entries(sourceTypes)
|
|
167
|
-
.map(([t, c]) => `${t}: ${c}`)
|
|
168
|
-
.join(', ') || 'none';
|
|
160
|
+
const datasets = deps.sourceManager.list();
|
|
169
161
|
|
|
170
162
|
sections.push([
|
|
171
163
|
'## Server State',
|
|
@@ -173,7 +165,7 @@ export function handleReportBug(deps: ReportDeps) {
|
|
|
173
165
|
`- **Uptime**: ${formatUptime(Date.now() - deps.serverStartTime)}`,
|
|
174
166
|
`- **Cached specs**: ${specStats.entries}`,
|
|
175
167
|
`- **Cached results**: ${resultStats.entries}`,
|
|
176
|
-
`- **
|
|
168
|
+
`- **Datasets**: ${datasets.length}`,
|
|
177
169
|
].join('\n'));
|
|
178
170
|
|
|
179
171
|
const report = sections.join('\n\n');
|
|
@@ -24,7 +24,7 @@ export function handleCreateDashboard(deps: { sourceManager: any }) {
|
|
|
24
24
|
return async (args: z.infer<typeof createDashboardInputSchema>) => {
|
|
25
25
|
const sourceInfo = deps.sourceManager.get(args.sourceId);
|
|
26
26
|
if (!sourceInfo) {
|
|
27
|
-
return errorResponse(`
|
|
27
|
+
return errorResponse(`Dataset not found: ${args.sourceId}. Use load_csv first.`);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
const result = await executeDashboardViews(
|