@centrali-io/centrali-mcp 9.5.1 → 9.6.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 +55 -1
- package/dist/index.js +2 -0
- package/dist/tools/describe.js +5 -5
- package/dist/tools/files.d.ts +3 -0
- package/dist/tools/files.js +73 -0
- package/dist/tools/insights.js +14 -0
- package/dist/tools/service-accounts.js +65 -65
- package/package.json +3 -2
- package/src/index.ts +2 -0
- package/src/tools/describe.ts +5 -5
- package/src/tools/files.ts +72 -0
- package/src/tools/insights.ts +19 -0
- package/src/tools/service-accounts.ts +65 -65
- package/tests/describeCapabilities.test.cjs +5 -2
- package/tests/files.test.cjs +143 -0
- package/tests/serviceAccountsRouting.test.cjs +94 -0
- package/tests/triggerHealth.test.cjs +37 -0
package/README.md
CHANGED
|
@@ -4,7 +4,47 @@ MCP (Model Context Protocol) server for the Centrali platform. Lets AI assistant
|
|
|
4
4
|
|
|
5
5
|
> **Full documentation:** [docs.centrali.io](https://docs.centrali.io) — SDK guide, API reference, compute functions, orchestrations, and more.
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## File uploads
|
|
8
|
+
|
|
9
|
+
Both hosted and stdio servers provide `upload_file`. It uploads a standalone Storage
|
|
10
|
+
file through the existing SDK and Storage API, using the authenticated workspace
|
|
11
|
+
and its existing folder permissions. Node.js 22 or newer is required for stdio.
|
|
12
|
+
|
|
13
|
+
```json
|
|
14
|
+
{
|
|
15
|
+
"filename": "hello.txt",
|
|
16
|
+
"contentType": "text/plain",
|
|
17
|
+
"contentEncoding": "utf8",
|
|
18
|
+
"content": "Hello from MCP"
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
For binary files use `contentEncoding: "base64"` with canonical padded base64
|
|
23
|
+
(no data URL prefix or whitespace). The decoded limit is **256 KiB**, including
|
|
24
|
+
UTF-8 byte length for text. Empty files are supported. The serialized `content`
|
|
25
|
+
JSON string also has a **768 KiB** limit so JSON escaping leaves room within the
|
|
26
|
+
hosted server's 1 MB request limit. For heavily escaped text (such as control
|
|
27
|
+
characters), encode the exact UTF-8 bytes as base64 instead.
|
|
28
|
+
`location` defaults to `/root/shared`; custom folders
|
|
29
|
+
must already exist. Files are private unless `isPublic: true` is explicitly set.
|
|
30
|
+
Public uploads allow only PNG, JPEG, GIF, WebP, plain text, JSON, MPEG/OGG/WAV
|
|
31
|
+
audio, and MP4/WebM video MIME types. HTML, SVG, XML and other active document
|
|
32
|
+
types cannot be made public through this tool because Storage serves the
|
|
33
|
+
supplied MIME type inline on the API origin. Private uploads retain support
|
|
34
|
+
for arbitrary MIME types. The SDK prefixes stored filenames with the workspace
|
|
35
|
+
and a timestamp.
|
|
36
|
+
|
|
37
|
+
The result contains `renderId`, `sizeBytes`, `contentType`, `isPublic`, `renderUrl`
|
|
38
|
+
and `downloadUrl`. Private URLs still require normal authentication. Attach the
|
|
39
|
+
returned render ID using a separate record update; an attachment failure leaves
|
|
40
|
+
the uploaded file in Storage. Repeating an upload can create another file.
|
|
41
|
+
|
|
42
|
+
The tool accepts content supplied by the client. It cannot read local paths,
|
|
43
|
+
fetch source URLs, or access chat attachments/generated images hidden by the
|
|
44
|
+
host. Never reconstruct image bytes through model transcription. Files larger
|
|
45
|
+
than 256 KiB must use the existing SDK/HTTP multipart upload API.
|
|
46
|
+
|
|
47
|
+
## Connection options
|
|
8
48
|
|
|
9
49
|
### Option 1: Hosted MCP Server (recommended)
|
|
10
50
|
|
|
@@ -416,3 +456,17 @@ CENTRALI_CLIENT_SECRET=... \
|
|
|
416
456
|
CENTRALI_WORKSPACE=my-workspace \
|
|
417
457
|
npx @modelcontextprotocol/inspector node dist/index.js
|
|
418
458
|
```
|
|
459
|
+
|
|
460
|
+
|
|
461
|
+
### Service-account identifiers
|
|
462
|
+
|
|
463
|
+
Account-path tools use the string `clientId` returned by `create_service_account` / `list_service_accounts`, including get, update, rotate, revoke, delete, dev-token, role/group membership, and permission scan/simulate. They no longer accept numeric `serviceAccountId` inputs. Existing legacy client IDs are supported. Upgrade this package alongside IAM when deploying the client-ID route change.
|
|
464
|
+
|
|
465
|
+
The separate `generate_remediation`, `preview_remediation`, and `apply_remediation` tools retain their numeric `serviceAccountId` argument for the access API's `targetId` contract. Account responses continue to include both `id` and `clientId`.
|
|
466
|
+
|
|
467
|
+
## Development tests
|
|
468
|
+
|
|
469
|
+
`npm test` builds the sibling SDK first when running in the monorepo, then builds
|
|
470
|
+
MCP and runs its tests. The health regression uses the real SDK normalization,
|
|
471
|
+
so its runtime distribution must exist even on a fresh checkout. Outside the
|
|
472
|
+
monorepo, tests use the installed SDK distribution instead.
|
package/dist/index.js
CHANGED
|
@@ -26,6 +26,7 @@ const auth_providers_js_1 = require("./tools/auth-providers.js");
|
|
|
26
26
|
const service_accounts_js_1 = require("./tools/service-accounts.js");
|
|
27
27
|
const webhook_subscriptions_js_1 = require("./tools/webhook-subscriptions.js");
|
|
28
28
|
const events_js_1 = require("./tools/events.js");
|
|
29
|
+
const files_js_1 = require("./tools/files.js");
|
|
29
30
|
const structures_js_2 = require("./resources/structures.js");
|
|
30
31
|
function getRequiredEnv(name) {
|
|
31
32
|
const value = process.env[name];
|
|
@@ -85,6 +86,7 @@ function main() {
|
|
|
85
86
|
(0, webhook_subscriptions_js_1.registerWebhookSubscriptionTools)(server, sdk);
|
|
86
87
|
(0, events_js_1.registerEventTools)(server, sdk, baseUrl, workspaceId);
|
|
87
88
|
(0, describe_js_1.registerDescribeTools)(server);
|
|
89
|
+
(0, files_js_1.registerFileTools)(server, sdk);
|
|
88
90
|
// Register resources
|
|
89
91
|
(0, structures_js_2.registerCollectionResources)(server, sdk);
|
|
90
92
|
(0, structures_js_2.registerStructureResources)(server, sdk);
|
package/dist/tools/describe.js
CHANGED
|
@@ -285,7 +285,7 @@ function registerDescribeTools(server) {
|
|
|
285
285
|
"Function runs (execution history)": { sdk: true, mcp: true, console: true },
|
|
286
286
|
"Outbound webhooks": { sdk: true, mcp: true, console: true, note: "SDK namespace (client.webhookSubscriptions) and MCP tools wrap the REST surface including delivery replay" },
|
|
287
287
|
"Service accounts & IAM": { sdk: false, mcp: true, console: true, note: "MCP tools for full SA lifecycle, roles, groups, and permission introspection" },
|
|
288
|
-
"File uploads": { sdk: true, mcp:
|
|
288
|
+
"File uploads": { sdk: true, mcp: true, console: true, note: "upload_file accepts up to 256 KiB decoded and 768 KiB serialized content; public uploads require a passive MIME type. Larger files use client.uploadFile()." },
|
|
289
289
|
},
|
|
290
290
|
},
|
|
291
291
|
sdk_integration: {
|
|
@@ -302,7 +302,7 @@ function registerDescribeTools(server) {
|
|
|
302
302
|
note: "workspaceId is the workspace slug (e.g., 'acme'), not a UUID. See https://docs.centrali.io/guides/centrali-sdk for the full guide.",
|
|
303
303
|
},
|
|
304
304
|
file_storage: {
|
|
305
|
-
description: "Centrali has built-in file storage (Azure Blob). Use the SDK
|
|
305
|
+
description: "Centrali has built-in file storage (Azure Blob). Use upload_file via MCP for files up to 256 KiB decoded (base64 or utf8), or the SDK for larger uploads. MCP uploads return renderId and render/download URLs, default to private, and use existing workspace folder permissions. Record attachment is a separate update. Private URLs require normal authentication. The MCP tool cannot access host attachments or local paths directly.",
|
|
306
306
|
folder_system: {
|
|
307
307
|
description: "Files live in folders. Every workspace starts with system folders: /root, /root/shared, /root/users, /root/_data_directory. You MUST create a folder before uploading to it — uploading to a non-existent folder will fail.",
|
|
308
308
|
system_folders: {
|
|
@@ -1782,13 +1782,13 @@ function registerDescribeTools(server) {
|
|
|
1782
1782
|
},
|
|
1783
1783
|
development: {
|
|
1784
1784
|
description: "Dev tokens — short-lived tokens for testing without the OAuth2 flow.",
|
|
1785
|
-
tool: "generate_dev_token(
|
|
1785
|
+
tool: "generate_dev_token(clientId, ttlSeconds)",
|
|
1786
1786
|
note: "Dev tokens have limited TTL. For production, always use client_credentials flow.",
|
|
1787
1787
|
},
|
|
1788
1788
|
},
|
|
1789
1789
|
service_account_shape: {
|
|
1790
|
-
id: "number —
|
|
1791
|
-
clientId: "string —
|
|
1790
|
+
id: "number — internal database key; used by remediation and role-query contracts, not service-account paths",
|
|
1791
|
+
clientId: "string — opaque public identifier (new accounts: sa_<hex>; legacy IDs preserved); used in all service-account paths and as client_id for token requests",
|
|
1792
1792
|
clientSecret: "string — format: sk_<hex> — ONLY returned on creation and rotation",
|
|
1793
1793
|
name: "string — display name",
|
|
1794
1794
|
description: "string | null — optional description",
|
|
@@ -0,0 +1,73 @@
|
|
|
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.registerFileTools = registerFileTools;
|
|
13
|
+
const zod_1 = require("zod");
|
|
14
|
+
const _register_js_1 = require("./_register.js");
|
|
15
|
+
const MAX_FILE_BYTES = 256 * 1024;
|
|
16
|
+
const MAX_CONTENT_CHARS = 4 * Math.ceil(MAX_FILE_BYTES / 3);
|
|
17
|
+
const MAX_CONTENT_JSON_BYTES = 768 * 1024;
|
|
18
|
+
// Storage renders the supplied MIME type inline on the API origin.
|
|
19
|
+
// Keep active documents (HTML, SVG, XML, etc.) out of public MCP uploads.
|
|
20
|
+
const PUBLIC_CONTENT_TYPES = new Set([
|
|
21
|
+
"image/png", "image/jpeg", "image/gif", "image/webp",
|
|
22
|
+
"text/plain", "application/json",
|
|
23
|
+
"audio/mpeg", "audio/ogg", "audio/wav", "video/mp4", "video/webm",
|
|
24
|
+
]);
|
|
25
|
+
const uploadSchema = zod_1.z.object({
|
|
26
|
+
filename: zod_1.z.string().min(1).max(255)
|
|
27
|
+
.refine(value => !/[\\/\x00-\x1f\x7f]/.test(value) && value !== "." && value !== "..", "Use a filename without path separators or control characters"),
|
|
28
|
+
contentType: zod_1.z.string().max(127)
|
|
29
|
+
.regex(/^[a-zA-Z0-9!#$&^_.+-]+\/[a-zA-Z0-9!#$&^_.+-]+$/, "Expected a MIME type such as image/png"),
|
|
30
|
+
contentEncoding: zod_1.z.enum(["base64", "utf8"]),
|
|
31
|
+
content: zod_1.z.string().max(MAX_CONTENT_CHARS)
|
|
32
|
+
.refine(value => Buffer.byteLength(JSON.stringify(value), "utf8") <= MAX_CONTENT_JSON_BYTES, "Serialized content exceeds 768 KiB; use base64 for heavily escaped text")
|
|
33
|
+
.describe("Exact file content, including empty content. Maximum 256 KiB decoded and 768 KiB as a JSON string; use base64 for heavily escaped UTF-8 text."),
|
|
34
|
+
location: zod_1.z.string().min(1).max(1024).optional()
|
|
35
|
+
.describe("Existing destination folder; defaults to /root/shared. Does not create folders."),
|
|
36
|
+
isPublic: zod_1.z.boolean().default(false)
|
|
37
|
+
.describe("Explicitly opt into unauthenticated public access. Only PNG, JPEG, GIF, WebP, plain text, JSON, MPEG/OGG/WAV audio and MP4/WebM video are allowed publicly. Defaults to private."),
|
|
38
|
+
});
|
|
39
|
+
function registerFileTools(server, sdk) {
|
|
40
|
+
(0, _register_js_1.registerTool)(server, "upload_file", "Upload a standalone file or image into the authenticated workspace's Storage (maximum 256 KiB decoded). Supply exact bytes as canonical padded base64, or text as utf8; never reconstruct binary bytes from an image description. Requires files/create permission on the destination folder. Private by default. Returns renderId and render/download URLs; private URLs require normal authentication. Use renderId in a separate record update to attach the file. This tool cannot access host attachments, local paths, or source URLs. Repeating an upload can create another file; it is not idempotent.", uploadSchema.shape, (args) => __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
try {
|
|
42
|
+
const input = uploadSchema.parse(args);
|
|
43
|
+
if (input.isPublic && !PUBLIC_CONTENT_TYPES.has(input.contentType.toLowerCase())) {
|
|
44
|
+
throw new Error("Public uploads require a supported passive MIME type; HTML, SVG and other active documents must remain private");
|
|
45
|
+
}
|
|
46
|
+
const bytes = Buffer.from(input.content, input.contentEncoding === "base64" ? "base64" : "utf8");
|
|
47
|
+
if (bytes.length > MAX_FILE_BYTES) {
|
|
48
|
+
throw new Error("File exceeds the 256 KiB decoded upload limit");
|
|
49
|
+
}
|
|
50
|
+
if (input.contentEncoding === "base64" && bytes.toString("base64") !== input.content) {
|
|
51
|
+
throw new Error("content must be canonical padded base64");
|
|
52
|
+
}
|
|
53
|
+
const file = new File([new Uint8Array(bytes)], input.filename, { type: input.contentType });
|
|
54
|
+
const result = yield sdk.uploadFile(file, input.location, input.isPublic);
|
|
55
|
+
const renderId = result.data;
|
|
56
|
+
return { content: [{ type: "text", text: JSON.stringify({
|
|
57
|
+
renderId,
|
|
58
|
+
sizeBytes: bytes.length,
|
|
59
|
+
contentType: input.contentType,
|
|
60
|
+
isPublic: input.isPublic,
|
|
61
|
+
renderUrl: sdk.getFileRenderUrl(renderId),
|
|
62
|
+
downloadUrl: sdk.getFileDownloadUrl(renderId),
|
|
63
|
+
}, null, 2) }] };
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
// Zod errors include rejected input values. Never echo file content.
|
|
67
|
+
const message = error instanceof zod_1.z.ZodError
|
|
68
|
+
? "Invalid upload_file arguments; check filename, MIME type, encoding and content size"
|
|
69
|
+
: (0, _register_js_1.formatError)(error, "uploading file");
|
|
70
|
+
return { content: [{ type: "text", text: message }], isError: true };
|
|
71
|
+
}
|
|
72
|
+
}));
|
|
73
|
+
}
|
package/dist/tools/insights.js
CHANGED
|
@@ -13,6 +13,20 @@ exports.registerInsightTools = registerInsightTools;
|
|
|
13
13
|
const zod_1 = require("zod");
|
|
14
14
|
const _register_js_1 = require("./_register.js");
|
|
15
15
|
function registerInsightTools(server, sdk) {
|
|
16
|
+
(0, _register_js_1.registerTool)(server, "get_trigger_health", "Inspect HTTP request acceptance separately from execution success. Returns durable receivedCount, acceptedCount, rejectedCount, rejectionReasonBreakdown, requestAcceptanceRate (null without arrivals), and executionSuccessRate. Completed decisions are buffered and rolled up about every five minutes. Storage interruptions may lose or duplicate observations; rates are approximate. In-flight requests are not counted. Counts begin at tracking rollout; older traffic is unavailable. Omit triggerId for workspace health including unattributed requests to unknown paths. Non-HTTP triggers have execution health only.", {
|
|
17
|
+
triggerId: zod_1.z.string().uuid().optional().describe("Trigger UUID; omit to list workspace health"),
|
|
18
|
+
period: zod_1.z.union([zod_1.z.literal(7), zod_1.z.literal(30)]).optional().describe("Days of health history, default 30"),
|
|
19
|
+
}, (_a) => __awaiter(this, [_a], void 0, function* ({ triggerId, period }) {
|
|
20
|
+
try {
|
|
21
|
+
const result = triggerId
|
|
22
|
+
? yield sdk.triggers.healthTrend(triggerId, period)
|
|
23
|
+
: yield sdk.triggers.health(period);
|
|
24
|
+
return { content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }] };
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
return { content: [{ type: "text", text: (0, _register_js_1.formatError)(error, "getting trigger health") }], isError: true };
|
|
28
|
+
}
|
|
29
|
+
}));
|
|
16
30
|
(0, _register_js_1.registerTool)(server, "list_insights", "List anomaly insights detected by Centrali's AI analysis. Insights flag unusual patterns in your data such as spikes, drops, or outliers.", {
|
|
17
31
|
recordSlug: zod_1.z
|
|
18
32
|
.string()
|
|
@@ -133,7 +133,7 @@ function registerServiceAccountTools(server, sdk, centraliUrl, workspaceId, curr
|
|
|
133
133
|
description: me.description,
|
|
134
134
|
revoked: me.revoked,
|
|
135
135
|
workspace: workspaceId,
|
|
136
|
-
_hint: "Use
|
|
136
|
+
_hint: "Use clientId with scan_service_account_permissions and simulate_service_account_permission. Use the numeric id as serviceAccountId with generate_remediation, preview_remediation, and apply_remediation.",
|
|
137
137
|
}, null, 2),
|
|
138
138
|
}],
|
|
139
139
|
};
|
|
@@ -168,18 +168,18 @@ function registerServiceAccountTools(server, sdk, centraliUrl, workspaceId, curr
|
|
|
168
168
|
};
|
|
169
169
|
}
|
|
170
170
|
}));
|
|
171
|
-
(0, _register_js_1.registerTool)(server, "get_service_account", "Get details of a specific service account by its
|
|
172
|
-
|
|
173
|
-
}, (_a) => __awaiter(this, [_a], void 0, function* ({
|
|
171
|
+
(0, _register_js_1.registerTool)(server, "get_service_account", "Get details of a specific service account by its clientId. Returns name, clientId, description, and revocation status. Does NOT return the clientSecret (it's only shown once at creation time).", {
|
|
172
|
+
clientId: zod_1.z.string().describe("The service account clientId (not its numeric database id)"),
|
|
173
|
+
}, (_a) => __awaiter(this, [_a], void 0, function* ({ clientId }) {
|
|
174
174
|
try {
|
|
175
|
-
const result = yield getSaClient().get(`/${
|
|
175
|
+
const result = yield getSaClient().get(`/${encodeURIComponent(clientId)}`);
|
|
176
176
|
return {
|
|
177
177
|
content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }],
|
|
178
178
|
};
|
|
179
179
|
}
|
|
180
180
|
catch (error) {
|
|
181
181
|
return {
|
|
182
|
-
content: [{ type: "text", text: (0, _register_js_1.formatError)(error, `getting service account '${
|
|
182
|
+
content: [{ type: "text", text: (0, _register_js_1.formatError)(error, `getting service account '${encodeURIComponent(clientId)}'`) }],
|
|
183
183
|
isError: true,
|
|
184
184
|
};
|
|
185
185
|
}
|
|
@@ -208,61 +208,61 @@ function registerServiceAccountTools(server, sdk, centraliUrl, workspaceId, curr
|
|
|
208
208
|
}
|
|
209
209
|
}));
|
|
210
210
|
(0, _register_js_1.registerTool)(server, "update_service_account_name", "Update the display name of a service account.", {
|
|
211
|
-
|
|
211
|
+
clientId: zod_1.z.string().describe("The service account clientId (not its numeric database id)"),
|
|
212
212
|
name: zod_1.z.string().describe("New display name"),
|
|
213
|
-
}, (_a) => __awaiter(this, [_a], void 0, function* ({
|
|
213
|
+
}, (_a) => __awaiter(this, [_a], void 0, function* ({ clientId, name }) {
|
|
214
214
|
try {
|
|
215
|
-
const result = yield getSaClient().put(`/${
|
|
215
|
+
const result = yield getSaClient().put(`/${encodeURIComponent(clientId)}/name`, { name });
|
|
216
216
|
return {
|
|
217
217
|
content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }],
|
|
218
218
|
};
|
|
219
219
|
}
|
|
220
220
|
catch (error) {
|
|
221
221
|
return {
|
|
222
|
-
content: [{ type: "text", text: (0, _register_js_1.formatError)(error, `updating service account '${
|
|
222
|
+
content: [{ type: "text", text: (0, _register_js_1.formatError)(error, `updating service account '${encodeURIComponent(clientId)}' name`) }],
|
|
223
223
|
isError: true,
|
|
224
224
|
};
|
|
225
225
|
}
|
|
226
226
|
}));
|
|
227
227
|
(0, _register_js_1.registerTool)(server, "update_service_account_description", "Update the description of a service account.", {
|
|
228
|
-
|
|
228
|
+
clientId: zod_1.z.string().describe("The service account clientId (not its numeric database id)"),
|
|
229
229
|
description: zod_1.z.string().nullable().describe("New description (or null to clear)"),
|
|
230
|
-
}, (_a) => __awaiter(this, [_a], void 0, function* ({
|
|
230
|
+
}, (_a) => __awaiter(this, [_a], void 0, function* ({ clientId, description }) {
|
|
231
231
|
try {
|
|
232
|
-
const result = yield getSaClient().put(`/${
|
|
232
|
+
const result = yield getSaClient().put(`/${encodeURIComponent(clientId)}/description`, { description });
|
|
233
233
|
return {
|
|
234
234
|
content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }],
|
|
235
235
|
};
|
|
236
236
|
}
|
|
237
237
|
catch (error) {
|
|
238
238
|
return {
|
|
239
|
-
content: [{ type: "text", text: (0, _register_js_1.formatError)(error, `updating service account '${
|
|
239
|
+
content: [{ type: "text", text: (0, _register_js_1.formatError)(error, `updating service account '${encodeURIComponent(clientId)}' description`) }],
|
|
240
240
|
isError: true,
|
|
241
241
|
};
|
|
242
242
|
}
|
|
243
243
|
}));
|
|
244
|
-
(0, _register_js_1.registerTool)(server, "delete_service_account", "Permanently delete a service account
|
|
245
|
-
clientId: zod_1.z.string().describe("The service account's clientId string (e.g., '
|
|
244
|
+
(0, _register_js_1.registerTool)(server, "delete_service_account", "Permanently delete a service account by clientId, including an already-revoked account. This cannot be undone.", {
|
|
245
|
+
clientId: zod_1.z.string().describe("The service account's clientId string (e.g., 'sa_abc123') — NOT the numeric ID"),
|
|
246
246
|
}, (_a) => __awaiter(this, [_a], void 0, function* ({ clientId }) {
|
|
247
247
|
try {
|
|
248
|
-
yield getSaClient().delete(`/${clientId}`);
|
|
248
|
+
yield getSaClient().delete(`/${encodeURIComponent(clientId)}`);
|
|
249
249
|
return {
|
|
250
|
-
content: [{ type: "text", text: `Service account '${clientId}' deleted successfully.` }],
|
|
250
|
+
content: [{ type: "text", text: `Service account '${encodeURIComponent(clientId)}' deleted successfully.` }],
|
|
251
251
|
};
|
|
252
252
|
}
|
|
253
253
|
catch (error) {
|
|
254
254
|
return {
|
|
255
|
-
content: [{ type: "text", text: (0, _register_js_1.formatError)(error, `deleting service account '${clientId}'`) }],
|
|
255
|
+
content: [{ type: "text", text: (0, _register_js_1.formatError)(error, `deleting service account '${encodeURIComponent(clientId)}'`) }],
|
|
256
256
|
isError: true,
|
|
257
257
|
};
|
|
258
258
|
}
|
|
259
259
|
}));
|
|
260
260
|
// ── Secret Rotation & Revocation ─────────────────────────────────
|
|
261
261
|
(0, _register_js_1.registerTool)(server, "rotate_service_account_secret", "Rotate the client secret of a service account. The old secret is immediately invalidated. Returns the new clientSecret — store it securely, it's only shown once.", {
|
|
262
|
-
|
|
263
|
-
}, (_a) => __awaiter(this, [_a], void 0, function* ({
|
|
262
|
+
clientId: zod_1.z.string().describe("The service account clientId (not its numeric database id)"),
|
|
263
|
+
}, (_a) => __awaiter(this, [_a], void 0, function* ({ clientId }) {
|
|
264
264
|
try {
|
|
265
|
-
const result = yield getSaClient().post(`/${
|
|
265
|
+
const result = yield getSaClient().post(`/${encodeURIComponent(clientId)}/rotate`);
|
|
266
266
|
return {
|
|
267
267
|
content: [{
|
|
268
268
|
type: "text",
|
|
@@ -272,34 +272,34 @@ function registerServiceAccountTools(server, sdk, centraliUrl, workspaceId, curr
|
|
|
272
272
|
}
|
|
273
273
|
catch (error) {
|
|
274
274
|
return {
|
|
275
|
-
content: [{ type: "text", text: (0, _register_js_1.formatError)(error, `rotating secret for service account '${
|
|
275
|
+
content: [{ type: "text", text: (0, _register_js_1.formatError)(error, `rotating secret for service account '${encodeURIComponent(clientId)}'`) }],
|
|
276
276
|
isError: true,
|
|
277
277
|
};
|
|
278
278
|
}
|
|
279
279
|
}));
|
|
280
280
|
(0, _register_js_1.registerTool)(server, "revoke_service_account", "Revoke a service account. All existing tokens are invalidated and no new tokens can be issued. This cannot be undone.", {
|
|
281
|
-
|
|
282
|
-
}, (_a) => __awaiter(this, [_a], void 0, function* ({
|
|
281
|
+
clientId: zod_1.z.string().describe("The service account clientId to revoke"),
|
|
282
|
+
}, (_a) => __awaiter(this, [_a], void 0, function* ({ clientId }) {
|
|
283
283
|
try {
|
|
284
|
-
const result = yield getSaClient().post(`/${
|
|
284
|
+
const result = yield getSaClient().post(`/${encodeURIComponent(clientId)}/revoke`);
|
|
285
285
|
return {
|
|
286
286
|
content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }],
|
|
287
287
|
};
|
|
288
288
|
}
|
|
289
289
|
catch (error) {
|
|
290
290
|
return {
|
|
291
|
-
content: [{ type: "text", text: (0, _register_js_1.formatError)(error, `revoking service account '${
|
|
291
|
+
content: [{ type: "text", text: (0, _register_js_1.formatError)(error, `revoking service account '${encodeURIComponent(clientId)}'`) }],
|
|
292
292
|
isError: true,
|
|
293
293
|
};
|
|
294
294
|
}
|
|
295
295
|
}));
|
|
296
296
|
// ── Dev Token Generation ─────────────────────────────────────────
|
|
297
297
|
(0, _register_js_1.registerTool)(server, "generate_dev_token", "Generate a short-lived development token for a service account. Useful for testing and local development without the full OAuth2 client_credentials flow. The token has limited TTL.", {
|
|
298
|
-
|
|
298
|
+
clientId: zod_1.z.string().describe("The service account clientId (not its numeric database id)"),
|
|
299
299
|
ttlSeconds: zod_1.z.number().describe("Token time-to-live in seconds (valid options depend on server config, typically 3600, 86400, 604800)"),
|
|
300
|
-
}, (_a) => __awaiter(this, [_a], void 0, function* ({
|
|
300
|
+
}, (_a) => __awaiter(this, [_a], void 0, function* ({ clientId, ttlSeconds }) {
|
|
301
301
|
try {
|
|
302
|
-
const result = yield getSaClient().post(`/${
|
|
302
|
+
const result = yield getSaClient().post(`/${encodeURIComponent(clientId)}/dev-token`, { ttlSeconds });
|
|
303
303
|
return {
|
|
304
304
|
content: [{
|
|
305
305
|
type: "text",
|
|
@@ -309,43 +309,43 @@ function registerServiceAccountTools(server, sdk, centraliUrl, workspaceId, curr
|
|
|
309
309
|
}
|
|
310
310
|
catch (error) {
|
|
311
311
|
return {
|
|
312
|
-
content: [{ type: "text", text: (0, _register_js_1.formatError)(error, `generating dev token for service account '${
|
|
312
|
+
content: [{ type: "text", text: (0, _register_js_1.formatError)(error, `generating dev token for service account '${encodeURIComponent(clientId)}'`) }],
|
|
313
313
|
isError: true,
|
|
314
314
|
};
|
|
315
315
|
}
|
|
316
316
|
}));
|
|
317
317
|
// ── Permission Introspection ─────────────────────────────────────
|
|
318
318
|
(0, _register_js_1.registerTool)(server, "scan_service_account_permissions", "Scan all permissions for a service account. Returns a full access matrix showing every resource and action with Allow/Deny decisions and reasons. Use this to audit what a service account can and cannot do.", {
|
|
319
|
-
|
|
319
|
+
clientId: zod_1.z.string().describe("The service account clientId (not its numeric database id)"),
|
|
320
320
|
filter: zod_1.z.enum(["all", "allowed", "denied"]).optional().describe("Filter results: 'all' (default), 'allowed' (only granted), 'denied' (only missing)"),
|
|
321
321
|
resourceCategory: zod_1.z.string().optional().describe("Filter by resource category (e.g., 'workspace')"),
|
|
322
|
-
}, (_a) => __awaiter(this, [_a], void 0, function* ({
|
|
322
|
+
}, (_a) => __awaiter(this, [_a], void 0, function* ({ clientId, filter, resourceCategory }) {
|
|
323
323
|
try {
|
|
324
324
|
const params = {};
|
|
325
325
|
if (filter)
|
|
326
326
|
params.filter = filter;
|
|
327
327
|
if (resourceCategory)
|
|
328
328
|
params.resourceCategory = resourceCategory;
|
|
329
|
-
const result = yield getSaClient().get(`/${
|
|
329
|
+
const result = yield getSaClient().get(`/${encodeURIComponent(clientId)}/permissions/scan`, { params });
|
|
330
330
|
return {
|
|
331
331
|
content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }],
|
|
332
332
|
};
|
|
333
333
|
}
|
|
334
334
|
catch (error) {
|
|
335
335
|
return {
|
|
336
|
-
content: [{ type: "text", text: (0, _register_js_1.formatError)(error, `scanning permissions for service account '${
|
|
336
|
+
content: [{ type: "text", text: (0, _register_js_1.formatError)(error, `scanning permissions for service account '${encodeURIComponent(clientId)}'`) }],
|
|
337
337
|
isError: true,
|
|
338
338
|
};
|
|
339
339
|
}
|
|
340
340
|
}));
|
|
341
341
|
(0, _register_js_1.registerTool)(server, "simulate_service_account_permission", "Simulate an authorization check for a service account against a specific resource and action. Returns the decision (Allow/Deny), evaluation trace, and suggestions for granting access if denied.", {
|
|
342
|
-
|
|
342
|
+
clientId: zod_1.z.string().describe("The service account clientId (not its numeric database id)"),
|
|
343
343
|
resource: zod_1.z.string().describe("Resource identifier (e.g., 'workspace::records', 'workspace::compute-functions')"),
|
|
344
344
|
resourceCategory: zod_1.z.string().describe("Resource category (e.g., 'workspace')"),
|
|
345
345
|
action: zod_1.z.string().describe("Action to check (e.g., 'create', 'retrieve', 'update', 'delete', 'list', 'execute', 'manage')"),
|
|
346
|
-
}, (_a) => __awaiter(this, [_a], void 0, function* ({
|
|
346
|
+
}, (_a) => __awaiter(this, [_a], void 0, function* ({ clientId, resource, resourceCategory, action }) {
|
|
347
347
|
try {
|
|
348
|
-
const result = yield getSaClient().post(`/${
|
|
348
|
+
const result = yield getSaClient().post(`/${encodeURIComponent(clientId)}/permissions/simulate`, {
|
|
349
349
|
resource,
|
|
350
350
|
resourceCategory,
|
|
351
351
|
action,
|
|
@@ -356,7 +356,7 @@ function registerServiceAccountTools(server, sdk, centraliUrl, workspaceId, curr
|
|
|
356
356
|
}
|
|
357
357
|
catch (error) {
|
|
358
358
|
return {
|
|
359
|
-
content: [{ type: "text", text: (0, _register_js_1.formatError)(error, `simulating permission for service account '${
|
|
359
|
+
content: [{ type: "text", text: (0, _register_js_1.formatError)(error, `simulating permission for service account '${encodeURIComponent(clientId)}'`) }],
|
|
360
360
|
isError: true,
|
|
361
361
|
};
|
|
362
362
|
}
|
|
@@ -465,102 +465,102 @@ function registerServiceAccountTools(server, sdk, centraliUrl, workspaceId, curr
|
|
|
465
465
|
}));
|
|
466
466
|
// ── Service Account ↔ Roles ──────────────────────────────────────
|
|
467
467
|
(0, _register_js_1.registerTool)(server, "list_service_account_roles", "List all roles assigned to a service account.", {
|
|
468
|
-
|
|
469
|
-
}, (_a) => __awaiter(this, [_a], void 0, function* ({
|
|
468
|
+
clientId: zod_1.z.string().describe("The service account clientId (not its numeric database id)"),
|
|
469
|
+
}, (_a) => __awaiter(this, [_a], void 0, function* ({ clientId }) {
|
|
470
470
|
try {
|
|
471
|
-
const result = yield getSaClient().get(`/${
|
|
471
|
+
const result = yield getSaClient().get(`/${encodeURIComponent(clientId)}/roles`);
|
|
472
472
|
return {
|
|
473
473
|
content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }],
|
|
474
474
|
};
|
|
475
475
|
}
|
|
476
476
|
catch (error) {
|
|
477
477
|
return {
|
|
478
|
-
content: [{ type: "text", text: (0, _register_js_1.formatError)(error, `listing roles for service account '${
|
|
478
|
+
content: [{ type: "text", text: (0, _register_js_1.formatError)(error, `listing roles for service account '${encodeURIComponent(clientId)}'`) }],
|
|
479
479
|
isError: true,
|
|
480
480
|
};
|
|
481
481
|
}
|
|
482
482
|
}));
|
|
483
483
|
(0, _register_js_1.registerTool)(server, "assign_role_to_service_account", "Assign a role to a service account. The service account inherits all permissions defined in the role.", {
|
|
484
|
-
|
|
484
|
+
clientId: zod_1.z.string().describe("The service account clientId (not its numeric database id)"),
|
|
485
485
|
roleId: zod_1.z.string().describe("The role ID (UUID) to assign"),
|
|
486
|
-
}, (_a) => __awaiter(this, [_a], void 0, function* ({
|
|
486
|
+
}, (_a) => __awaiter(this, [_a], void 0, function* ({ clientId, roleId }) {
|
|
487
487
|
try {
|
|
488
|
-
const result = yield getSaClient().post(`/${
|
|
488
|
+
const result = yield getSaClient().post(`/${encodeURIComponent(clientId)}/roles/${roleId}`);
|
|
489
489
|
return {
|
|
490
490
|
content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }],
|
|
491
491
|
};
|
|
492
492
|
}
|
|
493
493
|
catch (error) {
|
|
494
494
|
return {
|
|
495
|
-
content: [{ type: "text", text: (0, _register_js_1.formatError)(error, `assigning role '${roleId}' to service account '${
|
|
495
|
+
content: [{ type: "text", text: (0, _register_js_1.formatError)(error, `assigning role '${roleId}' to service account '${encodeURIComponent(clientId)}'`) }],
|
|
496
496
|
isError: true,
|
|
497
497
|
};
|
|
498
498
|
}
|
|
499
499
|
}));
|
|
500
500
|
(0, _register_js_1.registerTool)(server, "remove_role_from_service_account", "Remove a role from a service account. The service account loses all permissions from this role.", {
|
|
501
|
-
|
|
501
|
+
clientId: zod_1.z.string().describe("The service account clientId (not its numeric database id)"),
|
|
502
502
|
roleId: zod_1.z.string().describe("The role ID (UUID) to remove"),
|
|
503
|
-
}, (_a) => __awaiter(this, [_a], void 0, function* ({
|
|
503
|
+
}, (_a) => __awaiter(this, [_a], void 0, function* ({ clientId, roleId }) {
|
|
504
504
|
try {
|
|
505
|
-
yield getSaClient().delete(`/${
|
|
505
|
+
yield getSaClient().delete(`/${encodeURIComponent(clientId)}/roles/${roleId}`);
|
|
506
506
|
return {
|
|
507
|
-
content: [{ type: "text", text: `Role '${roleId}' removed from service account '${
|
|
507
|
+
content: [{ type: "text", text: `Role '${roleId}' removed from service account '${encodeURIComponent(clientId)}'.` }],
|
|
508
508
|
};
|
|
509
509
|
}
|
|
510
510
|
catch (error) {
|
|
511
511
|
return {
|
|
512
|
-
content: [{ type: "text", text: (0, _register_js_1.formatError)(error, `removing role '${roleId}' from service account '${
|
|
512
|
+
content: [{ type: "text", text: (0, _register_js_1.formatError)(error, `removing role '${roleId}' from service account '${encodeURIComponent(clientId)}'`) }],
|
|
513
513
|
isError: true,
|
|
514
514
|
};
|
|
515
515
|
}
|
|
516
516
|
}));
|
|
517
517
|
// ── Service Account ↔ Groups ─────────────────────────────────────
|
|
518
518
|
(0, _register_js_1.registerTool)(server, "list_service_account_groups", "List all groups a service account belongs to.", {
|
|
519
|
-
|
|
520
|
-
}, (_a) => __awaiter(this, [_a], void 0, function* ({
|
|
519
|
+
clientId: zod_1.z.string().describe("The service account clientId (not its numeric database id)"),
|
|
520
|
+
}, (_a) => __awaiter(this, [_a], void 0, function* ({ clientId }) {
|
|
521
521
|
try {
|
|
522
|
-
const result = yield getSaClient().get(`/${
|
|
522
|
+
const result = yield getSaClient().get(`/${encodeURIComponent(clientId)}/groups`);
|
|
523
523
|
return {
|
|
524
524
|
content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }],
|
|
525
525
|
};
|
|
526
526
|
}
|
|
527
527
|
catch (error) {
|
|
528
528
|
return {
|
|
529
|
-
content: [{ type: "text", text: (0, _register_js_1.formatError)(error, `listing groups for service account '${
|
|
529
|
+
content: [{ type: "text", text: (0, _register_js_1.formatError)(error, `listing groups for service account '${encodeURIComponent(clientId)}'`) }],
|
|
530
530
|
isError: true,
|
|
531
531
|
};
|
|
532
532
|
}
|
|
533
533
|
}));
|
|
534
534
|
(0, _register_js_1.registerTool)(server, "add_service_account_to_group", "Add a service account to a group. The service account inherits all roles assigned to the group.", {
|
|
535
|
-
|
|
535
|
+
clientId: zod_1.z.string().describe("The service account clientId (not its numeric database id)"),
|
|
536
536
|
groupId: zod_1.z.string().describe("The group ID (UUID) to add the service account to"),
|
|
537
|
-
}, (_a) => __awaiter(this, [_a], void 0, function* ({
|
|
537
|
+
}, (_a) => __awaiter(this, [_a], void 0, function* ({ clientId, groupId }) {
|
|
538
538
|
try {
|
|
539
|
-
const result = yield getSaClient().post(`/${
|
|
539
|
+
const result = yield getSaClient().post(`/${encodeURIComponent(clientId)}/groups/${groupId}`);
|
|
540
540
|
return {
|
|
541
541
|
content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }],
|
|
542
542
|
};
|
|
543
543
|
}
|
|
544
544
|
catch (error) {
|
|
545
545
|
return {
|
|
546
|
-
content: [{ type: "text", text: (0, _register_js_1.formatError)(error, `adding service account '${
|
|
546
|
+
content: [{ type: "text", text: (0, _register_js_1.formatError)(error, `adding service account '${encodeURIComponent(clientId)}' to group '${groupId}'`) }],
|
|
547
547
|
isError: true,
|
|
548
548
|
};
|
|
549
549
|
}
|
|
550
550
|
}));
|
|
551
551
|
(0, _register_js_1.registerTool)(server, "remove_service_account_from_group", "Remove a service account from a group. The service account loses all permissions inherited through this group.", {
|
|
552
|
-
|
|
552
|
+
clientId: zod_1.z.string().describe("The service account clientId (not its numeric database id)"),
|
|
553
553
|
groupId: zod_1.z.string().describe("The group ID (UUID) to remove the service account from"),
|
|
554
|
-
}, (_a) => __awaiter(this, [_a], void 0, function* ({
|
|
554
|
+
}, (_a) => __awaiter(this, [_a], void 0, function* ({ clientId, groupId }) {
|
|
555
555
|
try {
|
|
556
|
-
yield getSaClient().delete(`/${
|
|
556
|
+
yield getSaClient().delete(`/${encodeURIComponent(clientId)}/groups/${groupId}`);
|
|
557
557
|
return {
|
|
558
|
-
content: [{ type: "text", text: `Service account '${
|
|
558
|
+
content: [{ type: "text", text: `Service account '${encodeURIComponent(clientId)}' removed from group '${groupId}'.` }],
|
|
559
559
|
};
|
|
560
560
|
}
|
|
561
561
|
catch (error) {
|
|
562
562
|
return {
|
|
563
|
-
content: [{ type: "text", text: (0, _register_js_1.formatError)(error, `removing service account '${
|
|
563
|
+
content: [{ type: "text", text: (0, _register_js_1.formatError)(error, `removing service account '${encodeURIComponent(clientId)}' from group '${groupId}'`) }],
|
|
564
564
|
isError: true,
|
|
565
565
|
};
|
|
566
566
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@centrali-io/centrali-mcp",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.6.0",
|
|
4
4
|
"description": "Centrali MCP Server - AI assistant integration for Centrali workspaces",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"url": "git+https://github.com/blueinit/centrali-mcp.git"
|
|
13
13
|
},
|
|
14
14
|
"scripts": {
|
|
15
|
+
"pretest": "node -e \"const fs=require('node:fs');const cp=require('node:child_process');if(fs.existsSync('../centrali-sdk/tsup.config.ts'))cp.execFileSync('npm',['run','build'],{cwd:'../centrali-sdk',stdio:'inherit'});\"",
|
|
15
16
|
"build": "tsc --project tsconfig.json",
|
|
16
17
|
"test": "npm run build && node --test 'tests/**/*.test.cjs'",
|
|
17
18
|
"prepublishOnly": "npm run build"
|
|
@@ -25,7 +26,7 @@
|
|
|
25
26
|
"author": "Blueinit",
|
|
26
27
|
"license": "ISC",
|
|
27
28
|
"dependencies": {
|
|
28
|
-
"@centrali-io/centrali-sdk": "^9.
|
|
29
|
+
"@centrali-io/centrali-sdk": "^9.6.0",
|
|
29
30
|
"@modelcontextprotocol/sdk": "^1.28.0"
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
package/src/index.ts
CHANGED
|
@@ -16,6 +16,7 @@ import { registerAuthProviderTools } from "./tools/auth-providers.js";
|
|
|
16
16
|
import { registerServiceAccountTools } from "./tools/service-accounts.js";
|
|
17
17
|
import { registerWebhookSubscriptionTools } from "./tools/webhook-subscriptions.js";
|
|
18
18
|
import { registerEventTools } from "./tools/events.js";
|
|
19
|
+
import { registerFileTools } from "./tools/files.js";
|
|
19
20
|
import { registerStructureResources, registerCollectionResources } from "./resources/structures.js";
|
|
20
21
|
|
|
21
22
|
function getRequiredEnv(name: string): string {
|
|
@@ -82,6 +83,7 @@ async function main() {
|
|
|
82
83
|
registerWebhookSubscriptionTools(server, sdk);
|
|
83
84
|
registerEventTools(server, sdk, baseUrl, workspaceId);
|
|
84
85
|
registerDescribeTools(server);
|
|
86
|
+
registerFileTools(server, sdk);
|
|
85
87
|
|
|
86
88
|
// Register resources
|
|
87
89
|
registerCollectionResources(server, sdk);
|