@centrali-io/centrali-mcp 5.1.2 → 5.3.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 +15 -0
- package/dist/index.js +2 -0
- package/dist/tools/_register.d.ts +24 -0
- package/dist/tools/_register.js +44 -0
- package/dist/tools/auth-providers.js +15 -30
- package/dist/tools/compute.js +48 -69
- package/dist/tools/describe.js +174 -21
- package/dist/tools/insights.js +13 -36
- package/dist/tools/orchestrations.js +21 -44
- package/dist/tools/pages.js +39 -61
- package/dist/tools/records.js +29 -50
- package/dist/tools/search.js +3 -24
- package/dist/tools/service-accounts.js +93 -108
- package/dist/tools/smart-queries.js +15 -36
- package/dist/tools/structures.js +23 -61
- package/dist/tools/validation.js +11 -34
- package/dist/tools/webhook-subscriptions.d.ts +3 -0
- package/dist/tools/webhook-subscriptions.js +292 -0
- package/package.json +5 -6
- package/src/index.ts +2 -0
- package/src/tools/_register.ts +53 -0
- package/src/tools/auth-providers.ts +8 -24
- package/src/tools/compute.ts +25 -46
- package/src/tools/describe.ts +200 -21
- package/src/tools/insights.ts +19 -28
- package/src/tools/orchestrations.ts +11 -34
- package/src/tools/pages.ts +20 -41
- package/src/tools/records.ts +15 -36
- package/src/tools/search.ts +7 -22
- package/src/tools/service-accounts.ts +47 -63
- package/src/tools/smart-queries.ts +8 -29
- package/src/tools/structures.ts +12 -50
- package/src/tools/validation.ts +21 -27
- package/src/tools/webhook-subscriptions.ts +363 -0
|
@@ -11,30 +11,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.registerSmartQueryTools = registerSmartQueryTools;
|
|
13
13
|
const zod_1 = require("zod");
|
|
14
|
-
|
|
15
|
-
var _a, _b;
|
|
16
|
-
if (error && typeof error === 'object') {
|
|
17
|
-
const e = error;
|
|
18
|
-
if ('message' in e) {
|
|
19
|
-
let msg = `Error ${context}`;
|
|
20
|
-
if ('code' in e || 'status' in e) {
|
|
21
|
-
msg += `: [${(_b = (_a = e.code) !== null && _a !== void 0 ? _a : e.status) !== null && _b !== void 0 ? _b : 'ERROR'}] ${e.message}`;
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
msg += `: ${e.message}`;
|
|
25
|
-
}
|
|
26
|
-
if (Array.isArray(e.fieldErrors) && e.fieldErrors.length > 0) {
|
|
27
|
-
msg += '\nField errors:\n' + e.fieldErrors
|
|
28
|
-
.map(f => ` ${f.field}: ${f.message}`)
|
|
29
|
-
.join('\n');
|
|
30
|
-
}
|
|
31
|
-
return msg;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return `Error ${context}: ${error instanceof Error ? error.message : String(error)}`;
|
|
35
|
-
}
|
|
14
|
+
const _register_js_1 = require("./_register.js");
|
|
36
15
|
function registerSmartQueryTools(server, sdk) {
|
|
37
|
-
|
|
16
|
+
(0, _register_js_1.registerTool)(server, "list_smart_queries", "List smart queries. Smart queries are reusable, parameterized queries defined in the Centrali console. Optionally filter by collection record slug.", {
|
|
38
17
|
recordSlug: zod_1.z
|
|
39
18
|
.string()
|
|
40
19
|
.optional()
|
|
@@ -55,14 +34,14 @@ function registerSmartQueryTools(server, sdk) {
|
|
|
55
34
|
content: [
|
|
56
35
|
{
|
|
57
36
|
type: "text",
|
|
58
|
-
text: formatError(error, "listing smart queries"),
|
|
37
|
+
text: (0, _register_js_1.formatError)(error, "listing smart queries"),
|
|
59
38
|
},
|
|
60
39
|
],
|
|
61
40
|
isError: true,
|
|
62
41
|
};
|
|
63
42
|
}
|
|
64
43
|
}));
|
|
65
|
-
|
|
44
|
+
(0, _register_js_1.registerTool)(server, "execute_smart_query", "Execute a smart query by ID and return the results. Smart queries can have parameterized variables using {{variableName}} syntax.", {
|
|
66
45
|
recordSlug: zod_1.z
|
|
67
46
|
.string()
|
|
68
47
|
.describe("The collection's record slug the query belongs to"),
|
|
@@ -86,14 +65,14 @@ function registerSmartQueryTools(server, sdk) {
|
|
|
86
65
|
content: [
|
|
87
66
|
{
|
|
88
67
|
type: "text",
|
|
89
|
-
text: formatError(error, `executing smart query '${queryId}'`),
|
|
68
|
+
text: (0, _register_js_1.formatError)(error, `executing smart query '${queryId}'`),
|
|
90
69
|
},
|
|
91
70
|
],
|
|
92
71
|
isError: true,
|
|
93
72
|
};
|
|
94
73
|
}
|
|
95
74
|
}));
|
|
96
|
-
|
|
75
|
+
(0, _register_js_1.registerTool)(server, "get_smart_query", "Get a smart query by ID. Returns the full query definition including filters, sort, and variable declarations.", {
|
|
97
76
|
recordSlug: zod_1.z.string().describe("The collection's record slug the query belongs to"),
|
|
98
77
|
queryId: zod_1.z.string().describe("The smart query ID (UUID)"),
|
|
99
78
|
}, (_a) => __awaiter(this, [_a], void 0, function* ({ recordSlug, queryId }) {
|
|
@@ -110,14 +89,14 @@ function registerSmartQueryTools(server, sdk) {
|
|
|
110
89
|
content: [
|
|
111
90
|
{
|
|
112
91
|
type: "text",
|
|
113
|
-
text: formatError(error, `getting smart query '${queryId}'`),
|
|
92
|
+
text: (0, _register_js_1.formatError)(error, `getting smart query '${queryId}'`),
|
|
114
93
|
},
|
|
115
94
|
],
|
|
116
95
|
isError: true,
|
|
117
96
|
};
|
|
118
97
|
}
|
|
119
98
|
}));
|
|
120
|
-
|
|
99
|
+
(0, _register_js_1.registerTool)(server, "create_smart_query", "Create a new smart query for a collection. Smart queries are reusable, parameterized queries with filter, sort, and variable support.", {
|
|
121
100
|
recordSlug: zod_1.z.string().describe("The collection's record slug to create the query for"),
|
|
122
101
|
name: zod_1.z.string().describe("Display name for the smart query"),
|
|
123
102
|
description: zod_1.z.string().optional().describe("Optional description"),
|
|
@@ -141,14 +120,14 @@ function registerSmartQueryTools(server, sdk) {
|
|
|
141
120
|
content: [
|
|
142
121
|
{
|
|
143
122
|
type: "text",
|
|
144
|
-
text: formatError(error, `creating smart query '${name}' for '${recordSlug}'`),
|
|
123
|
+
text: (0, _register_js_1.formatError)(error, `creating smart query '${name}' for '${recordSlug}'`),
|
|
145
124
|
},
|
|
146
125
|
],
|
|
147
126
|
isError: true,
|
|
148
127
|
};
|
|
149
128
|
}
|
|
150
129
|
}));
|
|
151
|
-
|
|
130
|
+
(0, _register_js_1.registerTool)(server, "update_smart_query", "Update an existing smart query. Only include the fields you want to change.", {
|
|
152
131
|
recordSlug: zod_1.z.string().describe("The collection's record slug the query belongs to"),
|
|
153
132
|
queryId: zod_1.z.string().describe("The smart query ID (UUID) to update"),
|
|
154
133
|
name: zod_1.z.string().optional().describe("Updated display name"),
|
|
@@ -178,14 +157,14 @@ function registerSmartQueryTools(server, sdk) {
|
|
|
178
157
|
content: [
|
|
179
158
|
{
|
|
180
159
|
type: "text",
|
|
181
|
-
text: formatError(error, `updating smart query '${queryId}'`),
|
|
160
|
+
text: (0, _register_js_1.formatError)(error, `updating smart query '${queryId}'`),
|
|
182
161
|
},
|
|
183
162
|
],
|
|
184
163
|
isError: true,
|
|
185
164
|
};
|
|
186
165
|
}
|
|
187
166
|
}));
|
|
188
|
-
|
|
167
|
+
(0, _register_js_1.registerTool)(server, "delete_smart_query", "Delete a smart query by ID.", {
|
|
189
168
|
recordSlug: zod_1.z.string().describe("The collection's record slug the query belongs to"),
|
|
190
169
|
queryId: zod_1.z.string().describe("The smart query ID (UUID) to delete"),
|
|
191
170
|
}, (_a) => __awaiter(this, [_a], void 0, function* ({ recordSlug, queryId }) {
|
|
@@ -205,14 +184,14 @@ function registerSmartQueryTools(server, sdk) {
|
|
|
205
184
|
content: [
|
|
206
185
|
{
|
|
207
186
|
type: "text",
|
|
208
|
-
text: formatError(error, `deleting smart query '${queryId}'`),
|
|
187
|
+
text: (0, _register_js_1.formatError)(error, `deleting smart query '${queryId}'`),
|
|
209
188
|
},
|
|
210
189
|
],
|
|
211
190
|
isError: true,
|
|
212
191
|
};
|
|
213
192
|
}
|
|
214
193
|
}));
|
|
215
|
-
|
|
194
|
+
(0, _register_js_1.registerTool)(server, "test_smart_query", "Test execute a query definition without saving it. Useful for validating query syntax and previewing results before creating a smart query.", {
|
|
216
195
|
recordSlug: zod_1.z.string().describe("The collection's record slug to test against"),
|
|
217
196
|
queryDefinition: zod_1.z
|
|
218
197
|
.record(zod_1.z.string(), zod_1.z.any())
|
|
@@ -238,7 +217,7 @@ function registerSmartQueryTools(server, sdk) {
|
|
|
238
217
|
content: [
|
|
239
218
|
{
|
|
240
219
|
type: "text",
|
|
241
|
-
text: formatError(error, `test-executing smart query for '${recordSlug}'`),
|
|
220
|
+
text: (0, _register_js_1.formatError)(error, `test-executing smart query for '${recordSlug}'`),
|
|
242
221
|
},
|
|
243
222
|
],
|
|
244
223
|
isError: true,
|
package/dist/tools/structures.js
CHANGED
|
@@ -16,45 +16,7 @@ exports.registerStructureTools = registerStructureTools;
|
|
|
16
16
|
exports.registerCollectionTools = registerCollectionTools;
|
|
17
17
|
const axios_1 = __importDefault(require("axios"));
|
|
18
18
|
const zod_1 = require("zod");
|
|
19
|
-
|
|
20
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
21
|
-
if (error && typeof error === 'object') {
|
|
22
|
-
const e = error;
|
|
23
|
-
if ((_a = e.response) === null || _a === void 0 ? void 0 : _a.data) {
|
|
24
|
-
const d = e.response.data;
|
|
25
|
-
const code = (_f = (_e = (_c = (_b = d.code) !== null && _b !== void 0 ? _b : d.errorCode) !== null && _c !== void 0 ? _c : (_d = d.error) === null || _d === void 0 ? void 0 : _d.code) !== null && _e !== void 0 ? _e : e.response.status) !== null && _f !== void 0 ? _f : "ERROR";
|
|
26
|
-
const message = (_j = (_g = d.message) !== null && _g !== void 0 ? _g : (_h = d.error) === null || _h === void 0 ? void 0 : _h.message) !== null && _j !== void 0 ? _j : JSON.stringify(d);
|
|
27
|
-
let msg = `Error ${context}: [${code}] ${message}`;
|
|
28
|
-
// Include extra context from error response (e.g. classification details)
|
|
29
|
-
if (d.classification) {
|
|
30
|
-
msg += `\nClassification: ${JSON.stringify(d.classification)}`;
|
|
31
|
-
}
|
|
32
|
-
if (d.criticalChanges) {
|
|
33
|
-
msg += `\nCritical changes: ${JSON.stringify(d.criticalChanges)}`;
|
|
34
|
-
}
|
|
35
|
-
if (d.suggestion) {
|
|
36
|
-
msg += `\nSuggestion: ${d.suggestion}`;
|
|
37
|
-
}
|
|
38
|
-
return msg;
|
|
39
|
-
}
|
|
40
|
-
if ('message' in e) {
|
|
41
|
-
let msg = `Error ${context}`;
|
|
42
|
-
if ('code' in e || 'status' in e) {
|
|
43
|
-
msg += `: [${(_l = (_k = e.code) !== null && _k !== void 0 ? _k : e.status) !== null && _l !== void 0 ? _l : 'ERROR'}] ${e.message}`;
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
msg += `: ${e.message}`;
|
|
47
|
-
}
|
|
48
|
-
if (Array.isArray(e.fieldErrors) && e.fieldErrors.length > 0) {
|
|
49
|
-
msg += '\nField errors:\n' + e.fieldErrors
|
|
50
|
-
.map(f => ` ${f.field}: ${f.message}`)
|
|
51
|
-
.join('\n');
|
|
52
|
-
}
|
|
53
|
-
return msg;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return `Error ${context}: ${error instanceof Error ? error.message : String(error)}`;
|
|
57
|
-
}
|
|
19
|
+
const _register_js_1 = require("./_register.js");
|
|
58
20
|
/**
|
|
59
21
|
* Ensures the SDK has a valid token.
|
|
60
22
|
*/
|
|
@@ -108,7 +70,7 @@ function createDataClient(sdk, centraliUrl, workspaceId, pathSuffix) {
|
|
|
108
70
|
return client;
|
|
109
71
|
}
|
|
110
72
|
function registerStructureTools(server, sdk) {
|
|
111
|
-
|
|
73
|
+
(0, _register_js_1.registerTool)(server, "list_structures", "[DEPRECATED: use list_collections instead] List all data structures (schemas) in the Centrali workspace. Returns name, slug, description, and property definitions for each structure.", {
|
|
112
74
|
page: zod_1.z.number().optional().describe("Page number (1-indexed)"),
|
|
113
75
|
limit: zod_1.z.number().optional().describe("Results per page"),
|
|
114
76
|
}, (_a) => __awaiter(this, [_a], void 0, function* ({ page, limit }) {
|
|
@@ -125,14 +87,14 @@ function registerStructureTools(server, sdk) {
|
|
|
125
87
|
content: [
|
|
126
88
|
{
|
|
127
89
|
type: "text",
|
|
128
|
-
text: formatError(error, "listing structures"),
|
|
90
|
+
text: (0, _register_js_1.formatError)(error, "listing structures"),
|
|
129
91
|
},
|
|
130
92
|
],
|
|
131
93
|
isError: true,
|
|
132
94
|
};
|
|
133
95
|
}
|
|
134
96
|
}));
|
|
135
|
-
|
|
97
|
+
(0, _register_js_1.registerTool)(server, "get_structure", "[DEPRECATED: use get_collection instead] Get the full schema definition for a specific structure by its record slug. Returns properties, types, constraints, and configuration.", {
|
|
136
98
|
recordSlug: zod_1.z
|
|
137
99
|
.string()
|
|
138
100
|
.describe("The structure's record slug (e.g., 'orders', 'customers')"),
|
|
@@ -150,7 +112,7 @@ function registerStructureTools(server, sdk) {
|
|
|
150
112
|
content: [
|
|
151
113
|
{
|
|
152
114
|
type: "text",
|
|
153
|
-
text: formatError(error, `getting structure '${recordSlug}'`),
|
|
115
|
+
text: (0, _register_js_1.formatError)(error, `getting structure '${recordSlug}'`),
|
|
154
116
|
},
|
|
155
117
|
],
|
|
156
118
|
isError: true,
|
|
@@ -160,7 +122,7 @@ function registerStructureTools(server, sdk) {
|
|
|
160
122
|
}
|
|
161
123
|
function registerCollectionTools(server, sdk, centraliUrl, workspaceId) {
|
|
162
124
|
const getCollectionsClient = () => createDataClient(sdk, centraliUrl, workspaceId, "collections");
|
|
163
|
-
|
|
125
|
+
(0, _register_js_1.registerTool)(server, "list_collections", "List all data collections (schemas) in the Centrali workspace. Returns name, slug, description, and property definitions for each collection.", {
|
|
164
126
|
page: zod_1.z.number().optional().describe("Page number (1-indexed)"),
|
|
165
127
|
limit: zod_1.z.number().optional().describe("Results per page"),
|
|
166
128
|
}, (_a) => __awaiter(this, [_a], void 0, function* ({ page, limit }) {
|
|
@@ -177,14 +139,14 @@ function registerCollectionTools(server, sdk, centraliUrl, workspaceId) {
|
|
|
177
139
|
content: [
|
|
178
140
|
{
|
|
179
141
|
type: "text",
|
|
180
|
-
text: formatError(error, "listing collections"),
|
|
142
|
+
text: (0, _register_js_1.formatError)(error, "listing collections"),
|
|
181
143
|
},
|
|
182
144
|
],
|
|
183
145
|
isError: true,
|
|
184
146
|
};
|
|
185
147
|
}
|
|
186
148
|
}));
|
|
187
|
-
|
|
149
|
+
(0, _register_js_1.registerTool)(server, "get_collection", "Get the full schema definition for a specific collection by its record slug. Returns properties, types, constraints, and configuration.", {
|
|
188
150
|
recordSlug: zod_1.z
|
|
189
151
|
.string()
|
|
190
152
|
.describe("The collection's record slug (e.g., 'orders', 'customers')"),
|
|
@@ -202,14 +164,14 @@ function registerCollectionTools(server, sdk, centraliUrl, workspaceId) {
|
|
|
202
164
|
content: [
|
|
203
165
|
{
|
|
204
166
|
type: "text",
|
|
205
|
-
text: formatError(error, `getting collection '${recordSlug}'`),
|
|
167
|
+
text: (0, _register_js_1.formatError)(error, `getting collection '${recordSlug}'`),
|
|
206
168
|
},
|
|
207
169
|
],
|
|
208
170
|
isError: true,
|
|
209
171
|
};
|
|
210
172
|
}
|
|
211
173
|
}));
|
|
212
|
-
|
|
174
|
+
(0, _register_js_1.registerTool)(server, "create_collection", "Create a new data collection (schema). Define the name, recordSlug, description, and properties (fields) for the collection.", {
|
|
213
175
|
name: zod_1.z.string().describe("Display name for the collection (e.g., 'Customers')"),
|
|
214
176
|
recordSlug: zod_1.z.string().describe("URL-safe identifier used in API calls (e.g., 'customers'). This is the recordSlug, not 'slug'."),
|
|
215
177
|
description: zod_1.z.string().optional().describe("Optional description of the collection"),
|
|
@@ -248,7 +210,7 @@ function registerCollectionTools(server, sdk, centraliUrl, workspaceId) {
|
|
|
248
210
|
content: [
|
|
249
211
|
{
|
|
250
212
|
type: "text",
|
|
251
|
-
text: formatError(error, `creating collection '${recordSlug}'`),
|
|
213
|
+
text: (0, _register_js_1.formatError)(error, `creating collection '${recordSlug}'`),
|
|
252
214
|
},
|
|
253
215
|
],
|
|
254
216
|
isError: true,
|
|
@@ -268,7 +230,7 @@ function registerCollectionTools(server, sdk, centraliUrl, workspaceId) {
|
|
|
268
230
|
// For simple changes (adding optional fields, renaming, metadata-only),
|
|
269
231
|
// update_collection handles everything automatically. For breaking or
|
|
270
232
|
// critical changes, analyze first to understand what's needed.
|
|
271
|
-
|
|
233
|
+
(0, _register_js_1.registerTool)(server, "analyze_collection_update", `Analyze proposed schema changes BEFORE applying them. Returns whether migration is needed, what changes are breaking/critical, suggested fixes, and estimated duration.
|
|
272
234
|
|
|
273
235
|
WHEN TO USE: Call this before update_collection when you are changing properties (adding required fields, changing types, renaming fields, deleting fields, or toggling isSecret). This tells you exactly what will happen and what migration plan is needed.
|
|
274
236
|
|
|
@@ -323,12 +285,12 @@ RESPONSE FIELDS:
|
|
|
323
285
|
}
|
|
324
286
|
catch (error) {
|
|
325
287
|
return {
|
|
326
|
-
content: [{ type: "text", text: formatError(error, `analyzing update for collection '${collectionId}'`) }],
|
|
288
|
+
content: [{ type: "text", text: (0, _register_js_1.formatError)(error, `analyzing update for collection '${collectionId}'`) }],
|
|
327
289
|
isError: true,
|
|
328
290
|
};
|
|
329
291
|
}
|
|
330
292
|
}));
|
|
331
|
-
|
|
293
|
+
(0, _register_js_1.registerTool)(server, "preview_collection_migration", `Preview the effect of migration fixes on sample records BEFORE applying them. Shows before/after snapshots so you can verify fixes are correct.
|
|
332
294
|
|
|
333
295
|
WHEN TO USE: After analyze_collection_update returns suggestedFixes, call this to see how those fixes would transform actual records. Useful for validating type conversions, default values, and expressions before committing.`, {
|
|
334
296
|
collectionId: zod_1.z.string().describe("The collection ID (UUID)"),
|
|
@@ -349,12 +311,12 @@ WHEN TO USE: After analyze_collection_update returns suggestedFixes, call this t
|
|
|
349
311
|
}
|
|
350
312
|
catch (error) {
|
|
351
313
|
return {
|
|
352
|
-
content: [{ type: "text", text: formatError(error, `previewing fixes for collection '${collectionId}'`) }],
|
|
314
|
+
content: [{ type: "text", text: (0, _register_js_1.formatError)(error, `previewing fixes for collection '${collectionId}'`) }],
|
|
353
315
|
isError: true,
|
|
354
316
|
};
|
|
355
317
|
}
|
|
356
318
|
}));
|
|
357
|
-
|
|
319
|
+
(0, _register_js_1.registerTool)(server, "update_collection", `Update a collection's schema using the safe upgrade endpoint. This handles both simple updates and complex migrations.
|
|
358
320
|
|
|
359
321
|
HOW IT WORKS:
|
|
360
322
|
1. If your changes don't require migration (adding optional fields, metadata changes) → completes immediately
|
|
@@ -451,12 +413,12 @@ Each fix is an object with: { fieldName, fixType, value?, expression?, applyToAl
|
|
|
451
413
|
}
|
|
452
414
|
catch (error) {
|
|
453
415
|
return {
|
|
454
|
-
content: [{ type: "text", text: formatError(error, `updating collection '${collectionId}'`) }],
|
|
416
|
+
content: [{ type: "text", text: (0, _register_js_1.formatError)(error, `updating collection '${collectionId}'`) }],
|
|
455
417
|
isError: true,
|
|
456
418
|
};
|
|
457
419
|
}
|
|
458
420
|
}));
|
|
459
|
-
|
|
421
|
+
(0, _register_js_1.registerTool)(server, "get_collection_upgrade_progress", "Check the progress of an async collection migration/upgrade job. Call this after update_collection returns status='in_progress'.", {
|
|
460
422
|
collectionId: zod_1.z.string().describe("The collection ID (UUID)"),
|
|
461
423
|
jobId: zod_1.z.string().describe("The job ID returned by update_collection"),
|
|
462
424
|
}, (_a) => __awaiter(this, [_a], void 0, function* ({ collectionId, jobId }) {
|
|
@@ -469,12 +431,12 @@ Each fix is an object with: { fieldName, fixType, value?, expression?, applyToAl
|
|
|
469
431
|
}
|
|
470
432
|
catch (error) {
|
|
471
433
|
return {
|
|
472
|
-
content: [{ type: "text", text: formatError(error, `getting upgrade progress for '${collectionId}'`) }],
|
|
434
|
+
content: [{ type: "text", text: (0, _register_js_1.formatError)(error, `getting upgrade progress for '${collectionId}'`) }],
|
|
473
435
|
isError: true,
|
|
474
436
|
};
|
|
475
437
|
}
|
|
476
438
|
}));
|
|
477
|
-
|
|
439
|
+
(0, _register_js_1.registerTool)(server, "delete_collection", "Delete a collection by ID. This permanently removes the collection schema and all its records.", {
|
|
478
440
|
collectionId: zod_1.z.string().describe("The collection ID (UUID) to delete"),
|
|
479
441
|
}, (_a) => __awaiter(this, [_a], void 0, function* ({ collectionId }) {
|
|
480
442
|
try {
|
|
@@ -493,14 +455,14 @@ Each fix is an object with: { fieldName, fixType, value?, expression?, applyToAl
|
|
|
493
455
|
content: [
|
|
494
456
|
{
|
|
495
457
|
type: "text",
|
|
496
|
-
text: formatError(error, `deleting collection '${collectionId}'`),
|
|
458
|
+
text: (0, _register_js_1.formatError)(error, `deleting collection '${collectionId}'`),
|
|
497
459
|
},
|
|
498
460
|
],
|
|
499
461
|
isError: true,
|
|
500
462
|
};
|
|
501
463
|
}
|
|
502
464
|
}));
|
|
503
|
-
|
|
465
|
+
(0, _register_js_1.registerTool)(server, "explore_collections", "Get a compact overview of ALL collections in the workspace with their field names, types, and constraints. Returns everything in one call — no need to list collections and then get each one separately.", {
|
|
504
466
|
includeRecordCounts: zod_1.z.boolean().optional().describe("Include record counts for each collection (slower, requires an extra query per collection). Defaults to false."),
|
|
505
467
|
}, (_a) => __awaiter(this, [_a], void 0, function* ({ includeRecordCounts }) {
|
|
506
468
|
var _b, _c, _d, _e;
|
|
@@ -632,7 +594,7 @@ Each fix is an object with: { fieldName, fixType, value?, expression?, applyToAl
|
|
|
632
594
|
content: [
|
|
633
595
|
{
|
|
634
596
|
type: "text",
|
|
635
|
-
text: formatError(error, "exploring collections"),
|
|
597
|
+
text: (0, _register_js_1.formatError)(error, "exploring collections"),
|
|
636
598
|
},
|
|
637
599
|
],
|
|
638
600
|
isError: true,
|
package/dist/tools/validation.js
CHANGED
|
@@ -11,32 +11,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.registerValidationTools = registerValidationTools;
|
|
13
13
|
const zod_1 = require("zod");
|
|
14
|
-
|
|
15
|
-
var _a, _b;
|
|
16
|
-
if (error && typeof error === "object") {
|
|
17
|
-
const e = error;
|
|
18
|
-
if ("message" in e) {
|
|
19
|
-
let msg = `Error ${context}`;
|
|
20
|
-
if ("code" in e || "status" in e) {
|
|
21
|
-
msg += `: [${(_b = (_a = e.code) !== null && _a !== void 0 ? _a : e.status) !== null && _b !== void 0 ? _b : "ERROR"}] ${e.message}`;
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
msg += `: ${e.message}`;
|
|
25
|
-
}
|
|
26
|
-
if (Array.isArray(e.fieldErrors) && e.fieldErrors.length > 0) {
|
|
27
|
-
msg +=
|
|
28
|
-
"\nField errors:\n" +
|
|
29
|
-
e.fieldErrors
|
|
30
|
-
.map((f) => ` ${f.field}: ${f.message}`)
|
|
31
|
-
.join("\n");
|
|
32
|
-
}
|
|
33
|
-
return msg;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return `Error ${context}: ${error instanceof Error ? error.message : String(error)}`;
|
|
37
|
-
}
|
|
14
|
+
const _register_js_1 = require("./_register.js");
|
|
38
15
|
function registerValidationTools(server, sdk) {
|
|
39
|
-
|
|
16
|
+
(0, _register_js_1.registerTool)(server, "trigger_validation_scan", "Trigger an AI-powered data quality scan on a collection. Detects typos, format inconsistencies, duplicates, and other data issues. Returns a batchId — use get_validation_summary or list_validation_suggestions to see results after the scan completes.", {
|
|
40
17
|
recordSlug: zod_1.z.string().describe("The collection's record slug to scan"),
|
|
41
18
|
validationTypes: zod_1.z
|
|
42
19
|
.array(zod_1.z.enum(["typo", "format", "duplicate", "semantic", "type"]))
|
|
@@ -55,14 +32,14 @@ function registerValidationTools(server, sdk) {
|
|
|
55
32
|
content: [
|
|
56
33
|
{
|
|
57
34
|
type: "text",
|
|
58
|
-
text: formatError(error, `triggering validation scan for '${recordSlug}'`),
|
|
35
|
+
text: (0, _register_js_1.formatError)(error, `triggering validation scan for '${recordSlug}'`),
|
|
59
36
|
},
|
|
60
37
|
],
|
|
61
38
|
isError: true,
|
|
62
39
|
};
|
|
63
40
|
}
|
|
64
41
|
}));
|
|
65
|
-
|
|
42
|
+
(0, _register_js_1.registerTool)(server, "list_validation_suggestions", "List data quality suggestions generated by validation scans. Each suggestion identifies an issue in a record and proposes a fix.", {
|
|
66
43
|
recordSlug: zod_1.z
|
|
67
44
|
.string()
|
|
68
45
|
.optional()
|
|
@@ -100,14 +77,14 @@ function registerValidationTools(server, sdk) {
|
|
|
100
77
|
content: [
|
|
101
78
|
{
|
|
102
79
|
type: "text",
|
|
103
|
-
text: formatError(error, "listing validation suggestions"),
|
|
80
|
+
text: (0, _register_js_1.formatError)(error, "listing validation suggestions"),
|
|
104
81
|
},
|
|
105
82
|
],
|
|
106
83
|
isError: true,
|
|
107
84
|
};
|
|
108
85
|
}
|
|
109
86
|
}));
|
|
110
|
-
|
|
87
|
+
(0, _register_js_1.registerTool)(server, "get_validation_summary", "Get a summary of data quality across the workspace — counts of pending, accepted, and rejected suggestions. Optionally filter by collection.", {
|
|
111
88
|
recordSlug: zod_1.z
|
|
112
89
|
.string()
|
|
113
90
|
.optional()
|
|
@@ -122,13 +99,13 @@ function registerValidationTools(server, sdk) {
|
|
|
122
99
|
catch (error) {
|
|
123
100
|
return {
|
|
124
101
|
content: [
|
|
125
|
-
{ type: "text", text: formatError(error, "getting validation summary") },
|
|
102
|
+
{ type: "text", text: (0, _register_js_1.formatError)(error, "getting validation summary") },
|
|
126
103
|
],
|
|
127
104
|
isError: true,
|
|
128
105
|
};
|
|
129
106
|
}
|
|
130
107
|
}));
|
|
131
|
-
|
|
108
|
+
(0, _register_js_1.registerTool)(server, "accept_validation_suggestion", "Accept a data quality suggestion and apply the fix to the record. The suggested correction is written to the record automatically.", {
|
|
132
109
|
suggestionId: zod_1.z.string().describe("The suggestion ID (UUID) to accept"),
|
|
133
110
|
}, (_a) => __awaiter(this, [_a], void 0, function* ({ suggestionId }) {
|
|
134
111
|
try {
|
|
@@ -142,14 +119,14 @@ function registerValidationTools(server, sdk) {
|
|
|
142
119
|
content: [
|
|
143
120
|
{
|
|
144
121
|
type: "text",
|
|
145
|
-
text: formatError(error, `accepting suggestion '${suggestionId}'`),
|
|
122
|
+
text: (0, _register_js_1.formatError)(error, `accepting suggestion '${suggestionId}'`),
|
|
146
123
|
},
|
|
147
124
|
],
|
|
148
125
|
isError: true,
|
|
149
126
|
};
|
|
150
127
|
}
|
|
151
128
|
}));
|
|
152
|
-
|
|
129
|
+
(0, _register_js_1.registerTool)(server, "reject_validation_suggestion", "Reject a data quality suggestion, marking it as incorrect or not applicable. The record is left unchanged.", {
|
|
153
130
|
suggestionId: zod_1.z.string().describe("The suggestion ID (UUID) to reject"),
|
|
154
131
|
}, (_a) => __awaiter(this, [_a], void 0, function* ({ suggestionId }) {
|
|
155
132
|
try {
|
|
@@ -163,7 +140,7 @@ function registerValidationTools(server, sdk) {
|
|
|
163
140
|
content: [
|
|
164
141
|
{
|
|
165
142
|
type: "text",
|
|
166
|
-
text: formatError(error, `rejecting suggestion '${suggestionId}'`),
|
|
143
|
+
text: (0, _register_js_1.formatError)(error, `rejecting suggestion '${suggestionId}'`),
|
|
167
144
|
},
|
|
168
145
|
],
|
|
169
146
|
isError: true,
|