@outsidedata/dolex 0.1.10 → 0.1.12
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.js +1 -1
- package/dist/src/mcp/tools/connect-data.d.ts +14 -0
- package/dist/src/mcp/tools/connect-data.d.ts.map +1 -0
- package/dist/src/mcp/tools/connect-data.js +80 -0
- package/dist/src/mcp/tools/connect-data.js.map +1 -0
- package/package.json +1 -1
- package/src/mcp/index.ts +1 -1
- package/src/mcp/tools/connect-data.ts +94 -0
package/dist/src/mcp/index.js
CHANGED
|
@@ -60,7 +60,7 @@ const serverStartTime = Date.now();
|
|
|
60
60
|
// ─── CREATE SERVER ──────────────────────────────────────────────────────────
|
|
61
61
|
const server = new McpServer({
|
|
62
62
|
name: 'dolex',
|
|
63
|
-
version: '0.1.
|
|
63
|
+
version: '0.1.12',
|
|
64
64
|
}, {
|
|
65
65
|
instructions: [
|
|
66
66
|
'STOP. Read this before doing anything else.',
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
|
+
export declare const connectDataInputSchema: z.ZodObject<{
|
|
4
|
+
path: z.ZodOptional<z.ZodString>;
|
|
5
|
+
}, "strip", z.ZodTypeAny, {
|
|
6
|
+
path?: string | undefined;
|
|
7
|
+
}, {
|
|
8
|
+
path?: string | undefined;
|
|
9
|
+
}>;
|
|
10
|
+
export declare function handleConnectData(deps: {
|
|
11
|
+
sourceManager: any;
|
|
12
|
+
server: McpServer;
|
|
13
|
+
}): (args: z.infer<typeof connectDataInputSchema>, _extra: any) => Promise<import("./shared.js").McpResponse>;
|
|
14
|
+
//# sourceMappingURL=connect-data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connect-data.d.ts","sourceRoot":"","sources":["../../../../src/mcp/tools/connect-data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAIzE,eAAO,MAAM,sBAAsB;;;;;;EAEjC,CAAC;AAwBH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE;IAAE,aAAa,EAAE,GAAG,CAAC;IAAC,MAAM,EAAE,SAAS,CAAA;CAAE,IAGjE,MAAM,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,EAAE,QAAQ,GAAG,gDAyDxE"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import * as fs from 'fs';
|
|
3
|
+
import * as path from 'path';
|
|
4
|
+
import { errorResponse } from './shared.js';
|
|
5
|
+
import { handleAddSource, isSandboxPath } from './sources.js';
|
|
6
|
+
export const connectDataInputSchema = z.object({
|
|
7
|
+
path: z.string().optional().describe('File or directory path. If omitted, Dolex will ask the user directly.'),
|
|
8
|
+
});
|
|
9
|
+
function detectType(filePath) {
|
|
10
|
+
const stat = fs.statSync(filePath, { throwIfNoEntry: false });
|
|
11
|
+
if (!stat)
|
|
12
|
+
return 'csv';
|
|
13
|
+
if (stat.isDirectory()) {
|
|
14
|
+
const files = fs.readdirSync(filePath);
|
|
15
|
+
if (files.some(f => f.endsWith('.sqlite') || f.endsWith('.db') || f.endsWith('.sqlite3')))
|
|
16
|
+
return 'sqlite';
|
|
17
|
+
return 'csv';
|
|
18
|
+
}
|
|
19
|
+
const ext = path.extname(filePath).toLowerCase();
|
|
20
|
+
if (ext === '.sqlite' || ext === '.db' || ext === '.sqlite3')
|
|
21
|
+
return 'sqlite';
|
|
22
|
+
return 'csv';
|
|
23
|
+
}
|
|
24
|
+
function deriveName(filePath) {
|
|
25
|
+
const base = path.basename(filePath, path.extname(filePath));
|
|
26
|
+
return base
|
|
27
|
+
.replace(/[-_]/g, ' ')
|
|
28
|
+
.replace(/\b\w/g, c => c.toUpperCase());
|
|
29
|
+
}
|
|
30
|
+
export function handleConnectData(deps) {
|
|
31
|
+
const addSource = handleAddSource({ sourceManager: deps.sourceManager });
|
|
32
|
+
return async (args, _extra) => {
|
|
33
|
+
let filePath = args.path;
|
|
34
|
+
if (!filePath) {
|
|
35
|
+
try {
|
|
36
|
+
const result = await deps.server.server.elicitInput({
|
|
37
|
+
message: 'What data would you like to analyze?',
|
|
38
|
+
requestedSchema: {
|
|
39
|
+
type: 'object',
|
|
40
|
+
properties: {
|
|
41
|
+
path: {
|
|
42
|
+
type: 'string',
|
|
43
|
+
title: 'File or directory path',
|
|
44
|
+
description: 'e.g. /Users/you/Downloads/sales.csv or ~/data/my-project/',
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
required: ['path'],
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
if (result.action !== 'accept' || !result.content?.path) {
|
|
51
|
+
return errorResponse('No path provided. To connect data, provide a file or directory path.');
|
|
52
|
+
}
|
|
53
|
+
filePath = result.content.path;
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
return errorResponse('This client does not support interactive input. '
|
|
57
|
+
+ 'Use add_source instead and pass the file path directly.');
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
filePath = filePath.replace(/^~/, process.env.HOME || '');
|
|
61
|
+
if (isSandboxPath(filePath)) {
|
|
62
|
+
return errorResponse('This path looks like a cloud sandbox path, not a local filesystem path. '
|
|
63
|
+
+ 'Dolex runs on the user\'s machine and can access any local file — but not cloud sandbox uploads. '
|
|
64
|
+
+ 'Please provide the real local path.');
|
|
65
|
+
}
|
|
66
|
+
const stat = fs.statSync(filePath, { throwIfNoEntry: false });
|
|
67
|
+
if (!stat) {
|
|
68
|
+
return errorResponse(`Path not found: ${filePath}`);
|
|
69
|
+
}
|
|
70
|
+
const type = detectType(filePath);
|
|
71
|
+
const name = deriveName(filePath);
|
|
72
|
+
return addSource({
|
|
73
|
+
name,
|
|
74
|
+
type,
|
|
75
|
+
config: { type, path: filePath },
|
|
76
|
+
detail: 'full',
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=connect-data.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connect-data.js","sourceRoot":"","sources":["../../../../src/mcp/tools/connect-data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE9D,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7C,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,uEAAuE,CAAC;CAC9G,CAAC,CAAC;AAEH,SAAS,UAAU,CAAC,QAAgB;IAClC,MAAM,IAAI,GAAG,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC,CAAC;IAC9D,IAAI,CAAC,IAAI;QAAE,OAAO,KAAK,CAAC;IAExB,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;QACvB,MAAM,KAAK,GAAG,EAAE,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QACvC,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;YAAE,OAAO,QAAQ,CAAC;QAC3G,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,GAAG,GAAG,IAAI,CAAC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;oBACxD,OAAO,aAAa,CAAC,sEAAsE,CAAC,CAAC;gBAC/F,CAAC;gBACD,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,IAAc,CAAC;YAC3C,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,aAAa,CAClB,kDAAkD;sBAChD,yDAAyD,CAC5D,CAAC;YACJ,CAAC;QACH,CAAC;QAED,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;QAE1D,IAAI,aAAa,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC5B,OAAO,aAAa,CAClB,0EAA0E;kBACxE,mGAAmG;kBACnG,qCAAqC,CACxC,CAAC;QACJ,CAAC;QAED,MAAM,IAAI,GAAG,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC,CAAC;QAC9D,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,OAAO,aAAa,CAAC,mBAAmB,QAAQ,EAAE,CAAC,CAAC;QACtD,CAAC;QAED,MAAM,IAAI,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;QAClC,MAAM,IAAI,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;QAElC,OAAO,SAAS,CAAC;YACf,IAAI;YACJ,IAAI;YACJ,MAAM,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAS;YACvC,MAAM,EAAE,MAAM;SACf,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
package/src/mcp/index.ts
CHANGED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import * as fs from 'fs';
|
|
3
|
+
import * as path from 'path';
|
|
4
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
5
|
+
import { errorResponse } from './shared.js';
|
|
6
|
+
import { handleAddSource, isSandboxPath } from './sources.js';
|
|
7
|
+
|
|
8
|
+
export const connectDataInputSchema = z.object({
|
|
9
|
+
path: z.string().optional().describe('File or directory path. If omitted, Dolex will ask the user directly.'),
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
function detectType(filePath: string): 'csv' | 'sqlite' {
|
|
13
|
+
const stat = fs.statSync(filePath, { throwIfNoEntry: false });
|
|
14
|
+
if (!stat) return 'csv';
|
|
15
|
+
|
|
16
|
+
if (stat.isDirectory()) {
|
|
17
|
+
const files = fs.readdirSync(filePath);
|
|
18
|
+
if (files.some(f => f.endsWith('.sqlite') || f.endsWith('.db') || f.endsWith('.sqlite3'))) return 'sqlite';
|
|
19
|
+
return 'csv';
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const ext = path.extname(filePath).toLowerCase();
|
|
23
|
+
if (ext === '.sqlite' || ext === '.db' || ext === '.sqlite3') return 'sqlite';
|
|
24
|
+
return 'csv';
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function deriveName(filePath: string): string {
|
|
28
|
+
const base = path.basename(filePath, path.extname(filePath));
|
|
29
|
+
return base
|
|
30
|
+
.replace(/[-_]/g, ' ')
|
|
31
|
+
.replace(/\b\w/g, c => c.toUpperCase());
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function handleConnectData(deps: { sourceManager: any; server: McpServer }) {
|
|
35
|
+
const addSource = handleAddSource({ sourceManager: deps.sourceManager });
|
|
36
|
+
|
|
37
|
+
return async (args: z.infer<typeof connectDataInputSchema>, _extra: any) => {
|
|
38
|
+
let filePath = args.path;
|
|
39
|
+
|
|
40
|
+
if (!filePath) {
|
|
41
|
+
try {
|
|
42
|
+
const result = await deps.server.server.elicitInput({
|
|
43
|
+
message: 'What data would you like to analyze?',
|
|
44
|
+
requestedSchema: {
|
|
45
|
+
type: 'object' as const,
|
|
46
|
+
properties: {
|
|
47
|
+
path: {
|
|
48
|
+
type: 'string' as const,
|
|
49
|
+
title: 'File or directory path',
|
|
50
|
+
description: 'e.g. /Users/you/Downloads/sales.csv or ~/data/my-project/',
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
required: ['path'],
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
if (result.action !== 'accept' || !result.content?.path) {
|
|
58
|
+
return errorResponse('No path provided. To connect data, provide a file or directory path.');
|
|
59
|
+
}
|
|
60
|
+
filePath = result.content.path as string;
|
|
61
|
+
} catch {
|
|
62
|
+
return errorResponse(
|
|
63
|
+
'This client does not support interactive input. '
|
|
64
|
+
+ 'Use add_source instead and pass the file path directly.'
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
filePath = filePath.replace(/^~/, process.env.HOME || '');
|
|
70
|
+
|
|
71
|
+
if (isSandboxPath(filePath)) {
|
|
72
|
+
return errorResponse(
|
|
73
|
+
'This path looks like a cloud sandbox path, not a local filesystem path. '
|
|
74
|
+
+ 'Dolex runs on the user\'s machine and can access any local file — but not cloud sandbox uploads. '
|
|
75
|
+
+ 'Please provide the real local path.'
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const stat = fs.statSync(filePath, { throwIfNoEntry: false });
|
|
80
|
+
if (!stat) {
|
|
81
|
+
return errorResponse(`Path not found: ${filePath}`);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const type = detectType(filePath);
|
|
85
|
+
const name = deriveName(filePath);
|
|
86
|
+
|
|
87
|
+
return addSource({
|
|
88
|
+
name,
|
|
89
|
+
type,
|
|
90
|
+
config: { type, path: filePath } as any,
|
|
91
|
+
detail: 'full',
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
}
|