iit-mcp-autotask 0.55.1 → 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 +1 -1
- package/server.json +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
package/server.json
CHANGED