iit-mcp-autotask 0.55.1 → 0.56.0

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
@@ -10,9 +10,9 @@ client + SDK-owned TTL caches).
10
10
 
11
11
  ## Tool surface
12
12
 
13
- The **core** toolset (10 tools) is always served; `AUTOTASK_TOOLSETS` adds `service`, `records` and
14
- `finance` (or `all`, 23 tools); the operator profile adds three. The whole tool surface (26 tools) is
15
- listed below. Every other operation in the SDK's operation registry stays
13
+ The **core** toolset is always served; `AUTOTASK_TOOLSETS` adds `service`, `records` and
14
+ `finance` (or `all`); the operator profile adds a few more. The whole tool surface is
15
+ listed below (exact per-selection counts: the generated `capabilities.json`). Every other operation in the SDK's operation registry stays
16
16
  reachable through the generic layer: `autotask_catalog` finds the key, `autotask_describe` serves
17
17
  its contract (slim by default: transport and retry detail dropped, long text cut, the first two
18
18
  examples; `full: true` serves the complete record, `summary: true` about 2 KB), `autotask_read` runs it.
@@ -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,3 @@
1
+ import type { Config } from './config/schema.js';
2
+ export declare function setupOrigin(raw: string, config: Config): string | undefined;
3
+ export declare function connectionSetup(config: Config, fetcher?: typeof fetch): (request: Request) => Promise<Response | undefined>;
@@ -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
@@ -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
- // One principal, one token (review F6): two tokens under one name would share plans, idempotency
52
- // keys and a rate bucket while carrying different profiles or run scopes.
53
- const seen = new Set();
54
- const repeated = new Set();
55
- for (const { entry } of entries)
56
- (seen.has(entry.principal) ? repeated : seen).add(entry.principal);
57
- if (repeated.size > 0)
58
- throw new ConfigError(`AUTOTASK_HTTP_TOKENS_FILE is invalid: principal(s) ${[...repeated].join(', ')} appear on more than one token`);
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)
@@ -107,7 +107,7 @@ export declare function sdkCacheOptions(cache: 'on' | 'off'): Pick<AutotaskConfi
107
107
  * fails the boot (or the CI test) instead of quietly shipping a tool surface that no longer
108
108
  * describes the SDK behind it.
109
109
  */
110
- export declare const BUILT_AGAINST_PLAN_HASH = "541ece7c6ea9d88c2d947d71b9d4724b95b6ade1192609221b7dbd904b73a794";
110
+ export declare const BUILT_AGAINST_PLAN_HASH = "13e1b558df986f3971f12661c00008c5782252cf7c9eb11dd9b0a70a2c9c1db5";
111
111
  /**
112
112
  * Fail fast when the installed SDK's plan has moved out from under this surface.
113
113
  * Called at boot (main.ts) and safe to call repeatedly (pure comparison).
@@ -186,7 +186,7 @@ export function sdkCacheOptions(cache) {
186
186
  * fails the boot (or the CI test) instead of quietly shipping a tool surface that no longer
187
187
  * describes the SDK behind it.
188
188
  */
189
- export const BUILT_AGAINST_PLAN_HASH = '541ece7c6ea9d88c2d947d71b9d4724b95b6ade1192609221b7dbd904b73a794';
189
+ export const BUILT_AGAINST_PLAN_HASH = '13e1b558df986f3971f12661c00008c5782252cf7c9eb11dd9b0a70a2c9c1db5';
190
190
  /**
191
191
  * Fail fast when the installed SDK's plan has moved out from under this surface.
192
192
  * Called at boot (main.ts) and safe to call repeatedly (pure comparison).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iit-mcp-autotask",
3
- "version": "0.55.1",
3
+ "version": "0.56.0",
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.1",
57
+ "node-autotask": "0.58.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.55.1",
3
+ "version": "0.56.0",
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.1"
65
+ "versionRange": "0.58.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 uses the credential on the apply request"