@outsidedata/dolex 0.2.0 → 1.0.1
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 +15 -13
- package/dist/src/connectors/dsl-compiler.d.ts +3 -6
- package/dist/src/connectors/dsl-compiler.d.ts.map +1 -1
- package/dist/src/connectors/dsl-compiler.js +23 -63
- package/dist/src/connectors/dsl-compiler.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 +4 -4
- 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 +51 -51
- 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/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 +1 -1
- package/dist/src/mcp/tools/dsl-schemas.js +2 -2
- 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/query-source.d.ts +1 -1
- 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 +2 -2
- 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/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 +1 -1
- package/dist/src/mcp/tools/visualize-from-source.js +4 -4
- package/dist/src/mcp/tools/visualize-from-source.js.map +1 -1
- package/dist/src/mcp/tools/visualize.d.ts +2 -2
- package/dist/src/mcp/tools/visualize.js +5 -5
- package/dist/src/mcp/tools/visualize.js.map +1 -1
- package/dist/src/renderers/html/builders/dashboard.js +2 -2
- package/dist/src/types.d.ts +3 -24
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js.map +1 -1
- package/package.json +1 -4
- package/src/connectors/dsl-compiler.ts +22 -64
- package/src/connectors/index.ts +0 -3
- package/src/connectors/js-aggregation.ts +4 -4
- package/src/connectors/manager.ts +4 -24
- package/src/mcp/app-shell.ts +1 -1
- package/src/mcp/index.ts +51 -51
- package/src/mcp/prompts.ts +4 -4
- 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 +2 -2
- package/src/mcp/tools/export-html.ts +2 -2
- package/src/mcp/tools/query-source.ts +4 -4
- 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/sources.ts +18 -46
- package/src/mcp/tools/visualize-from-source.ts +4 -4
- package/src/mcp/tools/visualize.ts +5 -5
- package/src/renderers/html/builders/dashboard.ts +2 -2
- package/src/types.ts +3 -31
- package/src/connectors/mysql.ts +0 -378
- package/src/connectors/postgres.ts +0 -367
- package/src/connectors/sqlite.ts +0 -364
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
|
|
@@ -95,41 +95,41 @@ try {
|
|
|
95
95
|
const server = new McpServer(
|
|
96
96
|
{
|
|
97
97
|
name: 'dolex',
|
|
98
|
-
version: '0.
|
|
98
|
+
version: '1.0.0',
|
|
99
99
|
...(serverIcons && { icons: serverIcons }),
|
|
100
100
|
},
|
|
101
101
|
{
|
|
102
102
|
instructions: [
|
|
103
|
-
'Dolex —
|
|
103
|
+
'Dolex — CSV data analysis with 43 chart types.',
|
|
104
104
|
'',
|
|
105
105
|
'WORKFLOW:',
|
|
106
|
-
'• Got a file
|
|
106
|
+
'• Got a CSV file? → load_csv(name, path) immediately, don\'t verify — this server runs locally on the user\'s machine',
|
|
107
107
|
'• Got inline data? → visualize(data, intent) directly',
|
|
108
|
-
'• Need to explore? →
|
|
109
|
-
'• Need a dashboard? →
|
|
108
|
+
'• Need to explore? → load_csv → analyze_data → visualize_data per step',
|
|
109
|
+
'• Need a dashboard? → load_csv → create_dashboard with views array',
|
|
110
110
|
'',
|
|
111
|
-
'CONTINUATION (
|
|
112
|
-
'• Chart from
|
|
113
|
-
'• Want to SEE rows (answer a question, validate data, show a table)? →
|
|
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
114
|
'• Want to CHART rows you already queried? → visualize(resultId=...) to reuse cached data',
|
|
115
|
-
'• Want a table view? →
|
|
115
|
+
'• Want a table view? → query_data for raw data, or visualize with includeDataTable=true for a formatted table with chart',
|
|
116
116
|
'• Tweak a chart → refine_visualization(specId, ...) — always use the MOST RECENT specId',
|
|
117
117
|
'• Tweak a dashboard → refine_dashboard(currentSpec, refinement)',
|
|
118
|
-
'• specId expired? → re-run the original visualize/
|
|
118
|
+
'• specId expired? → re-run the original visualize/visualize_data call, then continue refining from the new specId',
|
|
119
119
|
'',
|
|
120
120
|
'TOOL GUIDE:',
|
|
121
|
-
'•
|
|
122
|
-
'•
|
|
123
|
-
'•
|
|
124
|
-
'•
|
|
125
|
-
'• visualize: Chart from inline data OR resultId from
|
|
126
|
-
'•
|
|
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
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
|
|
128
|
+
'• create_dashboard: Multi-chart layout from loaded data with per-view queries.',
|
|
129
129
|
'• refine_dashboard: Iterate dashboard — add/remove views, filters, layout, theme.',
|
|
130
130
|
'• list_patterns: Browse available chart types. Only needed when the user asks what charts are available or you need a pattern ID.',
|
|
131
131
|
'',
|
|
132
|
-
'Utility tools:
|
|
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).',
|
|
133
133
|
'',
|
|
134
134
|
'COLOR: Set palette (categorical/blue/warm/blueRed/etc.) and/or highlight specific values. Use colorField to control which column drives color.',
|
|
135
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.',
|
|
@@ -172,7 +172,7 @@ registerAppTool(
|
|
|
172
172
|
'visualize',
|
|
173
173
|
{
|
|
174
174
|
title: 'Visualize Data',
|
|
175
|
-
description: 'Chart inline data or cached query results. Pass data array + intent, OR resultId from
|
|
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.',
|
|
176
176
|
inputSchema: visualizeInputSchema.shape,
|
|
177
177
|
_meta: {
|
|
178
178
|
ui: {
|
|
@@ -186,13 +186,13 @@ registerAppTool(
|
|
|
186
186
|
handleVisualize(selectPatternCallback),
|
|
187
187
|
);
|
|
188
188
|
|
|
189
|
-
//
|
|
189
|
+
// CSV data visualization tool
|
|
190
190
|
registerAppTool(
|
|
191
191
|
server,
|
|
192
|
-
'
|
|
192
|
+
'visualize_data',
|
|
193
193
|
{
|
|
194
|
-
title: 'Visualize
|
|
195
|
-
description: 'Chart data from a
|
|
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.',
|
|
196
196
|
inputSchema: visualizeFromSourceInputSchema.shape,
|
|
197
197
|
_meta: {
|
|
198
198
|
ui: {
|
|
@@ -234,61 +234,61 @@ registerAppTool(
|
|
|
234
234
|
handleRefine(),
|
|
235
235
|
);
|
|
236
236
|
|
|
237
|
-
//
|
|
237
|
+
// CSV data management tools
|
|
238
238
|
server.registerTool(
|
|
239
|
-
'
|
|
239
|
+
'load_csv',
|
|
240
240
|
{
|
|
241
|
-
title: '
|
|
242
|
-
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).',
|
|
243
243
|
inputSchema: addSourceInputSchema,
|
|
244
244
|
},
|
|
245
245
|
handleAddSource({ sourceManager }),
|
|
246
246
|
);
|
|
247
247
|
|
|
248
248
|
server.registerTool(
|
|
249
|
-
'
|
|
249
|
+
'list_data',
|
|
250
250
|
{
|
|
251
|
-
title: 'List Data
|
|
252
|
-
description: 'List all
|
|
251
|
+
title: 'List Loaded Data',
|
|
252
|
+
description: 'List all loaded datasets with IDs and table counts.',
|
|
253
253
|
},
|
|
254
254
|
handleListSources({ sourceManager }),
|
|
255
255
|
);
|
|
256
256
|
|
|
257
257
|
server.registerTool(
|
|
258
|
-
'
|
|
258
|
+
'remove_data',
|
|
259
259
|
{
|
|
260
|
-
title: 'Remove Data
|
|
261
|
-
description: '
|
|
260
|
+
title: 'Remove Data',
|
|
261
|
+
description: 'Remove a loaded dataset by ID.',
|
|
262
262
|
inputSchema: removeSourceInputSchema,
|
|
263
263
|
},
|
|
264
264
|
handleRemoveSource({ sourceManager }),
|
|
265
265
|
);
|
|
266
266
|
|
|
267
267
|
server.registerTool(
|
|
268
|
-
'
|
|
268
|
+
'describe_data',
|
|
269
269
|
{
|
|
270
|
-
title: 'Describe Data
|
|
271
|
-
description: 'Examine column profiles for a
|
|
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).',
|
|
272
272
|
inputSchema: describeSourceInputSchema,
|
|
273
273
|
},
|
|
274
274
|
handleDescribeSource({ sourceManager }),
|
|
275
275
|
);
|
|
276
276
|
|
|
277
277
|
server.registerTool(
|
|
278
|
-
'
|
|
278
|
+
'analyze_data',
|
|
279
279
|
{
|
|
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
|
|
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.',
|
|
282
282
|
inputSchema: analyzeSourceInputSchema.shape,
|
|
283
283
|
},
|
|
284
284
|
handleAnalyzeSource({ sourceManager }),
|
|
285
285
|
);
|
|
286
286
|
|
|
287
287
|
server.registerTool(
|
|
288
|
-
'
|
|
288
|
+
'query_data',
|
|
289
289
|
{
|
|
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
|
|
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 }).',
|
|
292
292
|
inputSchema: querySourceInputSchema,
|
|
293
293
|
},
|
|
294
294
|
handleQuerySource({ sourceManager }),
|
|
@@ -300,7 +300,7 @@ registerAppTool(
|
|
|
300
300
|
'create_dashboard',
|
|
301
301
|
{
|
|
302
302
|
title: 'Create Dashboard',
|
|
303
|
-
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.',
|
|
304
304
|
inputSchema: createDashboardInputSchema.shape,
|
|
305
305
|
_meta: {
|
|
306
306
|
ui: {
|
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/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(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Shared Zod schemas for the query DSL.
|
|
3
|
-
* Used by both
|
|
3
|
+
* Used by both query_data and visualize_data tools.
|
|
4
4
|
*/
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
|
|
@@ -233,7 +233,7 @@ export const dashboardInteractionSchema = z.object({
|
|
|
233
233
|
});
|
|
234
234
|
|
|
235
235
|
export const createDashboardInputSchema = z.object({
|
|
236
|
-
sourceId: z.string().describe('
|
|
236
|
+
sourceId: z.string().describe('Dataset ID returned by load_csv'),
|
|
237
237
|
table: z.string().describe('Base table within the source'),
|
|
238
238
|
title: z.string().optional().describe('Dashboard title'),
|
|
239
239
|
description: z.string().optional().describe('Dashboard description'),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* MCP Tool: export_html
|
|
3
3
|
* Returns the full rendered HTML for a previously-created visualization.
|
|
4
|
-
* Accepts a specId from a visualize,
|
|
4
|
+
* Accepts a specId from a visualize, visualize_data, or refine call.
|
|
5
5
|
*
|
|
6
6
|
* Designed for programmatic consumption — the returned HTML is a complete,
|
|
7
7
|
* self-contained document that can be opened in a browser or screenshotted.
|
|
@@ -15,7 +15,7 @@ import { specStore } from '../spec-store.js';
|
|
|
15
15
|
import { errorResponse } from './shared.js';
|
|
16
16
|
|
|
17
17
|
export const exportHtmlInputSchema = z.object({
|
|
18
|
-
specId: z.string().describe('Spec ID from a previous visualize,
|
|
18
|
+
specId: z.string().describe('Spec ID from a previous visualize, visualize_data, or refine call'),
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
export function handleExportHtml() {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* MCP Tool:
|
|
2
|
+
* MCP Tool: query_data
|
|
3
3
|
* Execute a DSL query against a source and return tabular results.
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -10,7 +10,7 @@ import { errorResponse, jsonResponse } from './shared.js';
|
|
|
10
10
|
import { logOperation, extractDslStructure } from './operation-log.js';
|
|
11
11
|
|
|
12
12
|
export const querySourceInputSchema = z.object({
|
|
13
|
-
sourceId: z.string().describe('
|
|
13
|
+
sourceId: z.string().describe('Dataset ID returned by load_csv'),
|
|
14
14
|
table: z.string().describe('Table name within the source'),
|
|
15
15
|
query: dslQuerySchema.describe('Declarative query (join, select, groupBy, filter, orderBy, limit). Use join to combine tables; use table.field dot notation for joined table fields. Example: { select: ["region", { field: "revenue", aggregate: "sum", as: "total" }], groupBy: ["region"], orderBy: [{ field: "total", direction: "desc" }], limit: 10 }'),
|
|
16
16
|
maxRows: z.number().optional().describe('Max rows to return (default: 20)'),
|
|
@@ -28,7 +28,7 @@ export function handleQuerySource(deps: { sourceManager: any }) {
|
|
|
28
28
|
const result = await deps.sourceManager.queryDsl(args.sourceId, args.table, query);
|
|
29
29
|
if (!result.ok) {
|
|
30
30
|
logOperation({
|
|
31
|
-
toolName: '
|
|
31
|
+
toolName: 'query_data',
|
|
32
32
|
timestamp: start,
|
|
33
33
|
durationMs: Date.now() - start,
|
|
34
34
|
success: false,
|
|
@@ -43,7 +43,7 @@ export function handleQuerySource(deps: { sourceManager: any }) {
|
|
|
43
43
|
const resultId = saveResult(result.rows, result.columns);
|
|
44
44
|
|
|
45
45
|
logOperation({
|
|
46
|
-
toolName: '
|
|
46
|
+
toolName: 'query_data',
|
|
47
47
|
timestamp: start,
|
|
48
48
|
durationMs: Date.now() - start,
|
|
49
49
|
success: true,
|
|
@@ -14,7 +14,7 @@ import { specStore } from '../spec-store.js';
|
|
|
14
14
|
import { errorResponse } from './shared.js';
|
|
15
15
|
|
|
16
16
|
export const screenshotInputSchema = z.object({
|
|
17
|
-
specId: z.string().describe('Spec ID from a previous visualize,
|
|
17
|
+
specId: z.string().describe('Spec ID from a previous visualize, visualize_data, or refine call'),
|
|
18
18
|
width: z.number().optional().describe('Image width in pixels (default: 800)'),
|
|
19
19
|
height: z.number().optional().describe('Image height in pixels (default: 600)'),
|
|
20
20
|
});
|
|
@@ -27,11 +27,10 @@ export function handleServerStatus(deps: PrivacyDeps) {
|
|
|
27
27
|
const specStats = specStore.stats();
|
|
28
28
|
const resultStats = resultCacheStats();
|
|
29
29
|
|
|
30
|
-
const
|
|
31
|
-
const
|
|
30
|
+
const datasets = deps.sourceManager.list();
|
|
31
|
+
const datasetsSummary = datasets.map((s: any) => ({
|
|
32
32
|
id: s.id,
|
|
33
33
|
name: s.name,
|
|
34
|
-
type: s.type,
|
|
35
34
|
connected: deps.sourceManager.isConnected(s.id),
|
|
36
35
|
}));
|
|
37
36
|
|
|
@@ -52,10 +51,10 @@ export function handleServerStatus(deps: PrivacyDeps) {
|
|
|
52
51
|
totalDataRows: resultStats.totalRows,
|
|
53
52
|
ttl: '10 minutes',
|
|
54
53
|
},
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
connected:
|
|
58
|
-
list:
|
|
54
|
+
datasets: {
|
|
55
|
+
loaded: datasets.length,
|
|
56
|
+
connected: datasetsSummary.filter((s: any) => s.connected).length,
|
|
57
|
+
list: datasetsSummary,
|
|
59
58
|
},
|
|
60
59
|
});
|
|
61
60
|
};
|
package/src/mcp/tools/sources.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* MCP Tools:
|
|
3
|
-
* Manage
|
|
2
|
+
* MCP Tools: list_data, load_csv, remove_data, describe_data
|
|
3
|
+
* Manage CSV datasets.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { z } from 'zod';
|
|
@@ -18,44 +18,17 @@ export function isSandboxPath(filePath: string): boolean {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export const addSourceInputSchema = z.object({
|
|
21
|
-
name: z.string().describe('
|
|
22
|
-
|
|
23
|
-
config: z.union([
|
|
24
|
-
z.object({
|
|
25
|
-
type: z.literal('csv'),
|
|
26
|
-
path: z.string().describe('Path to CSV file or directory of CSV files'),
|
|
27
|
-
}),
|
|
28
|
-
z.object({
|
|
29
|
-
type: z.literal('sqlite'),
|
|
30
|
-
path: z.string().describe('Path to SQLite database file'),
|
|
31
|
-
}),
|
|
32
|
-
z.object({
|
|
33
|
-
type: z.literal('postgres'),
|
|
34
|
-
host: z.string(),
|
|
35
|
-
port: z.number().default(5432),
|
|
36
|
-
database: z.string(),
|
|
37
|
-
user: z.string(),
|
|
38
|
-
password: z.string(),
|
|
39
|
-
ssl: z.boolean().optional(),
|
|
40
|
-
}),
|
|
41
|
-
z.object({
|
|
42
|
-
type: z.literal('mysql'),
|
|
43
|
-
host: z.string(),
|
|
44
|
-
port: z.number().default(3306),
|
|
45
|
-
database: z.string(),
|
|
46
|
-
user: z.string(),
|
|
47
|
-
password: z.string(),
|
|
48
|
-
}),
|
|
49
|
-
]).describe('Connection configuration'),
|
|
21
|
+
name: z.string().describe('Name for this dataset'),
|
|
22
|
+
path: z.string().describe('Path to a CSV file or directory of CSV files'),
|
|
50
23
|
detail: z.enum(['compact', 'full']).default('full').describe('Schema detail level: "compact" returns just column names/types + row counts (saves tokens); "full" (default) includes stats, top values, and sample rows'),
|
|
51
24
|
});
|
|
52
25
|
|
|
53
26
|
export const removeSourceInputSchema = z.object({
|
|
54
|
-
sourceId: z.string().describe('ID
|
|
27
|
+
sourceId: z.string().describe('Dataset ID returned by load_csv'),
|
|
55
28
|
});
|
|
56
29
|
|
|
57
30
|
export const describeSourceInputSchema = z.object({
|
|
58
|
-
sourceId: z.string().describe('
|
|
31
|
+
sourceId: z.string().describe('Dataset ID returned by load_csv'),
|
|
59
32
|
table: z.string().optional().describe('Table name (optional — if omitted, returns all tables)'),
|
|
60
33
|
detail: z.enum(['compact', 'full']).default('full').describe('Schema detail level: "compact" returns just column names/types + row counts; "full" (default) includes stats, top values, and sample rows'),
|
|
61
34
|
});
|
|
@@ -94,16 +67,16 @@ export function handleListSources(deps: { sourceManager: any }) {
|
|
|
94
67
|
|
|
95
68
|
export function handleAddSource(deps: { sourceManager: any }) {
|
|
96
69
|
return async (args: z.infer<typeof addSourceInputSchema>) => {
|
|
97
|
-
if ((args.
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
);
|
|
104
|
-
}
|
|
70
|
+
if (isSandboxPath(args.path)) {
|
|
71
|
+
return errorResponse(
|
|
72
|
+
'This path looks like a cloud sandbox path, not a local filesystem path. '
|
|
73
|
+
+ 'Dolex runs on the user\'s machine and can access any local file — but not cloud sandbox uploads. '
|
|
74
|
+
+ 'Ask the user for the real local path (e.g. /Users/name/Downloads/data.csv).'
|
|
75
|
+
);
|
|
105
76
|
}
|
|
106
77
|
|
|
78
|
+
const config = { type: 'csv' as const, path: args.path };
|
|
79
|
+
|
|
107
80
|
let entry: any;
|
|
108
81
|
let reconnected = false;
|
|
109
82
|
|
|
@@ -114,18 +87,18 @@ export function handleAddSource(deps: { sourceManager: any }) {
|
|
|
114
87
|
} else {
|
|
115
88
|
let addResult: any;
|
|
116
89
|
try {
|
|
117
|
-
addResult = await deps.sourceManager.add(args.name,
|
|
90
|
+
addResult = await deps.sourceManager.add(args.name, config);
|
|
118
91
|
} catch (err: any) {
|
|
119
92
|
if (err.code === 'ENOENT') {
|
|
120
93
|
return errorResponse(
|
|
121
|
-
`File not found: ${
|
|
94
|
+
`File not found: ${args.path}. `
|
|
122
95
|
+ 'Ask the user to double-check the path exists on their machine.'
|
|
123
96
|
);
|
|
124
97
|
}
|
|
125
98
|
return errorResponse(err.message);
|
|
126
99
|
}
|
|
127
100
|
if (!addResult.ok || !addResult.entry) {
|
|
128
|
-
return errorResponse(addResult.error ?? 'Failed to
|
|
101
|
+
return errorResponse(addResult.error ?? 'Failed to load CSV');
|
|
129
102
|
}
|
|
130
103
|
entry = addResult.entry;
|
|
131
104
|
}
|
|
@@ -141,12 +114,11 @@ export function handleAddSource(deps: { sourceManager: any }) {
|
|
|
141
114
|
);
|
|
142
115
|
|
|
143
116
|
const tableCount = schema?.tables.length ?? 0;
|
|
144
|
-
const verb = reconnected ? 'Reconnected
|
|
117
|
+
const verb = reconnected ? 'Reconnected' : 'Loaded';
|
|
145
118
|
|
|
146
119
|
return jsonResponse({
|
|
147
120
|
sourceId: entry.id,
|
|
148
121
|
name: entry.name,
|
|
149
|
-
type: entry.type,
|
|
150
122
|
tables,
|
|
151
123
|
message: `${verb} "${args.name}" — ${tableCount} tables found`,
|
|
152
124
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* MCP Tool:
|
|
2
|
+
* MCP Tool: visualize_data
|
|
3
3
|
* Takes a data source + DSL query + intent and returns visualization
|
|
4
4
|
* recommendations from the handcrafted pattern library.
|
|
5
5
|
*
|
|
@@ -18,7 +18,7 @@ import { errorResponse, inferColumns, applyTimeBucketColumnTypes, enhanceIntentF
|
|
|
18
18
|
import { logOperation, extractDslStructure } from './operation-log.js';
|
|
19
19
|
|
|
20
20
|
export const visualizeFromSourceInputSchema = z.object({
|
|
21
|
-
sourceId: z.string().describe('
|
|
21
|
+
sourceId: z.string().describe('Dataset ID returned by load_csv'),
|
|
22
22
|
table: z.string().describe('Base table within the source'),
|
|
23
23
|
query: dslQuerySchema.describe('Declarative query to slice/aggregate the data before visualizing'),
|
|
24
24
|
intent: z.string().describe('What the user wants to see — e.g., "compare sales by region", "show distribution of ages", "how do rankings change over time"'),
|
|
@@ -48,7 +48,7 @@ export function handleVisualizeFromSource(
|
|
|
48
48
|
selectPatterns: (input: VisualizeInput) => VisualizeOutput,
|
|
49
49
|
deps: { sourceManager: any },
|
|
50
50
|
) {
|
|
51
|
-
const core = handleVisualizeCore(selectPatterns, '
|
|
51
|
+
const core = handleVisualizeCore(selectPatterns, 'visualize_data');
|
|
52
52
|
|
|
53
53
|
return async (args: z.infer<typeof visualizeFromSourceInputSchema>) => {
|
|
54
54
|
const start = Date.now();
|
|
@@ -63,7 +63,7 @@ export function handleVisualizeFromSource(
|
|
|
63
63
|
const result = await deps.sourceManager.queryDsl(args.sourceId, args.table, args.query);
|
|
64
64
|
if (!result.ok) {
|
|
65
65
|
logOperation({
|
|
66
|
-
toolName: '
|
|
66
|
+
toolName: 'visualize_data',
|
|
67
67
|
timestamp: start,
|
|
68
68
|
durationMs: Date.now() - start,
|
|
69
69
|
success: false,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Takes inline data + intent and returns visualization recommendations
|
|
4
4
|
* from the handcrafted pattern library.
|
|
5
5
|
*
|
|
6
|
-
* For source-based data (sourceId + table + query), use
|
|
6
|
+
* For source-based data (sourceId + table + query), use visualize_data.
|
|
7
7
|
*
|
|
8
8
|
* Returns compact text content (specId + metadata, no data) while
|
|
9
9
|
* structuredContent still gets the full pre-rendered chart HTML.
|
|
@@ -45,7 +45,7 @@ export const dataShapeHintsSchema = z.object({
|
|
|
45
45
|
|
|
46
46
|
export const visualizeInputSchema = z.object({
|
|
47
47
|
data: z.array(z.record(z.any())).optional().describe('Array of data rows to visualize. Optional if resultId is provided.'),
|
|
48
|
-
resultId: z.string().optional().describe('Result ID from a previous
|
|
48
|
+
resultId: z.string().optional().describe('Result ID from a previous query_data call — reuses cached data without re-sending it'),
|
|
49
49
|
intent: z.string().describe('What the user wants to see — e.g., "compare sales by region", "show distribution of ages", "how do rankings change over time"'),
|
|
50
50
|
columns: columnsSchema,
|
|
51
51
|
dataShapeHints: dataShapeHintsSchema,
|
|
@@ -70,7 +70,7 @@ export const visualizeInputSchema = z.object({
|
|
|
70
70
|
});
|
|
71
71
|
|
|
72
72
|
/**
|
|
73
|
-
* Shared core logic for both visualize and
|
|
73
|
+
* Shared core logic for both visualize and visualize_data.
|
|
74
74
|
* Takes resolved data + args and returns the MCP response.
|
|
75
75
|
*/
|
|
76
76
|
export function handleVisualizeCore(
|
|
@@ -215,13 +215,13 @@ export function handleVisualize(
|
|
|
215
215
|
if (args.resultId) {
|
|
216
216
|
const cached = getResult(args.resultId);
|
|
217
217
|
if (!cached) {
|
|
218
|
-
return errorResponse(`Result "${args.resultId}" not found or expired. Re-run
|
|
218
|
+
return errorResponse(`Result "${args.resultId}" not found or expired. Re-run query_data to get a new resultId.`);
|
|
219
219
|
}
|
|
220
220
|
data = cached.rows;
|
|
221
221
|
}
|
|
222
222
|
|
|
223
223
|
if (!data || data.length === 0) {
|
|
224
|
-
return errorResponse('No data provided. Pass either `data` array or `resultId` from
|
|
224
|
+
return errorResponse('No data provided. Pass either `data` array or `resultId` from query_data.');
|
|
225
225
|
}
|
|
226
226
|
|
|
227
227
|
return core(data, args);
|
|
@@ -147,8 +147,8 @@ html, body {
|
|
|
147
147
|
min-width: 140px;
|
|
148
148
|
}
|
|
149
149
|
.filter-control:focus {
|
|
150
|
-
outline: none; border-color: #
|
|
151
|
-
box-shadow: 0 0 0 2px rgba(
|
|
150
|
+
outline: none; border-color: #3366AA;
|
|
151
|
+
box-shadow: 0 0 0 2px rgba(51,102,170,0.2);
|
|
152
152
|
}
|
|
153
153
|
#dashboard-grid {
|
|
154
154
|
display: grid;
|