@centrali-io/centrali-mcp 4.4.4 → 4.4.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/README.md +146 -14
- package/dist/index.js +5 -1
- package/dist/tools/auth-providers.d.ts +3 -0
- package/dist/tools/auth-providers.js +267 -0
- package/dist/tools/compute.d.ts +1 -1
- package/dist/tools/compute.js +131 -2
- package/dist/tools/describe.js +499 -5
- package/dist/tools/orchestrations.js +9 -9
- package/dist/tools/pages.js +31 -12
- package/dist/tools/service-accounts.d.ts +3 -0
- package/dist/tools/service-accounts.js +856 -0
- package/package.json +2 -2
- package/src/index.ts +5 -1
- package/src/tools/auth-providers.ts +290 -0
- package/src/tools/compute.ts +142 -2
- package/src/tools/describe.ts +521 -5
- package/src/tools/orchestrations.ts +9 -9
- package/src/tools/pages.ts +27 -9
- package/src/tools/service-accounts.ts +1051 -0
package/dist/tools/compute.js
CHANGED
|
@@ -8,8 +8,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
15
|
exports.registerComputeTools = registerComputeTools;
|
|
16
|
+
const axios_1 = __importDefault(require("axios"));
|
|
13
17
|
const zod_1 = require("zod");
|
|
14
18
|
function formatError(error, context) {
|
|
15
19
|
var _a, _b;
|
|
@@ -33,7 +37,22 @@ function formatError(error, context) {
|
|
|
33
37
|
}
|
|
34
38
|
return `Error ${context}: ${error instanceof Error ? error.message : String(error)}`;
|
|
35
39
|
}
|
|
36
|
-
|
|
40
|
+
/**
|
|
41
|
+
* Ensures the SDK has a valid token.
|
|
42
|
+
*/
|
|
43
|
+
function ensureToken(sdk) {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
let token = sdk.getToken();
|
|
46
|
+
if (token)
|
|
47
|
+
return token;
|
|
48
|
+
try {
|
|
49
|
+
yield sdk.functions.list({ limit: 1 });
|
|
50
|
+
}
|
|
51
|
+
catch ( /* token refresh side effect */_a) { /* token refresh side effect */ }
|
|
52
|
+
return sdk.getToken();
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
function registerComputeTools(server, sdk, centraliUrl, workspaceId) {
|
|
37
56
|
server.tool("list_functions", "List all compute functions in the workspace. Compute functions are JavaScript code blocks that run server-side.", {
|
|
38
57
|
page: zod_1.z.number().optional().describe("Page number"),
|
|
39
58
|
limit: zod_1.z.number().optional().describe("Results per page"),
|
|
@@ -112,7 +131,11 @@ function registerComputeTools(server, sdk) {
|
|
|
112
131
|
content: [
|
|
113
132
|
{
|
|
114
133
|
type: "text",
|
|
115
|
-
text: JSON.stringify({
|
|
134
|
+
text: JSON.stringify({
|
|
135
|
+
jobId: result.data,
|
|
136
|
+
message: "Trigger invoked successfully. Execution is async — the function is running in the background.",
|
|
137
|
+
next_step: `To check the result, call get_compute_job_status with jobId='${result.data}'. It returns the job state (queued → running → completed | failed) and the return value or error.`,
|
|
138
|
+
}, null, 2),
|
|
116
139
|
},
|
|
117
140
|
],
|
|
118
141
|
};
|
|
@@ -129,6 +152,37 @@ function registerComputeTools(server, sdk) {
|
|
|
129
152
|
};
|
|
130
153
|
}
|
|
131
154
|
}));
|
|
155
|
+
server.tool("get_compute_job_status", "Check the status of an async compute job by job ID. Returns the current state (queued, running, completed, failed), the return value on success, or the failure reason on error. Use this after invoke_trigger to poll for results.", {
|
|
156
|
+
jobId: zod_1.z.string().describe("The job ID returned by invoke_trigger"),
|
|
157
|
+
}, (_a) => __awaiter(this, [_a], void 0, function* ({ jobId }) {
|
|
158
|
+
try {
|
|
159
|
+
const token = yield ensureToken(sdk);
|
|
160
|
+
const url = new URL(centraliUrl);
|
|
161
|
+
const hostname = url.hostname.startsWith("api.")
|
|
162
|
+
? url.hostname
|
|
163
|
+
: `api.${url.hostname}`;
|
|
164
|
+
const apiUrl = `${url.protocol}//${hostname}/data/workspace/${workspaceId}/api/v1/jobs/compute/${jobId}`;
|
|
165
|
+
const result = yield axios_1.default.get(apiUrl, {
|
|
166
|
+
headers: token ? { Authorization: `Bearer ${token}` } : {},
|
|
167
|
+
});
|
|
168
|
+
return {
|
|
169
|
+
content: [
|
|
170
|
+
{ type: "text", text: JSON.stringify(result.data, null, 2) },
|
|
171
|
+
],
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
catch (error) {
|
|
175
|
+
return {
|
|
176
|
+
content: [
|
|
177
|
+
{
|
|
178
|
+
type: "text",
|
|
179
|
+
text: formatError(error, `getting job status for '${jobId}'`),
|
|
180
|
+
},
|
|
181
|
+
],
|
|
182
|
+
isError: true,
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
}));
|
|
132
186
|
// ── Function CRUD tools ──────────────────────────────────────────
|
|
133
187
|
server.tool("get_function", "Get a compute function by ID. Returns the full function definition including code.", {
|
|
134
188
|
functionId: zod_1.z.string().describe("The compute function ID (UUID)"),
|
|
@@ -487,6 +541,81 @@ function registerComputeTools(server, sdk) {
|
|
|
487
541
|
};
|
|
488
542
|
}
|
|
489
543
|
}));
|
|
544
|
+
// ── Function Runs tools ────────────────────────────────────────────
|
|
545
|
+
server.tool("get_function_run", "Get a function run by ID. Returns status, output, error, timing, and execution metadata. Use this to check the result of an async trigger invocation or test execution.", {
|
|
546
|
+
runId: zod_1.z.string().describe("The function run ID (UUID)"),
|
|
547
|
+
}, (_a) => __awaiter(this, [_a], void 0, function* ({ runId }) {
|
|
548
|
+
try {
|
|
549
|
+
const result = yield sdk.runs.get(runId);
|
|
550
|
+
return {
|
|
551
|
+
content: [
|
|
552
|
+
{ type: "text", text: JSON.stringify(result.data, null, 2) },
|
|
553
|
+
],
|
|
554
|
+
};
|
|
555
|
+
}
|
|
556
|
+
catch (error) {
|
|
557
|
+
return {
|
|
558
|
+
content: [
|
|
559
|
+
{
|
|
560
|
+
type: "text",
|
|
561
|
+
text: formatError(error, `getting function run '${runId}'`),
|
|
562
|
+
},
|
|
563
|
+
],
|
|
564
|
+
isError: true,
|
|
565
|
+
};
|
|
566
|
+
}
|
|
567
|
+
}));
|
|
568
|
+
server.tool("list_function_runs", "List function runs filtered by trigger ID or function ID. Returns execution history with status, timing, and errors. Useful for checking whether a trigger invocation completed and what it returned.", {
|
|
569
|
+
triggerId: zod_1.z.string().optional().describe("Filter runs by trigger ID (UUID)"),
|
|
570
|
+
functionId: zod_1.z.string().optional().describe("Filter runs by function ID (UUID)"),
|
|
571
|
+
status: zod_1.z
|
|
572
|
+
.enum(["pending", "running", "completed", "failure", "timeout"])
|
|
573
|
+
.optional()
|
|
574
|
+
.describe("Filter by run status"),
|
|
575
|
+
page: zod_1.z.number().optional().describe("Page number"),
|
|
576
|
+
limit: zod_1.z.number().optional().describe("Results per page"),
|
|
577
|
+
}, (_a) => __awaiter(this, [_a], void 0, function* ({ triggerId, functionId, status, page, limit }) {
|
|
578
|
+
try {
|
|
579
|
+
if (!triggerId && !functionId) {
|
|
580
|
+
return {
|
|
581
|
+
content: [
|
|
582
|
+
{
|
|
583
|
+
type: "text",
|
|
584
|
+
text: "Error: provide either triggerId or functionId to list runs.",
|
|
585
|
+
},
|
|
586
|
+
],
|
|
587
|
+
isError: true,
|
|
588
|
+
};
|
|
589
|
+
}
|
|
590
|
+
const options = {};
|
|
591
|
+
if (status)
|
|
592
|
+
options.status = status;
|
|
593
|
+
if (page !== undefined)
|
|
594
|
+
options.page = page;
|
|
595
|
+
if (limit !== undefined)
|
|
596
|
+
options.limit = limit;
|
|
597
|
+
const opts = Object.keys(options).length > 0 ? options : undefined;
|
|
598
|
+
const result = triggerId
|
|
599
|
+
? yield sdk.runs.listByTrigger(triggerId, opts)
|
|
600
|
+
: yield sdk.runs.listByFunction(functionId, opts);
|
|
601
|
+
return {
|
|
602
|
+
content: [
|
|
603
|
+
{ type: "text", text: JSON.stringify(result.data, null, 2) },
|
|
604
|
+
],
|
|
605
|
+
};
|
|
606
|
+
}
|
|
607
|
+
catch (error) {
|
|
608
|
+
return {
|
|
609
|
+
content: [
|
|
610
|
+
{
|
|
611
|
+
type: "text",
|
|
612
|
+
text: formatError(error, `listing function runs`),
|
|
613
|
+
},
|
|
614
|
+
],
|
|
615
|
+
isError: true,
|
|
616
|
+
};
|
|
617
|
+
}
|
|
618
|
+
}));
|
|
490
619
|
// ── Allowed Domains tools ──────────────────────────────────────────
|
|
491
620
|
server.tool("list_allowed_domains", "List all allowed domains for compute function HTTP requests. Functions can only call external APIs on domains in this allowlist.", {}, () => __awaiter(this, void 0, void 0, function* () {
|
|
492
621
|
try {
|