@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.
@@ -65,7 +65,7 @@ function registerOrchestrationTools(server, sdk) {
65
65
  }
66
66
  }));
67
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)"),
68
+ orchestrationId: zod_1.z.string().describe("The orchestration ID (prefixed, e.g. orch_abc123)"),
69
69
  }, (_a) => __awaiter(this, [_a], void 0, function* ({ orchestrationId }) {
70
70
  try {
71
71
  const result = yield sdk.orchestrations.get(orchestrationId);
@@ -86,7 +86,7 @@ function registerOrchestrationTools(server, sdk) {
86
86
  }
87
87
  }));
88
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"),
89
+ orchestrationId: zod_1.z.string().describe("The orchestration ID (prefixed, e.g. orch_abc123) to trigger"),
90
90
  input: zod_1.z
91
91
  .record(zod_1.z.string(), zod_1.z.any())
92
92
  .optional()
@@ -120,7 +120,7 @@ function registerOrchestrationTools(server, sdk) {
120
120
  }
121
121
  }));
122
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)"),
123
+ orchestrationId: zod_1.z.string().describe("The orchestration ID (prefixed, e.g. orch_abc123)"),
124
124
  offset: zod_1.z.number().optional().describe("Number of results to skip (for pagination)"),
125
125
  limit: zod_1.z.number().optional().describe("Results per page"),
126
126
  status: zod_1.z
@@ -154,8 +154,8 @@ function registerOrchestrationTools(server, sdk) {
154
154
  }
155
155
  }));
156
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)"),
157
+ orchestrationId: zod_1.z.string().describe("The orchestration ID (prefixed, e.g. orch_abc123)"),
158
+ runId: zod_1.z.string().describe("The run ID (prefixed, e.g. orun_abc123)"),
159
159
  includeSteps: zod_1.z
160
160
  .boolean()
161
161
  .optional()
@@ -212,7 +212,7 @@ function registerOrchestrationTools(server, sdk) {
212
212
  }
213
213
  }));
214
214
  server.tool("update_orchestration", "Update an existing orchestration by ID. Only include the fields you want to change.", {
215
- orchestrationId: zod_1.z.string().describe("The orchestration ID (UUID) to update"),
215
+ orchestrationId: zod_1.z.string().describe("The orchestration ID (prefixed, e.g. orch_abc123) to update"),
216
216
  name: zod_1.z.string().optional().describe("Updated name"),
217
217
  description: zod_1.z.string().optional().describe("Updated description"),
218
218
  status: zod_1.z
@@ -258,7 +258,7 @@ function registerOrchestrationTools(server, sdk) {
258
258
  }
259
259
  }));
260
260
  server.tool("delete_orchestration", "Delete an orchestration by ID. This also deletes all runs associated with the orchestration.", {
261
- orchestrationId: zod_1.z.string().describe("The orchestration ID (UUID) to delete"),
261
+ orchestrationId: zod_1.z.string().describe("The orchestration ID (prefixed, e.g. orch_abc123) to delete"),
262
262
  }, (_a) => __awaiter(this, [_a], void 0, function* ({ orchestrationId }) {
263
263
  try {
264
264
  yield sdk.orchestrations.delete(orchestrationId);
@@ -284,7 +284,7 @@ function registerOrchestrationTools(server, sdk) {
284
284
  }
285
285
  }));
286
286
  server.tool("activate_orchestration", "Activate an orchestration. Active orchestrations can be triggered by scheduled events, record events, and webhooks.", {
287
- orchestrationId: zod_1.z.string().describe("The orchestration ID (UUID) to activate"),
287
+ orchestrationId: zod_1.z.string().describe("The orchestration ID (prefixed, e.g. orch_abc123) to activate"),
288
288
  }, (_a) => __awaiter(this, [_a], void 0, function* ({ orchestrationId }) {
289
289
  try {
290
290
  const result = yield sdk.orchestrations.activate(orchestrationId);
@@ -305,7 +305,7 @@ function registerOrchestrationTools(server, sdk) {
305
305
  }
306
306
  }));
307
307
  server.tool("pause_orchestration", "Pause an orchestration. Paused orchestrations cannot be triggered by any mechanism.", {
308
- orchestrationId: zod_1.z.string().describe("The orchestration ID (UUID) to pause"),
308
+ orchestrationId: zod_1.z.string().describe("The orchestration ID (prefixed, e.g. orch_abc123) to pause"),
309
309
  }, (_a) => __awaiter(this, [_a], void 0, function* ({ orchestrationId }) {
310
310
  try {
311
311
  const result = yield sdk.orchestrations.pause(orchestrationId);
@@ -53,16 +53,37 @@ function getPagesBaseUrl(centraliUrl) {
53
53
  : `api.${url.hostname}`;
54
54
  return `${url.protocol}//${hostname}/pages`;
55
55
  }
56
+ /**
57
+ * Ensures the SDK has a valid token by making a lightweight SDK call.
58
+ * The SDK's internal axios interceptor handles client-credentials token
59
+ * fetch and 401 refresh automatically — we just need to trigger it.
60
+ */
61
+ function ensureToken(sdk) {
62
+ return __awaiter(this, void 0, void 0, function* () {
63
+ let token = sdk.getToken();
64
+ if (token)
65
+ return token;
66
+ // Token not yet fetched — trigger the SDK's internal auth flow
67
+ // by making a lightweight call. The SDK will fetch and cache the token.
68
+ try {
69
+ yield sdk.functions.list({ limit: 1 });
70
+ }
71
+ catch (_a) {
72
+ // Ignore errors — we only need the token refresh side effect
73
+ }
74
+ return sdk.getToken();
75
+ });
76
+ }
56
77
  /**
57
78
  * Creates an axios instance for the pages API that uses the SDK's token.
79
+ * Auth is handled through the SDK's public getToken() API — no internal casting.
58
80
  */
59
81
  function createPagesClient(sdk, centraliUrl, workspaceId) {
60
82
  const baseURL = getPagesBaseUrl(centraliUrl);
61
83
  const client = axios_1.default.create({ baseURL });
62
84
  // Attach the SDK's bearer token to every request
63
85
  client.interceptors.request.use((config) => __awaiter(this, void 0, void 0, function* () {
64
- var _a, _b, _c;
65
- const token = (_c = (_b = (_a = sdk).getToken) === null || _b === void 0 ? void 0 : _b.call(_a)) !== null && _c !== void 0 ? _c : sdk.token;
86
+ const token = yield ensureToken(sdk);
66
87
  if (token) {
67
88
  config.headers.Authorization = `Bearer ${token}`;
68
89
  }
@@ -70,21 +91,19 @@ function createPagesClient(sdk, centraliUrl, workspaceId) {
70
91
  }));
71
92
  // Retry on 401/403 after refreshing the token via the SDK
72
93
  client.interceptors.response.use((response) => response, (error) => __awaiter(this, void 0, void 0, function* () {
73
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
94
+ var _a, _b;
74
95
  const originalRequest = error.config;
75
96
  const isAuthError = ((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 401 || ((_b = error.response) === null || _b === void 0 ? void 0 : _b.status) === 403;
76
97
  if (isAuthError && !originalRequest._hasRetried) {
77
98
  originalRequest._hasRetried = true;
78
- // Force SDK to fetch a fresh token
79
- const freshToken = yield ((_d = (_c = sdk).getTokenOrFetch) === null || _d === void 0 ? void 0 : _d.call(_c));
80
- if (!freshToken) {
81
- // SDK can't get a token either — trigger a re-auth by making any SDK call
82
- try {
83
- yield ((_f = (_e = sdk.axios) === null || _e === void 0 ? void 0 : _e.get) === null || _f === void 0 ? void 0 : _f.call(_e, '/health'));
84
- }
85
- catch ( /* ignore — we just want the token refresh side effect */_k) { /* ignore — we just want the token refresh side effect */ }
99
+ // Force a fresh token by making an SDK call (triggers internal 401 refresh)
100
+ try {
101
+ yield sdk.functions.list({ limit: 1 });
102
+ }
103
+ catch (_c) {
104
+ // Ignore we only need the token refresh side effect
86
105
  }
87
- const token = (_j = (_h = (_g = sdk).getToken) === null || _h === void 0 ? void 0 : _h.call(_g)) !== null && _j !== void 0 ? _j : sdk.token;
106
+ const token = sdk.getToken();
88
107
  if (token) {
89
108
  originalRequest.headers.Authorization = `Bearer ${token}`;
90
109
  return client.request(originalRequest);
@@ -0,0 +1,3 @@
1
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import { CentraliSDK } from "@centrali-io/centrali-sdk";
3
+ export declare function registerServiceAccountTools(server: McpServer, sdk: CentraliSDK, centraliUrl: string, workspaceId: string, ownClientId?: string): void;