iit-mcp-autotask 0.58.3 → 0.58.5
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 +26 -1
- package/dist/access/write-env.d.ts +2 -0
- package/dist/access/write-env.js +10 -0
- package/dist/http-guard.d.ts +1 -0
- package/dist/http-guard.js +4 -0
- package/dist/policy.js +1 -1
- package/dist/tools/meta.js +13 -1
- package/dist/tools/schemas.d.ts +3 -2
- package/dist/tools/schemas.js +1 -1
- package/dist/tools/server.js +3 -1
- package/dist/tools/ticket-note-verification.d.ts +2 -0
- package/dist/tools/ticket-note-verification.js +31 -0
- package/dist/tools/write/preview.js +1 -1
- package/dist/write/evaluate.js +1 -1
- package/package.json +1 -1
- package/server.json +1 -1
package/README.md
CHANGED
|
@@ -405,6 +405,13 @@ its own tool list; a missing or unknown token is 401; each principal gets
|
|
|
405
405
|
static bearer map does not implement the MCP authorization spec's RFC 9728 metadata (deviation
|
|
406
406
|
D-14). For an operator deployment use a separate Autotask API user from the read deployments.
|
|
407
407
|
|
|
408
|
+
An optional token field `"writeOperations": ["time_entries.updateReviewFields", "ticket_notes.create"]`
|
|
409
|
+
restricts that token to these exact served write keys, intersected with `AUTOTASK_WRITE`. It cannot
|
|
410
|
+
grant globally denied operations or upgrade a readonly profile. Omit it to preserve existing authority;
|
|
411
|
+
`[]` denies all writes. Wildcards, unknown/read operations and duplicates refuse boot. Catalog, describe,
|
|
412
|
+
preview and apply share this restriction; changing it invalidates pending plans. Successful historical
|
|
413
|
+
replays only return their recorded result. These limits do not change read access or company scope.
|
|
414
|
+
|
|
408
415
|
### Local (stdio)
|
|
409
416
|
|
|
410
417
|
Needs Node 24+ and your Autotask zone origin. The CLI defaults to `http`, so local clients pass
|
|
@@ -792,7 +799,7 @@ See [docs/architecture.md](docs/architecture.md) section 5 for intentional omiss
|
|
|
792
799
|
|
|
793
800
|
Authenticated `GET /configuration/autotask` returns versioned named zone choices filtered by the deployment host policy. `POST /configuration/autotask/resolve-zone` accepts `{ "username": "api-user@example.com" }`, calls the fixed Autotask ZoneInformation endpoint without credentials, and returns an allowed HTTPS zone origin/label. Discovery follows no redirects; errors return safe codes. Both routes use the normal Host/Origin, bearer and rate-limit guard. Health/readiness remain zero-wire. The zone catalogue follows the vendor REST zone table; custom zones still require existing host-policy approval.
|
|
794
801
|
|
|
795
|
-
For token rotation, two hashes may name the same principal only with identical complete token entries (profile, toolsets and
|
|
802
|
+
For token rotation, two hashes may name the same principal only with identical complete token entries (profile, toolsets, run scope and write operations; write-operation list order is immaterial). Install both hashes, restart to load them, switch the client secret, verify and remove the old hash after an overlap. Different authorities under one principal still fail boot. Secrets are never part of discovery metadata.
|
|
796
803
|
|
|
797
804
|
### Complete time-entry note verification
|
|
798
805
|
|
|
@@ -806,6 +813,24 @@ contract, SDK/plan and supported bounds first; retain separate connection/auth p
|
|
|
806
813
|
See [the runtime proof contract](docs/read-runtime.md) for canonicalization, drift
|
|
807
814
|
semantics and typed refusals. The guard is optional for existing consumers.
|
|
808
815
|
|
|
816
|
+
For exact TicketNote readback, first request `autotask_tenant_status {parts:["server"]}`
|
|
817
|
+
and require `server.ticketNoteVerificationProjection === "ticket_note_verification_v1"`
|
|
818
|
+
before creating a note whose complete description must be verified. Older servers omit the field.
|
|
819
|
+
Then read:
|
|
820
|
+
|
|
821
|
+
```json
|
|
822
|
+
{"operation":"ticket_notes.get","args":[9,44],"projection":"ticket_note_verification_v1"}
|
|
823
|
+
```
|
|
824
|
+
|
|
825
|
+
The response `data` has `contract:"ticket-note-verification-v1"`, `fresh:true`, validated
|
|
826
|
+
`note:{id,ticketID,noteType,publish}`, and `text:{title,description}`. Each complete text proof
|
|
827
|
+
has `state:"complete"`, UTF-16 `units`, code-point `characters`, UTF-8 `bytes`, and `sha256`.
|
|
828
|
+
Hashes cover raw text before display cleaning or truncation. Null text has `state:"null"`;
|
|
829
|
+
missing, invalid-Unicode or over-1-MiB text has `state:"unavailable"` and no hash. No note bodies
|
|
830
|
+
are returned. Check both parent and note IDs, the contract/fresh flag, publish/note type and
|
|
831
|
+
complete proof states before comparing hashes. The optional `expectedReadRuntime` guard,
|
|
832
|
+
SDK fresh read, credentials and operation policy remain in force; ordinary notes stay capped.
|
|
833
|
+
|
|
809
834
|
For full bounded note display and protected-field evidence, opt in to `billing_review_entry_v1`:
|
|
810
835
|
|
|
811
836
|
```json
|
|
@@ -24,6 +24,8 @@ export interface LoadedPolicy {
|
|
|
24
24
|
transport: Transport;
|
|
25
25
|
warnings: string[];
|
|
26
26
|
}
|
|
27
|
+
/** Token restrictions only narrow global policy; omitted preserves legacy plans byte-for-byte. */
|
|
28
|
+
export declare function restrictWritePolicy(loaded: LoadedPolicy, operations?: readonly string[]): LoadedPolicy;
|
|
27
29
|
/** The hard rule an op hits whatever its payload (`always`), or the move escalation it may hit (`move`). */
|
|
28
30
|
export declare function hardRuleOf(key: string): 'always' | 'move' | undefined;
|
|
29
31
|
/** `transport` defaults to stdio for the unit tests; every boot caller passes MCP_TRANSPORT. */
|
package/dist/access/write-env.js
CHANGED
|
@@ -9,6 +9,16 @@ import { ConfigError } from '../config/schema.js';
|
|
|
9
9
|
import { hashOf } from '../write/canonical.js';
|
|
10
10
|
import { hardRuleFor, MOVE_OPS, writeShape } from '../write/hard-rules.js';
|
|
11
11
|
import { RECORDS, recordById } from '../tools/catalog-data.js';
|
|
12
|
+
/** Token restrictions only narrow global policy; omitted preserves legacy plans byte-for-byte. */
|
|
13
|
+
export function restrictWritePolicy(loaded, operations) {
|
|
14
|
+
if (operations === undefined)
|
|
15
|
+
return loaded;
|
|
16
|
+
const allowed = new Set(operations);
|
|
17
|
+
return { ...loaded,
|
|
18
|
+
table: new Map([...loaded.table].filter(([operation]) => allowed.has(operation))),
|
|
19
|
+
policyHash: hashOf({ basePolicyHash: loaded.policyHash, writeOperations: [...allowed].sort() }),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
12
22
|
const MODES = ['allow', 'deny', 'confirm', 'unattended'];
|
|
13
23
|
const SERVER_GATED = ['confirm', 'unattended'];
|
|
14
24
|
const FAMILY = /^[a-z][a-z0-9_]*\.\*$/;
|
package/dist/http-guard.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ declare const TOKEN_ENTRY: z.ZodObject<{
|
|
|
21
21
|
}, z.core.$strict>, z.ZodObject<{
|
|
22
22
|
companyIds: z.ZodArray<z.ZodNumber>;
|
|
23
23
|
}, z.core.$strict>]>>;
|
|
24
|
+
writeOperations: z.ZodOptional<z.ZodPipe<z.ZodArray<z.ZodString>, z.ZodTransform<string[], string[]>>>;
|
|
24
25
|
}, z.core.$strict>;
|
|
25
26
|
export type TokenEntry = z.infer<typeof TOKEN_ENTRY>;
|
|
26
27
|
/** The loaded tokens file: entries by their SHA-256 key (the token itself is never held). */
|
package/dist/http-guard.js
CHANGED
|
@@ -20,6 +20,8 @@ import { readFileSync } from 'node:fs';
|
|
|
20
20
|
import { hostHeaderValidationResponse, localhostAllowedHostnames, localhostAllowedOrigins, originValidationResponse, } from '@modelcontextprotocol/server';
|
|
21
21
|
import * as z from 'zod';
|
|
22
22
|
import { ConfigError, PROFILES, TOOLSETS, RUN_SCOPE, isLoopbackHost } from './config/schema.js';
|
|
23
|
+
import { recordById } from './tools/catalog-data.js';
|
|
24
|
+
import { hardRuleFor } from './write/hard-rules.js';
|
|
23
25
|
/** The request body cap on the HTTP transport (M10). */
|
|
24
26
|
export const MAX_BODY_BYTES = 1024 * 1024;
|
|
25
27
|
/**
|
|
@@ -33,6 +35,8 @@ const TOKEN_ENTRY = z
|
|
|
33
35
|
profile: z.enum(PROFILES),
|
|
34
36
|
toolsets: z.array(z.enum([...TOOLSETS, 'all'])).optional(),
|
|
35
37
|
runScope: RUN_SCOPE.optional(),
|
|
38
|
+
writeOperations: z.array(z.string().max(200).refine((operation) => hardRuleFor(operation, recordById(operation)).never === undefined, 'must name a served write operation')).max(1000).refine((operations) => new Set(operations).size === operations.length, 'duplicate write operations')
|
|
39
|
+
.transform((operations) => [...operations].sort()).optional(),
|
|
36
40
|
})
|
|
37
41
|
.strict();
|
|
38
42
|
const TOKENS_FILE = z.record(z.string().regex(/^[0-9a-f]{64}$/, 'keys are the lowercase hex SHA-256 of a token'), TOKEN_ENTRY);
|
package/dist/policy.js
CHANGED
|
@@ -45,7 +45,7 @@ export function refusalReason(operation, record, config, writable = new Set()) {
|
|
|
45
45
|
return null;
|
|
46
46
|
if (config.AUTOTASK_PROFILE !== 'operator')
|
|
47
47
|
return 'refused: profile readonly serves reads only';
|
|
48
|
-
return writable.has(operation) ? null : 'refused: not
|
|
48
|
+
return writable.has(operation) ? null : 'refused: not admitted by the effective write policy (unlisted writes are read-only)';
|
|
49
49
|
}
|
|
50
50
|
/** The `POLICY_DENIED` error: deployment policy is fixed for the life of the process, so the
|
|
51
51
|
* model is told no argument it can choose will satisfy the gate (a `CONFIG_ERROR` here would
|
package/dist/tools/meta.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { projectTicketNoteVerification, TICKET_NOTE_VERIFICATION_PROJECTION } from './ticket-note-verification.js';
|
|
1
2
|
import { readRuntimeProof } from './read-runtime.js';
|
|
2
3
|
import { readBillingReview } from './billing-review-projection.js';
|
|
3
4
|
import { projectTimeEntryVerification } from './time-entry-verification.js';
|
|
@@ -614,6 +615,17 @@ export function buildRead(ctx) {
|
|
|
614
615
|
}
|
|
615
616
|
if (args.projection === 'billing_review_entry_v1')
|
|
616
617
|
return readBillingReview(ctx, args, signal);
|
|
618
|
+
if (args.projection === TICKET_NOTE_VERIFICATION_PROJECTION) {
|
|
619
|
+
if (args.operation !== 'ticket_notes.get' || args.items !== undefined || args.args.length !== 2 ||
|
|
620
|
+
args.args.some(id => !Number.isSafeInteger(id) || id <= 0)) {
|
|
621
|
+
throw new InputInvalidError('ticket note verification requires one ticket_notes.get and positive ticket/note ids', 'projection');
|
|
622
|
+
}
|
|
623
|
+
const [ticketId, noteId] = args.args;
|
|
624
|
+
const out = await readOneItem(ctx, args.operation, args.args, signal, { fresh: true }, raw => projectTicketNoteVerification(raw, ticketId, noteId));
|
|
625
|
+
if (out.aborted)
|
|
626
|
+
return abortedAnswer(ctx.correlationId);
|
|
627
|
+
return ok('Fresh TicketNote verification; note text withheld.', out.result);
|
|
628
|
+
}
|
|
617
629
|
if (args.projection !== undefined && args.projection !== 'default') {
|
|
618
630
|
if (args.operation !== 'time_entries.get' || args.items !== undefined || args.args.length !== 1 || !Number.isSafeInteger(args.args[0]) || args.args[0] <= 0) {
|
|
619
631
|
throw new InputInvalidError('verification projection requires one time_entries.get and one positive numeric id', 'projection');
|
|
@@ -689,7 +701,7 @@ export function buildTenantStatus(ctx) {
|
|
|
689
701
|
for (const part of parts) {
|
|
690
702
|
// Zero wire: this package's version (the same constant as serverInfo and /metadata), kept apart from the vendor `version` part.
|
|
691
703
|
if (part === 'server') {
|
|
692
|
-
data.server = { name: SERVER_NAME, version: SERVER_VERSION, sdkVersion: SDK_VERSION, profile: ctx.config.AUTOTASK_PROFILE, readRuntime: readRuntimeProof(ctx.client) };
|
|
704
|
+
data.server = { name: SERVER_NAME, version: SERVER_VERSION, sdkVersion: SDK_VERSION, profile: ctx.config.AUTOTASK_PROFILE, ticketNoteVerificationProjection: TICKET_NOTE_VERIFICATION_PROJECTION, readRuntime: readRuntimeProof(ctx.client) };
|
|
693
705
|
continue;
|
|
694
706
|
}
|
|
695
707
|
// Zero wire: the users' zone (AUTOTASK_USER_TIMEZONE) and its clock (#171), so a client need not guess today's date or zone.
|
package/dist/tools/schemas.d.ts
CHANGED
|
@@ -208,6 +208,7 @@ export declare const READ_INPUT: z.ZodPipe<z.ZodObject<{
|
|
|
208
208
|
default: "default";
|
|
209
209
|
time_entry_verification_v1: "time_entry_verification_v1";
|
|
210
210
|
billing_review_entry_v1: "billing_review_entry_v1";
|
|
211
|
+
ticket_note_verification_v1: "ticket_note_verification_v1";
|
|
211
212
|
}>>, unknown>;
|
|
212
213
|
expectedReadRuntime: z.ZodOptional<z.ZodString>;
|
|
213
214
|
}, z.core.$strip>, z.ZodTransform<{
|
|
@@ -217,7 +218,7 @@ export declare const READ_INPUT: z.ZodPipe<z.ZodObject<{
|
|
|
217
218
|
operation: string;
|
|
218
219
|
args: unknown[];
|
|
219
220
|
}[] | undefined;
|
|
220
|
-
projection?: "default" | "time_entry_verification_v1" | "billing_review_entry_v1" | undefined;
|
|
221
|
+
projection?: "default" | "time_entry_verification_v1" | "billing_review_entry_v1" | "ticket_note_verification_v1" | undefined;
|
|
221
222
|
expectedReadRuntime?: string | undefined;
|
|
222
223
|
}, {
|
|
223
224
|
args: unknown[];
|
|
@@ -226,7 +227,7 @@ export declare const READ_INPUT: z.ZodPipe<z.ZodObject<{
|
|
|
226
227
|
operation: string;
|
|
227
228
|
args: unknown[];
|
|
228
229
|
}[] | undefined;
|
|
229
|
-
projection?: "default" | "time_entry_verification_v1" | "billing_review_entry_v1" | undefined;
|
|
230
|
+
projection?: "default" | "time_entry_verification_v1" | "billing_review_entry_v1" | "ticket_note_verification_v1" | undefined;
|
|
230
231
|
expectedReadRuntime?: string | undefined;
|
|
231
232
|
}>>;
|
|
232
233
|
export declare const RESOLVE_INPUT: z.ZodObject<{
|
package/dist/tools/schemas.js
CHANGED
|
@@ -238,7 +238,7 @@ export const READ_INPUT = z.object({
|
|
|
238
238
|
operation: unset(OP_KEY.optional()).describe('Exact read key, e.g. tickets.get (autotask_catalog finds it).'),
|
|
239
239
|
args: unset(ARGS),
|
|
240
240
|
items: unset(z.array(READ_ITEM).min(1).max(READ_MAX_ITEMS).optional()).describe('Batch reads in one call, each { operation, args }; use instead of operation.'),
|
|
241
|
-
projection: unset(z.enum(['default', 'time_entry_verification_v1', 'billing_review_entry_v1']).optional()).describe('default: normal read. time_entry_verification_v1: fresh metadata-only get. billing_review_entry_v1: fresh ticket-entry get or bounded query (limit<=25, no includeFields); full bounded display notes and raw hashes.'),
|
|
241
|
+
projection: unset(z.enum(['default', 'time_entry_verification_v1', 'billing_review_entry_v1', 'ticket_note_verification_v1']).optional()).describe('default: normal read. time_entry_verification_v1: fresh metadata-only get. ticket_note_verification_v1: fresh parent-scoped ticket_notes.get [ticketId,noteId], hashes/counts only. billing_review_entry_v1: fresh ticket-entry get or bounded query (limit<=25, no includeFields); full bounded display notes and raw hashes.'),
|
|
242
242
|
expectedReadRuntime: z.string().regex(/^[a-f0-9]{64}$/).optional().describe('Require server.readRuntime.sha256 from autotask_tenant_status; changed or unavailable runtime refuses before any vendor dispatch.'),
|
|
243
243
|
}).transform(v => v.projection === 'billing_review_entry_v1' ? v : numericQueryBag(v));
|
|
244
244
|
export const RESOLVE_INPUT = z.object({
|
package/dist/tools/server.js
CHANGED
|
@@ -32,6 +32,7 @@ import { FILTER_OPS } from './schemas.js';
|
|
|
32
32
|
import { UNSCOPED_WALK_THRESHOLD } from 'node-autotask';
|
|
33
33
|
import { registerTools } from './register.js';
|
|
34
34
|
import { configForToken } from '../http-guard.js';
|
|
35
|
+
import { restrictWritePolicy } from '../access/write-env.js';
|
|
35
36
|
/** The wire identity of this server (the initialize answer + the `/metadata` payload). */
|
|
36
37
|
import { SERVER_NAME, SERVER_VERSION } from './server-version.js';
|
|
37
38
|
export { SERVER_NAME, SERVER_VERSION };
|
|
@@ -154,7 +155,8 @@ export function createMcpServerFactory(config, log, options = {}) {
|
|
|
154
155
|
...(requestConfig.AUTOTASK_PROFILE === 'operator' && write !== undefined
|
|
155
156
|
? {
|
|
156
157
|
write: {
|
|
157
|
-
runtime: write
|
|
158
|
+
runtime: entry?.writeOperations === undefined ? write
|
|
159
|
+
: { ...write, loaded: restrictWritePolicy(write.loaded, entry.writeOperations) },
|
|
158
160
|
principal: identity !== undefined ? identity.principal : (entry?.principal ?? config.AUTOTASK_PRINCIPAL),
|
|
159
161
|
runScope: tokens === undefined ? config.AUTOTASK_RUN_SCOPE : entry?.runScope,
|
|
160
162
|
...(identity?.clientId !== undefined ? { clientId: identity.clientId } : {}),
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** Fresh parent-scoped TicketNote evidence; vendor text never leaves this projection. */
|
|
2
|
+
import { createHash } from 'node:crypto';
|
|
3
|
+
import { InputInvalidError } from './dispatch.js';
|
|
4
|
+
export const TICKET_NOTE_VERIFICATION_PROJECTION = 'ticket_note_verification_v1';
|
|
5
|
+
const MAX_TEXT_BYTES = 1_048_576;
|
|
6
|
+
function fingerprint(value) {
|
|
7
|
+
if (value === null)
|
|
8
|
+
return { state: 'null' };
|
|
9
|
+
if (typeof value !== 'string')
|
|
10
|
+
return { state: 'unavailable', reason: 'missing_or_invalid' };
|
|
11
|
+
// Hash exact UTF-8 only: replacement of an unpaired surrogate would attest different text.
|
|
12
|
+
if (/[\uD800-\uDFFF]/u.test(value))
|
|
13
|
+
return { state: 'unavailable', reason: 'invalid_unicode' };
|
|
14
|
+
const bytes = Buffer.byteLength(value, 'utf8');
|
|
15
|
+
if (bytes > MAX_TEXT_BYTES)
|
|
16
|
+
return { state: 'unavailable', reason: 'too_large' };
|
|
17
|
+
return { state: 'complete', units: value.length, characters: [...value].length, bytes,
|
|
18
|
+
sha256: createHash('sha256').update(value, 'utf8').digest('hex') };
|
|
19
|
+
}
|
|
20
|
+
export function projectTicketNoteVerification(result, ticketId, noteId) {
|
|
21
|
+
const row = result;
|
|
22
|
+
if (row === null || typeof row !== 'object' || Array.isArray(row) || row.id !== noteId || row.ticketID !== ticketId ||
|
|
23
|
+
!Number.isSafeInteger(row.noteType) || row.noteType < 0 ||
|
|
24
|
+
!Number.isSafeInteger(row.publish) || row.publish < 0) {
|
|
25
|
+
throw new InputInvalidError('ticket note verification: the fresh identity or scalar fields were missing or inconsistent', 'args');
|
|
26
|
+
}
|
|
27
|
+
return { contract: 'ticket-note-verification-v1', fresh: true,
|
|
28
|
+
note: { id: row.id, ticketID: row.ticketID, noteType: row.noteType, publish: row.publish },
|
|
29
|
+
text: { title: fingerprint(row.title), description: fingerprint(row.description) } };
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=ticket-note-verification.js.map
|
|
@@ -242,7 +242,7 @@ async function execute(ctx, args, signal) {
|
|
|
242
242
|
const hard = hardRuleFor(op, found);
|
|
243
243
|
const rule = loaded.table.get(op);
|
|
244
244
|
if (hard.never !== undefined || rule === undefined || rule.mode === 'deny') {
|
|
245
|
-
const why = hard.never !== undefined ? `${op}: ${hard.never}` : rule === undefined ? `${op} is not
|
|
245
|
+
const why = hard.never !== undefined ? `${op}: ${hard.never}` : rule === undefined ? `${op} is not admitted by the effective write policy (unlisted writes are read-only)` : `AUTOTASK_WRITE denies ${op}`;
|
|
246
246
|
const rs = [reason('OP_NOT_ALLOWED', why)];
|
|
247
247
|
audit('denied', rs);
|
|
248
248
|
return answer('denied', 'stop', rs, { operation: op });
|
package/dist/write/evaluate.js
CHANGED
|
@@ -53,7 +53,7 @@ export function evaluate(loaded, facts, runScope, counters) {
|
|
|
53
53
|
return deny('OP_NOT_ALLOWED', `${facts.op}: ${hard.never}`, []);
|
|
54
54
|
const row = loaded.table.get(facts.op);
|
|
55
55
|
if (row === undefined)
|
|
56
|
-
return deny('OP_NOT_ALLOWED', `${facts.op} is not
|
|
56
|
+
return deny('OP_NOT_ALLOWED', `${facts.op} is not admitted by the effective write policy (unlisted writes are read-only)`, hard.hazards);
|
|
57
57
|
if (row.mode === 'deny')
|
|
58
58
|
return deny('OP_NOT_ALLOWED', `AUTOTASK_WRITE denies ${facts.op}`, hard.hazards);
|
|
59
59
|
if (runScope === undefined)
|
package/package.json
CHANGED
package/server.json
CHANGED