iit-mcp-autotask 0.63.16 → 0.63.17

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 CHANGED
@@ -799,8 +799,11 @@ guards (rate limiter, 429 cooldown) — a worse security posture, not a safer on
799
799
  quote live tenant metadata (field names, picklist labels), so it is served as untrusted content:
800
800
  embedded wrapper tags dropped, cleaned, secret-scrubbed, capped and wrapped in
801
801
  `<untrusted_content>`; `reasons[].detail` is its first 500 characters, unwrapped. Every other
802
- error message keeps the 200-character bound. An all-digit credential value (the impersonation id)
803
- is scrubbed only on digit boundaries, so it does not match inside a longer number.
802
+ error message keeps the 200-character bound. Every error path strips unsafe characters before it
803
+ scrubs, so a credential value split by an invisible character (U+200B) is still caught (#464). Any
804
+ all-digit credential value (usually the impersonation id) is scrubbed only on digit boundaries, so
805
+ it does not match inside a longer number; standing alone it still replaces the whole message, so a
806
+ short id equal to a listed picklist id (a selector refusal's `29 Label`) redacts that refusal.
804
807
  - **Host allow-list is fail-closed at boot** (see [Per-request credential model](#per-request-credential-model)).
805
808
  - **Sensitive-data-safe structured JSON logging:** NDJSON; stdio → stderr only (stdout is the
806
809
  protocol), http → stdout. Operation keys, status, latency and byte sizes are loggable; credential
package/dist/http.js CHANGED
@@ -24,7 +24,7 @@ import { runDoctor } from './doctor.js';
24
24
  import { SERVER_IDENTITY } from './tools/server.js';
25
25
  import { describeSurface } from './tools/surface.js';
26
26
  import { readRequestScope } from './auth.js';
27
- import { scrubSecrets } from './tools/results/errors.js';
27
+ import { stripThenScrub } from './tools/results/errors.js';
28
28
  import { createMcpGuard, MAX_BODY_BYTES } from './http-guard.js';
29
29
  import { AUTOTASK_BASE_URL_HEADER, AUTOTASK_IMPERSONATION_HEADER, AUTOTASK_INTEGRATION_CODE_HEADER, AUTOTASK_SECRET_HEADER, AUTOTASK_USERNAME_HEADER, } from './auth.js';
30
30
  /** The headers that carry per-request scope, and so must never be read from a duplicated pair. */
@@ -270,7 +270,7 @@ export function startHttpServer(config, mcp, log, tokens, exit = process.exit, e
270
270
  if (typeof v === 'string' && v.length > 0)
271
271
  secrets.push(v);
272
272
  }
273
- log.error('request failed', { err: scrubSecrets(err instanceof Error ? err.message : String(err), secrets) });
273
+ log.error('request failed', { err: stripThenScrub(err instanceof Error ? err.message : String(err), secrets) });
274
274
  if (!res.headersSent) {
275
275
  res.statusCode = 500;
276
276
  res.end('internal error');
@@ -108,7 +108,7 @@ export declare function sdkCacheOptions(cache: 'on' | 'off'): Pick<AutotaskConfi
108
108
  * fails the boot (or the CI test) instead of quietly shipping a tool surface that no longer
109
109
  * describes the SDK behind it.
110
110
  */
111
- export declare const BUILT_AGAINST_PLAN_HASH = "929593354ffa904a038cb7cbbf7b91ffbb05e9f06078181e9f225505f3463a88";
111
+ export declare const BUILT_AGAINST_PLAN_HASH = "c97deac4ac7c3ca9ce4cea10ac6a50bb19b6517993d9657c52397964e1fcf715";
112
112
  /**
113
113
  * Fail fast when the installed SDK's plan has moved out from under this surface.
114
114
  * Called at boot (main.ts) and safe to call repeatedly (pure comparison).
@@ -190,7 +190,7 @@ export function sdkCacheOptions(cache) {
190
190
  * fails the boot (or the CI test) instead of quietly shipping a tool surface that no longer
191
191
  * describes the SDK behind it.
192
192
  */
193
- export const BUILT_AGAINST_PLAN_HASH = '929593354ffa904a038cb7cbbf7b91ffbb05e9f06078181e9f225505f3463a88';
193
+ export const BUILT_AGAINST_PLAN_HASH = 'c97deac4ac7c3ca9ce4cea10ac6a50bb19b6517993d9657c52397964e1fcf715';
194
194
  /**
195
195
  * Fail fast when the installed SDK's plan has moved out from under this surface.
196
196
  * Called at boot (main.ts) and safe to call repeatedly (pure comparison).
@@ -72,6 +72,12 @@ export declare function sdkValidationMessage(raw: string, secrets: readonly stri
72
72
  * (security R2).
73
73
  */
74
74
  export declare function scrubSecrets(value: string, secrets: readonly string[]): string;
75
+ /**
76
+ * {@link scrubSecrets} after the unsafe characters are stripped (#464): the choke point strips them later
77
+ * anyway, and a value split by an invisible format character (U+200B) would pass a scrub of the raw text
78
+ * and be rejoined by that strip. Every error path that scrubs vendor or SDK text uses this order.
79
+ */
80
+ export declare function stripThenScrub(value: string, secrets: readonly string[]): string;
75
81
  /**
76
82
  * Bound + scrub the vendor body the SDK carries under `vendorError` (V23/FT-5): the served
77
83
  * envelope is typed-only — never the raw body, never a request's own credential value.
@@ -5,7 +5,7 @@ import { unknownKeysRefusal } from 'node-autotask/operations';
5
5
  import { errorEnvelope, TRUNCATION_MARKER } from './envelope.js';
6
6
  import { classifyError } from '../reasons.js';
7
7
  import { UNTRUSTED_CLOSE, UNTRUSTED_OPEN } from 'node-autotask/untrusted';
8
- import { cleanUntrustedText, EVERY_ITEM, LONG_TEXT_CAP, note, wrapOrSelf } from './untrusted.js';
8
+ import { cleanUntrustedText, EVERY_ITEM, LONG_TEXT_CAP, note, stripUnsafeChars, wrapOrSelf } from './untrusted.js';
9
9
  /** Hard cap on the model-facing error text; see {@link boundErrorMessage}. */
10
10
  export const MAX_ERROR_MESSAGE_CHARS = 200;
11
11
  /**
@@ -116,10 +116,30 @@ export function sdkValidationMessage(raw, secrets) {
116
116
  */
117
117
  export function scrubSecrets(value, secrets) {
118
118
  for (const s of secrets)
119
- if (s.length > 0 && carriesSecret(value, s))
120
- return SECRET_MARKER;
119
+ for (const form of secretForms(s))
120
+ if (carriesSecret(value, form))
121
+ return SECRET_MARKER;
121
122
  return value;
122
123
  }
124
+ /**
125
+ * The forms of one credential value a scrub matches: the raw value and, when it differs, the value with
126
+ * the unsafe characters stripped. The credential shape check accepts values that carry such characters
127
+ * (U+00AD, U+200B, U+FE0F, ...), and every error path scrubs text after the strip (#464), so the stripped
128
+ * form is the one an echo takes there. An empty form never matches.
129
+ */
130
+ function secretForms(secret) {
131
+ const stripped = stripUnsafeChars(secret);
132
+ return [secret, ...(stripped !== secret ? [stripped] : [])].filter((f) => f.length > 0);
133
+ }
134
+ /**
135
+ * {@link scrubSecrets} after the unsafe characters are stripped (#464): the choke point strips them later
136
+ * anyway, and a value split by an invisible format character (U+200B) would pass a scrub of the raw text
137
+ * and be rejoined by that strip. Every error path that scrubs vendor or SDK text uses this order.
138
+ */
139
+ export function stripThenScrub(value, secrets) {
140
+ // scrubSecrets matches each secret raw and stripped, so a secret that itself carries an unsafe character is caught too.
141
+ return scrubSecrets(stripUnsafeChars(value), secrets);
142
+ }
123
143
  /**
124
144
  * Whether `value` carries the credential value `secret`. An all-digit value (the impersonation resource
125
145
  * id, often two or three digits) matches only on digit boundaries: inside a longer number (`29` in
@@ -156,11 +176,11 @@ export function boundVendorError(vendorError, secrets) {
156
176
  if (depth > 6)
157
177
  return '[DEPTH]';
158
178
  if (typeof v === 'string') {
159
- const scrubbed = scrubSecrets(v, secrets);
160
- if (scrubbed !== v)
161
- return SECRET_MARKER;
162
- // R5: vendor error text is cleaned like any other vendor text (strip; the per-string cap is the line below)
179
+ // R5: vendor error text is cleaned like any other vendor text (strip; the per-string cap is below),
180
+ // and scrubbed after the strip (#464), so a value split by an invisible character is caught whole.
163
181
  const clean = cleanUntrustedText(v, false);
182
+ if (scrubSecrets(clean, secrets) !== clean)
183
+ return SECRET_MARKER;
164
184
  return clean.length > VENDOR_FIELD_MAX ? `[TRUNCATED ${v.length}]` : clean;
165
185
  }
166
186
  // Each string here is already cleaned, so it is recorded `server`: the choke point keeps a
@@ -247,14 +267,14 @@ export function vendorShapeDiagnostic(err, secrets) {
247
267
  if (details !== null && typeof details === 'object') {
248
268
  const diagnostic = details.diagnostic;
249
269
  if (typeof diagnostic === 'string' && diagnostic.length > 0) {
250
- const scrubbed = scrubSecrets(diagnostic, secrets);
270
+ const scrubbed = stripThenScrub(diagnostic, secrets);
251
271
  // The scrub already replaced an echoed value: the statement is unreadable, so it is ABSENT.
252
- const clean = scrubbed !== diagnostic || isAnomalyFreeDiagnostic(scrubbed);
272
+ const clean = scrubbed === SECRET_MARKER || isAnomalyFreeDiagnostic(scrubbed);
253
273
  return clean ? undefined : scrubbed;
254
274
  }
255
275
  const problem = details.problem;
256
276
  if (typeof problem === 'string' && problem.length > 0) {
257
- return scrubSecrets(`sent value shows shell-quoting/line-break artifacts (${problem}) — check your env load`, secrets);
277
+ return stripThenScrub(`sent value shows shell-quoting/line-break artifacts (${problem}) — check your env load`, secrets);
258
278
  }
259
279
  }
260
280
  for (const value of secrets) {
@@ -369,7 +389,7 @@ export function typedErrorPayload(err, correlationId, secrets = []) {
369
389
  else {
370
390
  payload.message = sdkValidation
371
391
  ? sdkValidationMessage(err.message, secrets)
372
- : scrubSecrets(rollupBudget ? err.message : boundErrorMessage(err instanceof Error ? err.message : String(err), url), secrets);
392
+ : boundedMessage(err instanceof Error ? err.message : String(err), rollupBudget, url, secrets);
373
393
  }
374
394
  // Untrusted content with the longer cap: recorded `long` so the choke point keeps up to 3,000
375
395
  // characters and the wrapper. `reasons[].detail` is built from this message (unwrapped) by
@@ -379,7 +399,7 @@ export function typedErrorPayload(err, correlationId, secrets = []) {
379
399
  note(payload, 'message', 'long');
380
400
  const suggestedAction = str(e.suggestedAction);
381
401
  if (!shapeOnlyVendorError && suggestedAction !== undefined)
382
- payload.suggestedAction = scrubSecrets(suggestedAction, secrets);
402
+ payload.suggestedAction = stripThenScrub(suggestedAction, secrets);
383
403
  // SDK-built budget guidance contains no vendor text; preserve its complete narrowing options.
384
404
  if (rollupBudget)
385
405
  for (const key of ['message', 'suggestedAction'])
@@ -411,6 +431,20 @@ export function typedErrorPayload(err, correlationId, secrets = []) {
411
431
  payload.correlationId = str(e.correlationId) ?? correlationId;
412
432
  return payload;
413
433
  }
434
+ /**
435
+ * The served message of a client-side error that is not SDK validation text (#464): unsafe characters
436
+ * stripped, then the request's credential values scrubbed on the whole text, then bounded at
437
+ * {@link MAX_ERROR_MESSAGE_CHARS} (last, so a cut can never leave half of a value the scrub would have
438
+ * matched whole). The rollup budget guidance keeps its complete text.
439
+ */
440
+ function boundedMessage(raw, keepWhole, url, secrets) {
441
+ const clean = stripUnsafeChars(raw);
442
+ // Over the cap with a dialed host, the message is the host shape: none of the raw text crosses.
443
+ if (!keepWhole && clean.length > MAX_ERROR_MESSAGE_CHARS && hostFromUrl(url) !== undefined)
444
+ return boundErrorMessage(clean, url);
445
+ const scrubbed = scrubSecrets(clean, secrets);
446
+ return keepWhole || scrubbed === SECRET_MARKER ? scrubbed : boundErrorMessage(scrubbed, url);
447
+ }
414
448
  /** The tool-level error envelope: the typed payload as the text block (the batch's per-item
415
449
  * slot — issue #15 — rides the SAME payload object, so a slot error is exactly what the single
416
450
  * read would have served). */
@@ -390,7 +390,8 @@ async function respond(a, r) {
390
390
  const { ctx, store, plan } = a;
391
391
  const { record, shape, entry, error, moveResult, callResult } = r;
392
392
  if (entry.state !== 'succeeded') {
393
- const data = error === undefined ? {} : { error: honestError(typedErrorPayload(error, ctx.correlationId, requestSecrets(ctx)), entry) };
393
+ const secrets = requestSecrets(ctx);
394
+ const data = error === undefined ? {} : { error: honestError(typedErrorPayload(error, ctx.correlationId, secrets), entry, secrets) };
394
395
  return outcomeAnswer(plan, entry, { replayed: false, data });
395
396
  }
396
397
  if (shape === 'move')
@@ -6,14 +6,19 @@ import { type LedgerEntry, type PlanRecord } from '../../write/store.js';
6
6
  * transient (`retryable: true`, "Retry with backoff"), but a 500 with an errors[] body is a
7
7
  * deterministic business-rule rejection, and an unknown outcome must never be re-sent. Only a
8
8
  * genuinely retryable failure keeps the SDK's hint.
9
+ *
10
+ * `secrets` (#413): the request's own credential values. The typed payload has already bounded and
11
+ * scrubbed these vendor messages; each is stripped and scrubbed again here (strip first, #464), so the
12
+ * advice never depends on how the payload was built.
9
13
  */
10
- export declare function honestError(payload: Record<string, unknown>, entry: LedgerEntry): Record<string, unknown>;
14
+ export declare function honestError(payload: Record<string, unknown>, entry: LedgerEntry, secrets: readonly string[]): Record<string, unknown>;
11
15
  /** The cap on the vendor refusal text a failed ledger line keeps. */
12
16
  export declare const VENDOR_MESSAGE_CAP = 300;
13
17
  /**
14
18
  * The vendor's first errors[] message, as a failed ledger line keeps it so a later investigation
15
- * or replay can say why the write was refused. Untrusted vendor text: request secrets scrubbed,
16
- * unsafe characters stripped, whitespace collapsed to one line, capped at {@link VENDOR_MESSAGE_CAP}.
19
+ * or replay can say why the write was refused. Untrusted vendor text: unsafe characters stripped, then
20
+ * request secrets scrubbed (#464: a value split by an invisible character is caught whole), whitespace
21
+ * collapsed to one line, capped at {@link VENDOR_MESSAGE_CAP}.
17
22
  */
18
23
  export declare function vendorRefusal(err: unknown, secrets: readonly string[]): string | undefined;
19
24
  /** The envelope of an update whose HTTP write succeeded but whose stored record lacks some sent fields (issue #103). */
@@ -1,7 +1,7 @@
1
1
  import { COOLDOWN_MINUTES } from '../../write/store.js';
2
2
  import { answer, applyToolFor, reason } from './common.js';
3
- import { isKnowledgeBaseRootOperation, scrubSecrets } from '../results/errors.js';
4
- import { cleanUntrustedText, stripUnsafeChars } from '../results/untrusted.js';
3
+ import { isKnowledgeBaseRootOperation, stripThenScrub } from '../results/errors.js';
4
+ import { cleanUntrustedText } from '../results/untrusted.js';
5
5
  // ---------------------------------------------------------------------------
6
6
  // autotask_apply: the execution
7
7
  // ---------------------------------------------------------------------------
@@ -10,15 +10,18 @@ import { cleanUntrustedText, stripUnsafeChars } from '../results/untrusted.js';
10
10
  * transient (`retryable: true`, "Retry with backoff"), but a 500 with an errors[] body is a
11
11
  * deterministic business-rule rejection, and an unknown outcome must never be re-sent. Only a
12
12
  * genuinely retryable failure keeps the SDK's hint.
13
+ *
14
+ * `secrets` (#413): the request's own credential values. The typed payload has already bounded and
15
+ * scrubbed these vendor messages; each is stripped and scrubbed again here (strip first, #464), so the
16
+ * advice never depends on how the payload was built.
13
17
  */
14
- export function honestError(payload, entry) {
18
+ export function honestError(payload, entry, secrets) {
15
19
  if (entry.outcome?.retryable === true)
16
20
  return { ...payload, nextAction: 'retry' };
17
21
  if (entry.state === 'unknown')
18
22
  return { ...payload, retryable: false, nextAction: 'stop', suggestedAction: 'The write may have landed: read the record to verify; do not re-send.' };
19
- // The typed payload has already bounded and scrubbed these vendor messages.
20
23
  const errors = payload.vendorError?.errors;
21
- const said = Array.isArray(errors) ? errors.filter((e) => typeof e === 'string').slice(0, 3).map((e) => e.slice(0, 200)) : [];
24
+ const said = Array.isArray(errors) ? errors.filter((e) => typeof e === 'string').slice(0, 3).map((e) => stripThenScrub(e, secrets).slice(0, 200)) : [];
22
25
  return { ...payload, retryable: false, nextAction: 'stop', suggestedAction: refusedAction(said.join('; ')) };
23
26
  }
24
27
  /** The nested error's advice for a definite refusal, naming the vendor's text when there is any. */
@@ -30,15 +33,16 @@ function refusedAction(said) {
30
33
  export const VENDOR_MESSAGE_CAP = 300;
31
34
  /**
32
35
  * The vendor's first errors[] message, as a failed ledger line keeps it so a later investigation
33
- * or replay can say why the write was refused. Untrusted vendor text: request secrets scrubbed,
34
- * unsafe characters stripped, whitespace collapsed to one line, capped at {@link VENDOR_MESSAGE_CAP}.
36
+ * or replay can say why the write was refused. Untrusted vendor text: unsafe characters stripped, then
37
+ * request secrets scrubbed (#464: a value split by an invisible character is caught whole), whitespace
38
+ * collapsed to one line, capped at {@link VENDOR_MESSAGE_CAP}.
35
39
  */
36
40
  export function vendorRefusal(err, secrets) {
37
41
  const errors = err?.vendorError?.errors;
38
42
  const first = Array.isArray(errors) ? errors.find((e) => typeof e === 'string' && e.trim() !== '') : undefined;
39
43
  if (first === undefined)
40
44
  return undefined;
41
- const text = stripUnsafeChars(scrubSecrets(first, secrets)).replace(/\s+/g, ' ').trim();
45
+ const text = stripThenScrub(first, secrets).replace(/\s+/g, ' ').trim();
42
46
  return text === '' ? undefined : cleanUntrustedText(text, true, VENDOR_MESSAGE_CAP);
43
47
  }
44
48
  /** The envelope of an update whose HTTP write succeeded but whose stored record lacks some sent fields (issue #103). */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iit-mcp-autotask",
3
- "version": "0.63.16",
3
+ "version": "0.63.17",
4
4
  "description": "MCP server for the Autotask (Datto) PSA domain, built on the node-autotask SDK",
5
5
  "license": "MIT",
6
6
  "author": "Max Soukhomlinov",
@@ -54,7 +54,7 @@
54
54
  },
55
55
  "dependencies": {
56
56
  "@modelcontextprotocol/server": "^2.2.0",
57
- "node-autotask": "0.86.0",
57
+ "node-autotask": "0.87.0",
58
58
  "zod": "^4.6.7"
59
59
  },
60
60
  "devDependencies": {
package/server.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iit-mcp-autotask",
3
- "version": "0.63.16",
3
+ "version": "0.63.17",
4
4
  "description": "MCP server for the Autotask (Datto) PSA API, powered by the node-autotask SDK",
5
5
  "mcpProtocolBaseline": "2026-07-28",
6
6
  "legacyProtocolFallback": "2025-11-25",
@@ -62,7 +62,7 @@
62
62
  "capabilitiesManifest": "capabilities.json",
63
63
  "sdk": {
64
64
  "package": "node-autotask",
65
- "versionRange": "0.86.0"
65
+ "versionRange": "0.87.0"
66
66
  },
67
67
  "vendorExtensions": false,
68
68
  "credentialModelNote": "per-request; server-held under stdio or, on HTTP, only behind AUTOTASK_HTTP_AUTH=tokens; operator plans and the ledger are keyed by principal and tenant id, never by credential, and an apply authenticates the request credential and restores the plan's per-write impersonation"
@@ -28,7 +28,7 @@ Configuration items (CIs) are the assets. Count and group before listing. Values
28
28
  3. Group the same filter: `group_by: ["productID"]` first (or `configurationItemType`, `companyID`), `top: 50`. `groupsTruncated` or `hasMore`: partial, say so. Keys come named (`productIDName`); a `null` name: `products` (`companies`: `companyName`) by `id in`. Type names: `autotask_query {resource: "configuration_item_types", filter: [{field: "id", op: "exist", value: ""}], include_fields: ["id", "name"], limit: 100}`.
29
29
  4. List the same filter: `autotask_query {resource: "configuration_items", filter: <step 2>, include_fields: ["id", "referenceTitle", "serialNumber", "productID", "installDate", "warrantyExpirationDate", "sourceChargeID", "sourceChargeType"], limit: 100}`, plus `companyID` unless it is the scope. Every row: `output_path` (stdio only), not a larger limit.
30
30
  5. Licence terms: `autotask_query {resource: "subscriptions", filter: [{field: "configurationItemID", op: "in", value: "<CI ids>"}], include_fields: ["id", "configurationItemID", "subscriptionName", "effectiveDate", "expirationDate", "purchaseOrderNumber", "status"], limit: 100}`; expiring soon: add `expirationDate` `gte` today and `lte` a date. None there is not "no terms": check the CI's `warrantyExpirationDate`, `domainExpirationDateTime`, `sslValidUntilDateTime`, `userDefinedFields` and `contractServiceID`. Billing products: `configuration_item_billing_product_associations` by `configurationItemID in`.
31
- 6. Purchase date (CIs have none), in order: (a) the subscription `effectiveDate` and `purchaseOrderNumber`; (b) the CI's charge, only when the `sourceChargeType` label names its resource (the SDK has no type map; never guess): `autotask_query {resource: "<contract|project|ticket>_charges", filter: [{field: "id", op: "eq", value: "<sourceChargeID>"}], include_fields: ["datePurchased", "productID", "purchaseOrderNumber"], limit: 1}`; (c) `purchase_order_items` by `productID in` (`orderID`, `productID`, `quantity`), then `purchase_order_item_receiving` by `purchaseOrderItemID in` (`receiveDate`, `serialNumber`): product-level only, unless a receiving `serialNumber` equals the CI serial; (d) else `installDate`, labelled a proxy, never the purchase date.
31
+ 6. Purchase date (CIs have none), in order: (a) the subscription `effectiveDate` and `purchaseOrderNumber`; (b) the CI's charge, only when the `sourceChargeType` label names its resource (the SDK has no type map; never guess): `autotask_query {resource: "<contract|project|ticket>_charges", filter: [{field: "id", op: "eq", value: "<sourceChargeID>"}], include_fields: ["datePurchased", "productID", "purchaseOrderNumber"], limit: 1}`; (c) `purchase_order_items` by `productID in` (`orderID`, `productID`, `quantity`), then `purchase_order_item_receiving` by `purchaseOrderItemID in` (`purchaseOrderItemID`, `receiveDate`, `serialNumber`): product-level only, unless a receiving `serialNumber` equals the CI serial; (d) else `installDate`, labelled a proxy, never the purchase date.
32
32
  7. One item in depth, when served (`records` toolset): `autotask_configuration_item_profile {id: <CI id>}` (a part `unavailable` is a permission gap, not absence).
33
33
 
34
34
  ## Guardrails