@centrali-io/centrali-mcp 3.1.4 → 3.1.6
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/index.js +6 -0
- package/dist/resources/structures.js +75 -38
- package/dist/tools/compute.js +25 -3
- package/dist/tools/insights.d.ts +3 -0
- package/dist/tools/insights.js +172 -0
- package/dist/tools/orchestrations.d.ts +3 -0
- package/dist/tools/orchestrations.js +182 -0
- package/dist/tools/records.js +96 -5
- package/dist/tools/search.js +23 -1
- package/dist/tools/smart-queries.js +24 -2
- package/dist/tools/structures.js +24 -2
- package/dist/tools/validation.d.ts +3 -0
- package/dist/tools/validation.js +173 -0
- package/package.json +2 -2
- package/src/index.ts +6 -0
- package/src/resources/structures.ts +69 -36
- package/src/tools/compute.ts +27 -6
- package/src/tools/insights.ts +198 -0
- package/src/tools/orchestrations.ts +209 -0
- package/src/tools/records.ts +119 -10
- package/src/tools/search.ts +23 -2
- package/src/tools/smart-queries.ts +25 -4
- package/src/tools/structures.ts +25 -4
- package/src/tools/validation.ts +193 -0
package/dist/index.js
CHANGED
|
@@ -18,6 +18,9 @@ const records_js_1 = require("./tools/records.js");
|
|
|
18
18
|
const search_js_1 = require("./tools/search.js");
|
|
19
19
|
const compute_js_1 = require("./tools/compute.js");
|
|
20
20
|
const smart_queries_js_1 = require("./tools/smart-queries.js");
|
|
21
|
+
const orchestrations_js_1 = require("./tools/orchestrations.js");
|
|
22
|
+
const insights_js_1 = require("./tools/insights.js");
|
|
23
|
+
const validation_js_1 = require("./tools/validation.js");
|
|
21
24
|
const structures_js_2 = require("./resources/structures.js");
|
|
22
25
|
function getRequiredEnv(name) {
|
|
23
26
|
const value = process.env[name];
|
|
@@ -49,6 +52,9 @@ function main() {
|
|
|
49
52
|
(0, search_js_1.registerSearchTools)(server, sdk);
|
|
50
53
|
(0, compute_js_1.registerComputeTools)(server, sdk);
|
|
51
54
|
(0, smart_queries_js_1.registerSmartQueryTools)(server, sdk);
|
|
55
|
+
(0, orchestrations_js_1.registerOrchestrationTools)(server, sdk);
|
|
56
|
+
(0, insights_js_1.registerInsightTools)(server, sdk);
|
|
57
|
+
(0, validation_js_1.registerValidationTools)(server, sdk);
|
|
52
58
|
// Register resources
|
|
53
59
|
(0, structures_js_2.registerStructureResources)(server, sdk);
|
|
54
60
|
// Start stdio transport
|
|
@@ -11,59 +11,96 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.registerStructureResources = registerStructureResources;
|
|
13
13
|
const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
14
|
+
function formatError(error, context) {
|
|
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
36
|
function registerStructureResources(server, sdk) {
|
|
15
37
|
// Static resource: list all structures (gives LLM workspace context)
|
|
16
38
|
server.resource("structures-list", "centrali://structures", {
|
|
17
39
|
description: "List of all data structures in the workspace with name, slug, and description",
|
|
18
40
|
mimeType: "application/json",
|
|
19
41
|
}, (uri) => __awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
42
|
+
try {
|
|
43
|
+
const result = yield sdk.structures.list({ limit: 100 });
|
|
44
|
+
const summary = (result.data || []).map((s) => {
|
|
45
|
+
var _a;
|
|
46
|
+
return ({
|
|
47
|
+
name: s.name,
|
|
48
|
+
recordSlug: s.recordSlug,
|
|
49
|
+
description: s.description || "",
|
|
50
|
+
propertyCount: ((_a = s.properties) === null || _a === void 0 ? void 0 : _a.length) || 0,
|
|
51
|
+
status: s.status,
|
|
52
|
+
});
|
|
29
53
|
});
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
54
|
+
return {
|
|
55
|
+
contents: [
|
|
56
|
+
{
|
|
57
|
+
uri: uri.href,
|
|
58
|
+
mimeType: "application/json",
|
|
59
|
+
text: JSON.stringify(summary, null, 2),
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
throw new Error(formatError(error, "listing structures resource"));
|
|
66
|
+
}
|
|
40
67
|
}));
|
|
41
68
|
// Resource template: full schema for a specific structure
|
|
42
69
|
server.resource("structure-schema", new mcp_js_1.ResourceTemplate("centrali://structures/{slug}", {
|
|
43
70
|
list: () => __awaiter(this, void 0, void 0, function* () {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
71
|
+
try {
|
|
72
|
+
const result = yield sdk.structures.list({ limit: 100 });
|
|
73
|
+
return {
|
|
74
|
+
resources: (result.data || []).map((s) => ({
|
|
75
|
+
uri: `centrali://structures/${s.recordSlug}`,
|
|
76
|
+
name: s.name,
|
|
77
|
+
description: s.description || `Schema for ${s.name}`,
|
|
78
|
+
mimeType: "application/json",
|
|
79
|
+
})),
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
throw new Error(formatError(error, "listing structure schemas"));
|
|
84
|
+
}
|
|
53
85
|
}),
|
|
54
86
|
}), {
|
|
55
87
|
description: "Full schema definition for a specific structure",
|
|
56
88
|
mimeType: "application/json",
|
|
57
89
|
}, (uri_1, _a) => __awaiter(this, [uri_1, _a], void 0, function* (uri, { slug }) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
90
|
+
try {
|
|
91
|
+
const result = yield sdk.structures.getBySlug(slug);
|
|
92
|
+
return {
|
|
93
|
+
contents: [
|
|
94
|
+
{
|
|
95
|
+
uri: uri.href,
|
|
96
|
+
mimeType: "application/json",
|
|
97
|
+
text: JSON.stringify(result.data, null, 2),
|
|
98
|
+
},
|
|
99
|
+
],
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
throw new Error(formatError(error, `getting structure schema for '${slug}'`));
|
|
104
|
+
}
|
|
68
105
|
}));
|
|
69
106
|
}
|
package/dist/tools/compute.js
CHANGED
|
@@ -11,6 +11,28 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.registerComputeTools = registerComputeTools;
|
|
13
13
|
const zod_1 = require("zod");
|
|
14
|
+
function formatError(error, context) {
|
|
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
36
|
function registerComputeTools(server, sdk) {
|
|
15
37
|
server.tool("list_functions", "List all compute functions in the workspace. Compute functions are JavaScript code blocks that run server-side.", {
|
|
16
38
|
page: zod_1.z.number().optional().describe("Page number"),
|
|
@@ -34,7 +56,7 @@ function registerComputeTools(server, sdk) {
|
|
|
34
56
|
content: [
|
|
35
57
|
{
|
|
36
58
|
type: "text",
|
|
37
|
-
text:
|
|
59
|
+
text: formatError(error, "listing functions"),
|
|
38
60
|
},
|
|
39
61
|
],
|
|
40
62
|
isError: true,
|
|
@@ -69,7 +91,7 @@ function registerComputeTools(server, sdk) {
|
|
|
69
91
|
content: [
|
|
70
92
|
{
|
|
71
93
|
type: "text",
|
|
72
|
-
text:
|
|
94
|
+
text: formatError(error, "listing triggers"),
|
|
73
95
|
},
|
|
74
96
|
],
|
|
75
97
|
isError: true,
|
|
@@ -100,7 +122,7 @@ function registerComputeTools(server, sdk) {
|
|
|
100
122
|
content: [
|
|
101
123
|
{
|
|
102
124
|
type: "text",
|
|
103
|
-
text: `
|
|
125
|
+
text: formatError(error, `invoking trigger '${triggerId}'`),
|
|
104
126
|
},
|
|
105
127
|
],
|
|
106
128
|
isError: true,
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.registerInsightTools = registerInsightTools;
|
|
13
|
+
const zod_1 = require("zod");
|
|
14
|
+
function formatError(error, context) {
|
|
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
|
+
}
|
|
38
|
+
function registerInsightTools(server, sdk) {
|
|
39
|
+
server.tool("list_insights", "List anomaly insights detected by Centrali's AI analysis. Insights flag unusual patterns in your data such as spikes, drops, or outliers.", {
|
|
40
|
+
structureSlug: zod_1.z
|
|
41
|
+
.string()
|
|
42
|
+
.optional()
|
|
43
|
+
.describe("Filter insights by structure slug. If omitted, returns insights for all structures."),
|
|
44
|
+
status: zod_1.z
|
|
45
|
+
.enum(["active", "acknowledged", "dismissed"])
|
|
46
|
+
.optional()
|
|
47
|
+
.describe("Filter by insight status"),
|
|
48
|
+
severity: zod_1.z
|
|
49
|
+
.enum(["critical", "high", "medium", "low"])
|
|
50
|
+
.optional()
|
|
51
|
+
.describe("Filter by severity level"),
|
|
52
|
+
}, (_a) => __awaiter(this, [_a], void 0, function* ({ structureSlug, status, severity }) {
|
|
53
|
+
try {
|
|
54
|
+
const options = {};
|
|
55
|
+
if (structureSlug)
|
|
56
|
+
options.structureSlug = structureSlug;
|
|
57
|
+
if (status)
|
|
58
|
+
options.status = status;
|
|
59
|
+
if (severity)
|
|
60
|
+
options.severity = severity;
|
|
61
|
+
const result = yield sdk.anomalyInsights.list(Object.keys(options).length > 0 ? options : undefined);
|
|
62
|
+
return {
|
|
63
|
+
content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }],
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
return {
|
|
68
|
+
content: [{ type: "text", text: formatError(error, "listing insights") }],
|
|
69
|
+
isError: true,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
}));
|
|
73
|
+
server.tool("get_insight", "Get full details of a single anomaly insight by ID.", {
|
|
74
|
+
insightId: zod_1.z.string().describe("The insight ID (UUID)"),
|
|
75
|
+
}, (_a) => __awaiter(this, [_a], void 0, function* ({ insightId }) {
|
|
76
|
+
try {
|
|
77
|
+
const result = yield sdk.anomalyInsights.get(insightId);
|
|
78
|
+
return {
|
|
79
|
+
content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }],
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
return {
|
|
84
|
+
content: [
|
|
85
|
+
{ type: "text", text: formatError(error, `getting insight '${insightId}'`) },
|
|
86
|
+
],
|
|
87
|
+
isError: true,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
}));
|
|
91
|
+
server.tool("acknowledge_insight", "Mark an anomaly insight as acknowledged (reviewed/handled). The insight remains visible but is flagged as addressed.", {
|
|
92
|
+
insightId: zod_1.z.string().describe("The insight ID (UUID) to acknowledge"),
|
|
93
|
+
}, (_a) => __awaiter(this, [_a], void 0, function* ({ insightId }) {
|
|
94
|
+
try {
|
|
95
|
+
const result = yield sdk.anomalyInsights.acknowledge(insightId);
|
|
96
|
+
return {
|
|
97
|
+
content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }],
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
return {
|
|
102
|
+
content: [
|
|
103
|
+
{
|
|
104
|
+
type: "text",
|
|
105
|
+
text: formatError(error, `acknowledging insight '${insightId}'`),
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
isError: true,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
}));
|
|
112
|
+
server.tool("dismiss_insight", "Dismiss an anomaly insight, marking it as a false positive or not relevant.", {
|
|
113
|
+
insightId: zod_1.z.string().describe("The insight ID (UUID) to dismiss"),
|
|
114
|
+
}, (_a) => __awaiter(this, [_a], void 0, function* ({ insightId }) {
|
|
115
|
+
try {
|
|
116
|
+
const result = yield sdk.anomalyInsights.dismiss(insightId);
|
|
117
|
+
return {
|
|
118
|
+
content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }],
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
catch (error) {
|
|
122
|
+
return {
|
|
123
|
+
content: [
|
|
124
|
+
{ type: "text", text: formatError(error, `dismissing insight '${insightId}'`) },
|
|
125
|
+
],
|
|
126
|
+
isError: true,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
}));
|
|
130
|
+
server.tool("get_insights_summary", "Get a summary of anomaly insights in the workspace — counts by status and severity. Optionally filter by structure.", {
|
|
131
|
+
structureSlug: zod_1.z
|
|
132
|
+
.string()
|
|
133
|
+
.optional()
|
|
134
|
+
.describe("Filter summary to a specific structure. If omitted, returns workspace-wide summary."),
|
|
135
|
+
}, (_a) => __awaiter(this, [_a], void 0, function* ({ structureSlug }) {
|
|
136
|
+
try {
|
|
137
|
+
const result = yield sdk.anomalyInsights.getSummary(structureSlug);
|
|
138
|
+
return {
|
|
139
|
+
content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }],
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
catch (error) {
|
|
143
|
+
return {
|
|
144
|
+
content: [
|
|
145
|
+
{ type: "text", text: formatError(error, "getting insights summary") },
|
|
146
|
+
],
|
|
147
|
+
isError: true,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
}));
|
|
151
|
+
server.tool("trigger_anomaly_analysis", "Trigger AI-powered anomaly analysis for a structure. Starts a background analysis to detect unusual patterns. Check list_insights after the scan completes.", {
|
|
152
|
+
structureSlug: zod_1.z.string().describe("The structure's record slug to analyze"),
|
|
153
|
+
}, (_a) => __awaiter(this, [_a], void 0, function* ({ structureSlug }) {
|
|
154
|
+
try {
|
|
155
|
+
const result = yield sdk.anomalyInsights.triggerAnalysis(structureSlug);
|
|
156
|
+
return {
|
|
157
|
+
content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }],
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
catch (error) {
|
|
161
|
+
return {
|
|
162
|
+
content: [
|
|
163
|
+
{
|
|
164
|
+
type: "text",
|
|
165
|
+
text: formatError(error, `triggering anomaly analysis for '${structureSlug}'`),
|
|
166
|
+
},
|
|
167
|
+
],
|
|
168
|
+
isError: true,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
}));
|
|
172
|
+
}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.registerOrchestrationTools = registerOrchestrationTools;
|
|
13
|
+
const zod_1 = require("zod");
|
|
14
|
+
function formatError(error, context) {
|
|
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
|
+
}
|
|
38
|
+
function registerOrchestrationTools(server, sdk) {
|
|
39
|
+
server.tool("list_orchestrations", "List all orchestrations in the workspace. Orchestrations are multi-step workflows that chain compute functions together.", {
|
|
40
|
+
offset: zod_1.z.number().optional().describe("Number of results to skip (for pagination)"),
|
|
41
|
+
limit: zod_1.z.number().optional().describe("Results per page"),
|
|
42
|
+
status: zod_1.z
|
|
43
|
+
.enum(["draft", "active", "paused"])
|
|
44
|
+
.optional()
|
|
45
|
+
.describe("Filter by orchestration status"),
|
|
46
|
+
}, (_a) => __awaiter(this, [_a], void 0, function* ({ offset, limit, status }) {
|
|
47
|
+
try {
|
|
48
|
+
const options = {};
|
|
49
|
+
if (offset !== undefined)
|
|
50
|
+
options.offset = offset;
|
|
51
|
+
if (limit !== undefined)
|
|
52
|
+
options.limit = limit;
|
|
53
|
+
if (status)
|
|
54
|
+
options.status = status;
|
|
55
|
+
const result = yield sdk.orchestrations.list(Object.keys(options).length > 0 ? options : undefined);
|
|
56
|
+
return {
|
|
57
|
+
content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }],
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
return {
|
|
62
|
+
content: [{ type: "text", text: formatError(error, "listing orchestrations") }],
|
|
63
|
+
isError: true,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
}));
|
|
67
|
+
server.tool("get_orchestration", "Get full details of a single orchestration by ID, including its step definitions.", {
|
|
68
|
+
orchestrationId: zod_1.z.string().describe("The orchestration ID (UUID)"),
|
|
69
|
+
}, (_a) => __awaiter(this, [_a], void 0, function* ({ orchestrationId }) {
|
|
70
|
+
try {
|
|
71
|
+
const result = yield sdk.orchestrations.get(orchestrationId);
|
|
72
|
+
return {
|
|
73
|
+
content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }],
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
return {
|
|
78
|
+
content: [
|
|
79
|
+
{
|
|
80
|
+
type: "text",
|
|
81
|
+
text: formatError(error, `getting orchestration '${orchestrationId}'`),
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
isError: true,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
}));
|
|
88
|
+
server.tool("trigger_orchestration", "Trigger an orchestration run. Creates a new run instance and starts executing the workflow. Optionally pass input data to the run.", {
|
|
89
|
+
orchestrationId: zod_1.z.string().describe("The orchestration ID (UUID) to trigger"),
|
|
90
|
+
input: zod_1.z
|
|
91
|
+
.record(zod_1.z.string(), zod_1.z.any())
|
|
92
|
+
.optional()
|
|
93
|
+
.describe("Input data passed to the first step of the orchestration"),
|
|
94
|
+
correlationId: zod_1.z
|
|
95
|
+
.string()
|
|
96
|
+
.optional()
|
|
97
|
+
.describe("Optional correlation ID for tracing this run"),
|
|
98
|
+
}, (_a) => __awaiter(this, [_a], void 0, function* ({ orchestrationId, input, correlationId }) {
|
|
99
|
+
try {
|
|
100
|
+
const options = {};
|
|
101
|
+
if (input)
|
|
102
|
+
options.input = input;
|
|
103
|
+
if (correlationId)
|
|
104
|
+
options.correlationId = correlationId;
|
|
105
|
+
const result = yield sdk.orchestrations.trigger(orchestrationId, Object.keys(options).length > 0 ? options : undefined);
|
|
106
|
+
return {
|
|
107
|
+
content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }],
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
return {
|
|
112
|
+
content: [
|
|
113
|
+
{
|
|
114
|
+
type: "text",
|
|
115
|
+
text: formatError(error, `triggering orchestration '${orchestrationId}'`),
|
|
116
|
+
},
|
|
117
|
+
],
|
|
118
|
+
isError: true,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
}));
|
|
122
|
+
server.tool("list_orchestration_runs", "List all runs for an orchestration. Runs represent individual executions of the workflow.", {
|
|
123
|
+
orchestrationId: zod_1.z.string().describe("The orchestration ID (UUID)"),
|
|
124
|
+
offset: zod_1.z.number().optional().describe("Number of results to skip (for pagination)"),
|
|
125
|
+
limit: zod_1.z.number().optional().describe("Results per page"),
|
|
126
|
+
status: zod_1.z
|
|
127
|
+
.enum(["pending", "running", "waiting", "completed", "failed"])
|
|
128
|
+
.optional()
|
|
129
|
+
.describe("Filter by run status"),
|
|
130
|
+
}, (_a) => __awaiter(this, [_a], void 0, function* ({ orchestrationId, offset, limit, status }) {
|
|
131
|
+
try {
|
|
132
|
+
const options = {};
|
|
133
|
+
if (offset !== undefined)
|
|
134
|
+
options.offset = offset;
|
|
135
|
+
if (limit !== undefined)
|
|
136
|
+
options.limit = limit;
|
|
137
|
+
if (status)
|
|
138
|
+
options.status = status;
|
|
139
|
+
const result = yield sdk.orchestrations.listRuns(orchestrationId, Object.keys(options).length > 0 ? options : undefined);
|
|
140
|
+
return {
|
|
141
|
+
content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }],
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
catch (error) {
|
|
145
|
+
return {
|
|
146
|
+
content: [
|
|
147
|
+
{
|
|
148
|
+
type: "text",
|
|
149
|
+
text: formatError(error, `listing runs for orchestration '${orchestrationId}'`),
|
|
150
|
+
},
|
|
151
|
+
],
|
|
152
|
+
isError: true,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
}));
|
|
156
|
+
server.tool("get_orchestration_run", "Get details of a specific orchestration run. Set includeSteps=true to see step-by-step execution history.", {
|
|
157
|
+
orchestrationId: zod_1.z.string().describe("The orchestration ID (UUID)"),
|
|
158
|
+
runId: zod_1.z.string().describe("The run ID (UUID)"),
|
|
159
|
+
includeSteps: zod_1.z
|
|
160
|
+
.boolean()
|
|
161
|
+
.optional()
|
|
162
|
+
.describe("Include step execution history in the response (default: false)"),
|
|
163
|
+
}, (_a) => __awaiter(this, [_a], void 0, function* ({ orchestrationId, runId, includeSteps }) {
|
|
164
|
+
try {
|
|
165
|
+
const result = yield sdk.orchestrations.getRun(orchestrationId, runId, includeSteps);
|
|
166
|
+
return {
|
|
167
|
+
content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }],
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
catch (error) {
|
|
171
|
+
return {
|
|
172
|
+
content: [
|
|
173
|
+
{
|
|
174
|
+
type: "text",
|
|
175
|
+
text: formatError(error, `getting run '${runId}' for orchestration '${orchestrationId}'`),
|
|
176
|
+
},
|
|
177
|
+
],
|
|
178
|
+
isError: true,
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
}));
|
|
182
|
+
}
|