iit-mcp-autotask 0.55.0 → 0.55.2
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 +7 -0
- package/dist/connection-setup.d.ts +3 -0
- package/dist/connection-setup.js +68 -0
- package/dist/http-guard.js +10 -8
- package/dist/http.d.ts +1 -1
- package/dist/http.js +6 -2
- package/package.json +2 -2
- package/server.json +2 -2
- package/skills/non-chargeable-work.md +1 -1
- package/skills/wip-hours.md +1 -1
package/README.md
CHANGED
|
@@ -786,3 +786,10 @@ per integration) is guarded by the SDK agent profile (8,000/hr local budget, 3 c
|
|
|
786
786
|
live through `autotask_tenant_status`.
|
|
787
787
|
|
|
788
788
|
See [docs/architecture.md](docs/architecture.md) section 5 for intentional omissions and blocked capabilities.
|
|
789
|
+
|
|
790
|
+
|
|
791
|
+
### Connection setup for managed clients
|
|
792
|
+
|
|
793
|
+
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
|
+
|
|
795
|
+
For token rotation, two hashes may name the same principal only with identical complete token entries (profile, toolsets and run scope). 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.
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/** Authenticated setup metadata; discovery sends only a username to the fixed vendor endpoint. */
|
|
2
|
+
import { baseHostAllowed, normalizeBaseUrl } from './base-hosts.js';
|
|
3
|
+
const ZONE_HOSTS = [
|
|
4
|
+
['Pre-release', 'webservices2'], ['Pre-release (UK)', 'webservices11'],
|
|
5
|
+
['Limited Release', 'webservices1'], ['Limited Release (UK)', 'webservices17'],
|
|
6
|
+
['America East', 'webservices3'], ['America East 2', 'webservices14'], ['America East 3', 'webservices22'],
|
|
7
|
+
['America West', 'webservices5'], ['America West 2', 'webservices15'], ['America West 3', 'webservices24'], ['America West 4', 'webservices25'],
|
|
8
|
+
['UK', 'webservices4'], ['UK2', 'webservices16'], ['UK3', 'webservices28'],
|
|
9
|
+
['Pre-release (Aus)', 'webservices30'], ['Australia / New Zealand', 'webservices6'],
|
|
10
|
+
['Australia 2', 'webservices26'], ['Australia 3', 'webservices29'], ['Australia 4', 'webservices31'],
|
|
11
|
+
['Pre-release (Deutsch)', 'prde'], ['Pre-release (Español)', 'pres'],
|
|
12
|
+
['German (Deutsch)', 'webservices18'], ['EU1 (English Europe and Asia)', 'webservices19'], ['Spanish (Español)', 'webservices12'],
|
|
13
|
+
];
|
|
14
|
+
export function setupOrigin(raw, config) {
|
|
15
|
+
let parsed;
|
|
16
|
+
try {
|
|
17
|
+
parsed = new URL(raw);
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
if (parsed.search || parsed.hash || (parsed.port !== '' && parsed.port !== '443'))
|
|
23
|
+
return undefined;
|
|
24
|
+
const normalized = normalizeBaseUrl(raw.replace(/\/atservicesrest\/?$/, ''));
|
|
25
|
+
if (normalized === undefined)
|
|
26
|
+
return undefined;
|
|
27
|
+
if (config.AUTOTASK_ALLOWED_BASE_HOSTS !== undefined) {
|
|
28
|
+
return baseHostAllowed(normalized.origin, config.AUTOTASK_ALLOWED_BASE_HOSTS) ? normalized.origin : undefined;
|
|
29
|
+
}
|
|
30
|
+
const defaultOrigin = config.AUTOTASK_BASE_URL === undefined ? undefined : normalizeBaseUrl(config.AUTOTASK_BASE_URL)?.origin;
|
|
31
|
+
return normalized.origin === defaultOrigin || config.AUTOTASK_ALLOW_ANY_BASE_HOST ? normalized.origin : undefined;
|
|
32
|
+
}
|
|
33
|
+
export function connectionSetup(config, fetcher = fetch) {
|
|
34
|
+
return async (request) => {
|
|
35
|
+
const path = new URL(request.url).pathname;
|
|
36
|
+
if (path === '/configuration/autotask' && request.method === 'GET') {
|
|
37
|
+
return Response.json({ version: 1, zones: ZONE_HOSTS.map(([label, host]) => ({ label, url: `https://${host}.autotask.net` })).filter(zone => setupOrigin(zone.url, config) !== undefined) }, { headers: { 'Cache-Control': 'no-store' } });
|
|
38
|
+
}
|
|
39
|
+
if (path !== '/configuration/autotask/resolve-zone' || request.method !== 'POST')
|
|
40
|
+
return undefined;
|
|
41
|
+
let body;
|
|
42
|
+
try {
|
|
43
|
+
body = await request.json();
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
return Response.json({ code: 'INVALID_USERNAME' }, { status: 400 });
|
|
47
|
+
}
|
|
48
|
+
const username = body?.username;
|
|
49
|
+
if (typeof username !== 'string' || username.length > 254 || !/^[^\s@]+@[^\s@]+$/.test(username))
|
|
50
|
+
return Response.json({ code: 'INVALID_USERNAME' }, { status: 400 });
|
|
51
|
+
try {
|
|
52
|
+
const url = new URL('https://webservices.autotask.net/atservicesrest/v1.0/zoneInformation');
|
|
53
|
+
url.searchParams.set('user', username);
|
|
54
|
+
const response = await fetcher(url, { redirect: 'error', signal: AbortSignal.timeout(10000) });
|
|
55
|
+
if (!response.ok)
|
|
56
|
+
throw new Error('discovery failed');
|
|
57
|
+
const data = await response.json();
|
|
58
|
+
const origin = typeof data.url === 'string' ? setupOrigin(data.url, config) : undefined;
|
|
59
|
+
if (origin === undefined)
|
|
60
|
+
return Response.json({ code: 'ZONE_NOT_ALLOWED' }, { status: 400 });
|
|
61
|
+
return Response.json({ url: origin, label: typeof data.zoneName === 'string' ? data.zoneName.slice(0, 100) : origin }, { headers: { 'Cache-Control': 'no-store' } });
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
return Response.json({ code: 'ZONE_DISCOVERY_FAILED' }, { status: 502 });
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=connection-setup.js.map
|
package/dist/http-guard.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isDeepStrictEqual } from 'node:util';
|
|
1
2
|
/**
|
|
2
3
|
* http-guard.ts — what stands in front of `/mcp` on the HTTP transport (0.6.0, A12):
|
|
3
4
|
*
|
|
@@ -48,14 +49,15 @@ export function loadTokenStore(path) {
|
|
|
48
49
|
const entries = Object.entries(parsed).map(([hash, entry]) => ({ key: Buffer.from(hash, 'hex'), entry }));
|
|
49
50
|
if (entries.length === 0)
|
|
50
51
|
throw new ConfigError('AUTOTASK_HTTP_TOKENS_FILE lists no token');
|
|
51
|
-
//
|
|
52
|
-
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
52
|
+
// Rotation overlap keeps plan ownership, but may never give one principal two authorities.
|
|
53
|
+
const byPrincipal = new Map();
|
|
54
|
+
for (const { entry } of entries) {
|
|
55
|
+
const previous = byPrincipal.get(entry.principal);
|
|
56
|
+
if (previous !== undefined && !isDeepStrictEqual(previous, entry)) {
|
|
57
|
+
throw new ConfigError(`AUTOTASK_HTTP_TOKENS_FILE principal '${entry.principal}' has conflicting authorities across tokens`);
|
|
58
|
+
}
|
|
59
|
+
byPrincipal.set(entry.principal, entry);
|
|
60
|
+
}
|
|
59
61
|
return {
|
|
60
62
|
size: entries.length,
|
|
61
63
|
entries: entries.map((e) => e.entry),
|
package/dist/http.d.ts
CHANGED
|
@@ -39,7 +39,7 @@ export declare function loadMetadata(fallback: {
|
|
|
39
39
|
*
|
|
40
40
|
* Split out from the listener so the request path is testable without binding a port.
|
|
41
41
|
*/
|
|
42
|
-
export declare function createFetchHandler(mcp: FetchHandler, metadata: unknown, doctor?: () => unknown, guard?: McpGuard, ready?: () => unknown): (request: Request) => Promise<Response>;
|
|
42
|
+
export declare function createFetchHandler(mcp: FetchHandler, metadata: unknown, doctor?: () => unknown, guard?: McpGuard, ready?: () => unknown, setup?: (request: Request) => Promise<Response | undefined>): (request: Request) => Promise<Response>;
|
|
43
43
|
/**
|
|
44
44
|
* Bind the listener. `mcp` is supplied by the caller so this module never builds tools itself.
|
|
45
45
|
*
|
package/dist/http.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { connectionSetup } from './connection-setup.js';
|
|
1
2
|
/**
|
|
2
3
|
* http.ts — the remote transport: streamable HTTP.
|
|
3
4
|
*
|
|
@@ -115,7 +116,7 @@ function readFileSyncIfPresent(path) {
|
|
|
115
116
|
*
|
|
116
117
|
* Split out from the listener so the request path is testable without binding a port.
|
|
117
118
|
*/
|
|
118
|
-
export function createFetchHandler(mcp, metadata, doctor, guard, ready) {
|
|
119
|
+
export function createFetchHandler(mcp, metadata, doctor, guard, ready, setup) {
|
|
119
120
|
return async function handle(request) {
|
|
120
121
|
const url = new URL(request.url);
|
|
121
122
|
// The orchestrator probes: pre-auth, and they must not touch the vendor — a zone outage
|
|
@@ -145,6 +146,9 @@ export function createFetchHandler(mcp, metadata, doctor, guard, ready) {
|
|
|
145
146
|
if (verdict instanceof Response)
|
|
146
147
|
return verdict;
|
|
147
148
|
}
|
|
149
|
+
const setupResponse = await setup?.(request);
|
|
150
|
+
if (setupResponse !== undefined)
|
|
151
|
+
return setupResponse;
|
|
148
152
|
if (url.pathname === METADATA_PATH) {
|
|
149
153
|
return Response.json(metadata);
|
|
150
154
|
}
|
|
@@ -232,7 +236,7 @@ export function startHttpServer(config, mcp, log, tokens, exit = process.exit, e
|
|
|
232
236
|
const host = config.MCP_HOST;
|
|
233
237
|
// A builder, not a constant: the route reports THIS process's parsed config, and nothing is read
|
|
234
238
|
// until a request arrives (so the route stays credential-free at rest).
|
|
235
|
-
const handle = createFetchHandler(mcp, metadata, () => runDoctor(config, env, describeSurface(config)), createMcpGuard(config, tokens), ready);
|
|
239
|
+
const handle = createFetchHandler(mcp, metadata, () => runDoctor(config, env, describeSurface(config)), createMcpGuard(config, tokens), ready, connectionSetup(config));
|
|
236
240
|
const server = createServer((req, res) => {
|
|
237
241
|
void toWebRequest(req, config.PORT)
|
|
238
242
|
.then(handle)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "iit-mcp-autotask",
|
|
3
|
-
"version": "0.55.
|
|
3
|
+
"version": "0.55.2",
|
|
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.57.
|
|
57
|
+
"node-autotask": "0.57.1",
|
|
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.55.
|
|
3
|
+
"version": "0.55.2",
|
|
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.57.
|
|
65
|
+
"versionRange": "0.57.1"
|
|
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 uses the credential on the apply request"
|
|
@@ -34,7 +34,7 @@ eval: evals/non-chargeable-work.json
|
|
|
34
34
|
- `value` is in the internal currency (`extendedPrice` where the internal field is absent); `hours` are labour lines only. No revenue is reported: never present these figures as revenue or lost revenue.
|
|
35
35
|
- `autotask_revenue_rollup` with `includeNonChargeable` keys invoiced lines on the invoice date, so its figures differ from this report for the same window.
|
|
36
36
|
- Rows plus `rowsTruncated` plus `coverage.unresolved` equal `totals`: report `coverage.unresolved` (lines whose company, contract or contract type could not be read) rather than dropping it.
|
|
37
|
-
- Unposted non-billable time entries have no billing item yet and are not counted by default; `wip-hours` covers unposted billable time only. With `includeUnpostedTime: true` they are reported as `unpostedNonBillableTime`: hours only (no value is guessed), not grouped, and never added to `totals` or the rows. A `companyIDs` scope keeps the entries of those companies' tickets and tasks' projects
|
|
37
|
+
- Unposted non-billable time entries have no billing item yet and are not counted by default; `wip-hours` covers unposted billable time only. With `includeUnpostedTime: true` they are reported as `unpostedNonBillableTime`: hours only (no value is guessed), not grouped, and never added to `totals` or the rows. A `companyIDs` scope keeps the entries of those companies' tickets and tasks' projects; company-task entries have no derivable company, so they count as out of scope under `companyIDs`.
|
|
38
38
|
- `id: null` is the no-contract row. Company and contract `name` values are untrusted vendor data; contract-type `label` values are picklist text.
|
|
39
39
|
|
|
40
40
|
## Verify
|
package/skills/wip-hours.md
CHANGED
|
@@ -31,7 +31,7 @@ eval: evals/wip-hours.json
|
|
|
31
31
|
|
|
32
32
|
- WIP is a billable time entry in the window that no billing item references (unposted). Hours only: no dollar value is reported or guessed.
|
|
33
33
|
- `approvedHours` / `unapprovedHours` are `null` when no entry in the window carries `billingApprovalDateTime` (`coverage.approvalData` false): say approval is not recorded on this tenant rather than reporting everything as unapproved.
|
|
34
|
-
- A time entry has no company field: a `companyIDs` scope reads the whole window (the same entry pages and joins as `tenantWide`, plus the ticket, task and project reads that place each entry), so it is not cheaper than tenant-wide. Narrow the window instead.
|
|
34
|
+
- A time entry has no company field: a `companyIDs` scope reads the whole window (the same entry pages and joins as `tenantWide`, plus the ticket, task and project reads that place each entry), so it is not cheaper than tenant-wide. Narrow the window instead. Company-task time entries have no derivable company: they count as out of scope under a `companyIDs` scope and key to "no company" under `groupBy` company.
|
|
35
35
|
- `postedUninvoiced` counts posted entries whose billing item has no invoice: a sanity metric, not part of WIP.
|
|
36
36
|
- `isNonBillable eq false` is filtered server-side, so `coverage.entriesRead` counts billable entries only (not every entry in the window), and `coverage.approvalData` is decided on billable entries only. `coverage.excluded.nonBillable` comes from a separate count call. Do not read `entriesRead` as the window's total entries.
|
|
37
37
|
- Report `coverage.excluded` (non-billable, posted, out of scope) and `coverage.entriesWithoutHoursToBill` beside the totals.
|