iit-mcp-autotask 0.66.0 → 0.66.1

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.
@@ -19,6 +19,7 @@ import { ok } from './results/envelope.js';
19
19
  import { assertOperationPermitted } from '../policy.js';
20
20
  import { documentReadArgs } from './documents.js';
21
21
  import { scopedCatalogCall } from './field-pointer.js';
22
+ import { queryQuirkHint } from './query-hints.js';
22
23
  /** The server line for an SDK aggregate answer: numbers only, and the partial marker whenever the SDK flags truncation. */
23
24
  function summaryLine(operation, result) {
24
25
  const r = (result ?? {});
@@ -62,6 +63,7 @@ export async function runAggregate(ctx, operation, rawFilter, opts, signal, extr
62
63
  });
63
64
  if (answer === undefined)
64
65
  return abortedAnswer(ctx.correlationId);
65
- return ok(summaryLine(operation, answer), { ...extra, operation, result: markResult(answer, ctx.untrustedFields(operation)) });
66
+ const hint = await queryQuirkHint(ctx, operation.slice(0, operation.indexOf('.')), filter);
67
+ return ok(`${summaryLine(operation, answer)}${hint}`, { ...extra, operation, result: markResult(answer, ctx.untrustedFields(operation)) });
66
68
  }
67
69
  //# sourceMappingURL=aggregate.js.map
@@ -14,6 +14,7 @@ import { isDeletedActivityAuditResource, staffReadParentFilter } from './catalog
14
14
  import { abortedAnswer, InputInvalidError } from './dispatch.js';
15
15
  import { documentCompanyScope, projectDocumentRows, scopedDocumentQuery, verifyDocumentRows } from './documents.js';
16
16
  import { runAggregate } from './aggregate.js';
17
+ import { queryQuirkHint } from './query-hints.js';
17
18
  import { markResult, markServerField, PROVENANCE, sanitiseVendorOutput } from './results/untrusted.js';
18
19
  import { bytesCappedNote, QUERY_MAX_BYTES, withinQueryBudget } from './query-budget.js';
19
20
  import { ok } from './results/envelope.js';
@@ -124,9 +125,11 @@ export function buildQuery(ctx) {
124
125
  // (both are blank-to-undefined at boot)
125
126
  const fileForm = ctx.config.MCP_TRANSPORT === 'stdio' && (ctx.config.AUTOTASK_OUTPUT_DIR !== undefined || ctx.config.AUTOTASK_STATE_DIR !== undefined);
126
127
  // #451: the full answer as today, or (over the byte budget) the cut answer of the first `rows` rows
128
+ // #472: a covered query-scoped SDK quirk (time_entries approval fields) rides the line once
129
+ const hint = await queryQuirkHint(ctx, args.resource, args.filter);
127
130
  const countText = (rows, cut) => cut === undefined
128
- ? `${typeof n === 'number' ? `${n} ${noun}` : noun} returned.${notes}`
129
- : `${rows} of ${cut.rowsFetched} ${noun} returned.${notes}${bytesCappedNote(cut, fileForm)}`;
131
+ ? `${typeof n === 'number' ? `${n} ${noun}` : noun} returned.${notes}${hint}`
132
+ : `${rows} of ${cut.rowsFetched} ${noun} returned.${notes}${bytesCappedNote(cut, fileForm)}${hint}`;
130
133
  // #459: an empty userDefinedFields array the caller did not name is dropped before the marking, so the
131
134
  // byte budget below measures the slimmed rows; JSON and TSV rows share this one result.
132
135
  const marked = markResult(withoutEmptyUdfs(result, args.include_fields), fields);
@@ -245,7 +248,7 @@ async function outputPathAnswer(ctx, resource, operation, noun, fields, args, si
245
248
  return abortedAnswer(ctx.correlationId);
246
249
  const { columns, rowCount, hasMore, walkNotes, firstRows, bytes, truncatedNote } = exported;
247
250
  const capNote = hasMore ? ` The walk is incomplete after ${rowCount} rows (truncated).` : '';
248
- return ok(`Wrote ${rowCount} ${noun} as ${asTsv ? 'TSV' : 'JSON'} to the output directory.${capNote} The summary carries the path, ${columns.length} column(s) and the first rows; result.items is omitted.`, {
251
+ return ok(`Wrote ${rowCount} ${noun} as ${asTsv ? 'TSV' : 'JSON'} to the output directory.${capNote} The summary carries the path, ${columns.length} column(s) and the first rows; result.items is omitted.${await queryQuirkHint(ctx, resource, args.filter)}`, {
249
252
  resource,
250
253
  result: {
251
254
  outputPath: target.path,
@@ -0,0 +1,3 @@
1
+ import type { ToolContext } from './context/types.js';
2
+ /** The ` <statement> <pointer>` text to append to a query answer line, or '' when no covered field is filtered. */
3
+ export declare function queryQuirkHint(ctx: ToolContext, resource: string, filter: unknown): Promise<string>;
@@ -0,0 +1,40 @@
1
+ /**
2
+ * tools/query-hints.ts — point-of-use hint for query-scoped SDK quirks (#472, #418): when a filter names a field a
3
+ * `vendor-managed-side-effect` quirk (ops includes `query`) covers, the quirk's own `statement` is appended once to the
4
+ * answer line. Derived from the SDK's relationship map (zero wire), never a server literal; a missing or unreadable
5
+ * map adds nothing. Rows and totals are never changed.
6
+ */
7
+ import { relationshipMap } from 'node-autotask/operations';
8
+ /** Pointer for the time-entry approval trap: the reachable-everywhere unposted-time read. */
9
+ const UNPOSTED_POINTER = 'Unposted time: autotask_read companies.unbilledWork (source "date_range" with dateFrom and dateTo).';
10
+ /** Lower-cased field names named by a filter: a conditions array, a `{filter}` bag, or nested `and`/`or` `items`. */
11
+ function filterFields(node, out = new Set()) {
12
+ if (Array.isArray(node))
13
+ for (const n of node)
14
+ filterFields(n, out);
15
+ else if (node !== null && typeof node === 'object') {
16
+ const o = node;
17
+ if (typeof o.field === 'string')
18
+ out.add(o.field.toLowerCase());
19
+ filterFields(o.items, out);
20
+ filterFields(o.filter, out);
21
+ }
22
+ return out;
23
+ }
24
+ /** The ` <statement> <pointer>` text to append to a query answer line, or '' when no covered field is filtered. */
25
+ export async function queryQuirkHint(ctx, resource, filter) {
26
+ try {
27
+ const named = filterFields(filter);
28
+ const map = (await relationshipMap(ctx.client, resource));
29
+ const quirks = Array.isArray(map?.zoneFacts?.quirks) ? map.zoneFacts.quirks : [];
30
+ const hit = quirks.find((q) => q?.kind === 'vendor-managed-side-effect' && Array.isArray(q.ops) && q.ops.includes('query') && typeof q.statement === 'string'
31
+ && Array.isArray(q.fields) && q.fields.some((f) => typeof f === 'string' && named.has(f.toLowerCase())));
32
+ if (hit === undefined)
33
+ return '';
34
+ return ` ${hit.statement}${resource === 'time_entries' ? ` ${UNPOSTED_POINTER}` : ''}`;
35
+ }
36
+ catch {
37
+ return '';
38
+ }
39
+ }
40
+ //# sourceMappingURL=query-hints.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iit-mcp-autotask",
3
- "version": "0.66.0",
3
+ "version": "0.66.1",
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",
package/server.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iit-mcp-autotask",
3
- "version": "0.66.0",
3
+ "version": "0.66.1",
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",