@onlyflows/servicenow-mcp 2.2.0-dev.4 → 2.2.0-dev.6

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.
Files changed (40) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/dist/command-resolution.d.ts +53 -0
  3. package/dist/command-resolution.d.ts.map +1 -0
  4. package/dist/command-resolution.js +154 -0
  5. package/dist/command-resolution.js.map +1 -0
  6. package/dist/profile-admin.d.ts.map +1 -1
  7. package/dist/profile-admin.js +3 -0
  8. package/dist/profile-admin.js.map +1 -1
  9. package/dist/profile-manager.d.ts +10 -0
  10. package/dist/profile-manager.d.ts.map +1 -1
  11. package/dist/profile-manager.js +32 -3
  12. package/dist/profile-manager.js.map +1 -1
  13. package/dist/server.d.ts.map +1 -1
  14. package/dist/server.js +53 -0
  15. package/dist/server.js.map +1 -1
  16. package/dist/setup.d.ts +7 -0
  17. package/dist/setup.d.ts.map +1 -1
  18. package/dist/setup.js +193 -54
  19. package/dist/setup.js.map +1 -1
  20. package/dist/tools/atf-contracts.d.ts +221 -3
  21. package/dist/tools/atf-contracts.d.ts.map +1 -1
  22. package/dist/tools/atf-contracts.js +6 -3
  23. package/dist/tools/atf-contracts.js.map +1 -1
  24. package/dist/tools/atf-renderers.d.ts.map +1 -1
  25. package/dist/tools/atf-renderers.js +8 -2
  26. package/dist/tools/atf-renderers.js.map +1 -1
  27. package/dist/tools/atf-results-module.d.ts.map +1 -1
  28. package/dist/tools/atf-results-module.js +31 -2
  29. package/dist/tools/atf-results-module.js.map +1 -1
  30. package/dist/tools/atf-shared.d.ts +5 -2
  31. package/dist/tools/atf-shared.d.ts.map +1 -1
  32. package/dist/tools/atf-shared.js +32 -18
  33. package/dist/tools/atf-shared.js.map +1 -1
  34. package/dist/tools/result-envelope.d.ts +234 -19
  35. package/dist/tools/result-envelope.d.ts.map +1 -1
  36. package/dist/tools/syslog.d.ts +2 -2
  37. package/dist/version.d.ts +1 -1
  38. package/dist/version.js +1 -1
  39. package/docs/ATF-WORKFLOW.md +34 -4
  40. package/package.json +2 -1
package/dist/server.js CHANGED
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createMcpServer = createMcpServer;
4
4
  const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
5
+ const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
5
6
  const version_js_1 = require("./version.js");
6
7
  const REGISTRAR_CONNECTED_MESSAGE = "McpServer registrar must not connect the server during construction";
7
8
  /** Build a runtime view that exposes registration but no lifecycle controls. */
@@ -19,6 +20,56 @@ function createRegistrationSurface(server) {
19
20
  registerTool: server.registerTool.bind(server),
20
21
  });
21
22
  }
23
+ /**
24
+ * Serve every tool schema without a `$schema` dialect declaration.
25
+ *
26
+ * The SDK converts zod schemas with zod-to-json-schema, which stamps each one
27
+ * `"$schema": "http://json-schema.org/draft-07/schema#"`. Clients built on the
28
+ * current MCP spec validate with a JSON Schema 2020-12 validator and refuse a
29
+ * schema that names draft-07, which disabled every tool (SNSDK-86). With no
30
+ * declaration, those clients read a schema as 2020-12 and older ones read it
31
+ * as draft-07. Ours use only keywords that mean the same in both, and a
32
+ * contract test holds them to that. Declaring 2020-12 instead would break the
33
+ * older clients.
34
+ *
35
+ * The SDK installs its tools/list handler through `setRequestHandler` when the
36
+ * first tool is registered, so the handler is wrapped as it is installed; no
37
+ * SDK internals are read.
38
+ */
39
+ function serveDialectNeutralToolSchemas(server) {
40
+ const lowLevel = server.server;
41
+ const install = lowLevel.setRequestHandler.bind(lowLevel);
42
+ const setRequestHandler = (requestSchema, handler) => {
43
+ // Identity against the SDK's own schema object, the one McpServer passes.
44
+ if (requestSchema !== types_js_1.ListToolsRequestSchema) {
45
+ install(requestSchema, handler);
46
+ return;
47
+ }
48
+ install(requestSchema, async (request, extra) => withoutSchemaDialects(await handler(request, extra)));
49
+ };
50
+ lowLevel.setRequestHandler = setRequestHandler;
51
+ }
52
+ function withoutSchemaDialects(result) {
53
+ if (!("tools" in result) || !Array.isArray(result.tools))
54
+ return result;
55
+ return {
56
+ ...result,
57
+ tools: result.tools.map((tool) => ({
58
+ ...tool,
59
+ inputSchema: withoutDialect(tool.inputSchema),
60
+ ...(tool.outputSchema === undefined
61
+ ? {}
62
+ : { outputSchema: withoutDialect(tool.outputSchema) }),
63
+ })),
64
+ };
65
+ }
66
+ function withoutDialect(schema) {
67
+ if (!Object.hasOwn(schema, "$schema"))
68
+ return schema;
69
+ const copy = { ...schema };
70
+ delete copy.$schema;
71
+ return copy;
72
+ }
22
73
  /** Close a connected construction candidate and verify that it disconnected. */
23
74
  async function closeConnectedCandidate(server) {
24
75
  await server.close();
@@ -43,6 +94,8 @@ async function createMcpServer(options) {
43
94
  prompts: {},
44
95
  },
45
96
  });
97
+ // Before registration: the SDK installs tools/list on the first registerTool.
98
+ serveDialectNeutralToolSchemas(server);
46
99
  const registrationSurface = createRegistrationSurface(server);
47
100
  try {
48
101
  await options.register(registrationSurface, options.dependencies);
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";;AA4EA,0CA+CC;AA3HD,oEAAoE;AAEpE,6CAAuC;AAmCvC,MAAM,2BAA2B,GAC/B,qEAAqE,CAAC;AAExE,gFAAgF;AAChF,SAAS,yBAAyB,CAAC,MAAiB;IAClD,2EAA2E;IAC3E,+EAA+E;IAC/E,MAAM,eAAe,GAAmC,MAAM,CAAC,MAAM,CAAC;QACpE,oBAAoB,EAAE,MAAM,CAAC,MAAM,CAAC,oBAAoB,CAAC,IAAI,CAC3D,MAAM,CAAC,MAAM,CACiC;QAChD,iBAAiB,EAAE,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAC,IAAI,CACrD,MAAM,CAAC,MAAM,CAC8B;KAC9C,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,MAAM,EAAE,eAAe;QACvB,cAAc,EAAE,MAAM,CAAC,c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AC;QAClE,IAAI,CAAC;YACH,MAAM,uBAAuB,CAAC,MAAM,CAAC,CAAC;QACxC,CAAC;QAAC,OAAO,YAAY,EAAE,CAAC;YACtB,MAAM,IAAI,cAAc,CACtB,CAAC,cAAc,EAAE,YAAY,CAAC,EAC9B,6DAA6D,CAC9D,CAAC;QACJ,CAAC;QACD,MAAM,cAAc,CAAC;IACvB,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
package/dist/setup.d.ts CHANGED
@@ -33,6 +33,13 @@ export interface SetupCliDependencies {
33
33
  readonly writeStderr?: (value: string) => void;
34
34
  readonly commandExists?: (command: string) => boolean;
35
35
  readonly runCommand?: (command: string, args: readonly string[], env: NodeJS.ProcessEnv) => CommandResult;
36
+ /**
37
+ * Injected for tests; defaults to `process.platform`. Decides the command
38
+ * clients are registered to launch, and what doctor checks for it.
39
+ */
40
+ readonly platform?: NodeJS.Platform;
41
+ /** Injected for tests; defaults to this package's own `dist/index.js`. */
42
+ readonly serverEntrypoint?: string;
36
43
  /** Injected for tests; defaults to the real profile store under `home`. */
37
44
  readonly profileManager?: ProfileManager;
38
45
  /** Injected for tests; defaults to a readline/TTY prompter. */
@@ -1 +1 @@
1
- {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAkBH,OAAO,KAAK,EAAuB,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,EAQL,KAAK,cAAc,EACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAGL,KAAK,4BAA4B,EAElC,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,cAAc,EAIf,MAAM,sBAAsB,CAAC;AAQ9B,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACjC,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAA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e;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,UAAU,CAAC;IAClC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,WAAW,CAAC;IACpC,QAAQ,CAAC,QAAQ,CAAC,EAAE,cAAc,CAAC;CACpC;AAyBD,2EAA2E;AAC3E,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,eAAe,GAAG,cAAc,CAmD1E;AAiBD,sEAAsE;AACtE,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,GAAG,MAAM,GAAG,SAAS,CAWrF"}
package/dist/setup.js CHANGED
@@ -36,6 +36,7 @@ const node_path_1 = require("node:path");
36
36
  const node_child_process_1 = require("node:child_process");
37
37
  const promises_1 = require("node:readline/promises");
38
38
  const client_js_1 = require("./client.js");
39
+ const command_resolution_js_1 = require("./command-resolution.js");
39
40
  const profile_admin_js_1 = require("./profile-admin.js");
40
41
  const profile_credentials_js_1 = require("./profile-credentials.js");
41
42
  const profile_manager_js_1 = require("./profile-manager.js");
@@ -188,13 +189,18 @@ async function runWizard(options, home, env, dependencies, out) {
188
189
  // was generated now or loaded from an earlier bootstrap. Bound and
189
190
  // validated here so a corrupt key fails before anything is prompted for.
190
191
  const keyProvider = dependencies.keyProvider ?? (0, profile_credentials_js_1.encryptionKeyProviderFromValue)(values[ENCRYPTION_KEY_ENV]);
192
+ // Which client CLIs are installed, said before anything is asked, so an
193
+ // operator without one learns it now rather than after the credential.
194
+ const clientContext = registrationContext(dependencies, env, home);
195
+ const clis = locateClientClis(clientContext);
196
+ prompter.note(renderClientCliNote(clis));
191
197
  // 2. Re-run safety: never clobber an existing profile without being told.
192
198
  const existing = existingProfileNames(manager);
193
199
  if (existing.length > 0) {
194
200
  prompter.note(`Existing profiles: ${existing.join(", ")}\n`);
195
201
  const choice = await prompter.ask("Add another profile, or just re-register MCP clients?", { default: "profile", choices: ["profile", "clients"] });
196
202
  if (choice === "clients") {
197
- const only = await registerClientsInteractively(prompter, options, env, dependencies);
203
+ const only = await registerClientsInteractively(prompter, options, clis, clientContext);
198
204
  out(renderClientOnlySummary(only, home));
199
205
  return;
200
206
  }
@@ -294,7 +300,7 @@ async function runWizard(options, home, env, dependencies, out) {
294
300
  }
295
301
  prompter.note(`\nWrote profile ${name}.\n${JSON.stringify((0, profile_admin_js_1.safeProfileView)(name, profile), null, 2)}\n`);
296
302
  // 7. Client configuration.
297
- const registered = await registerClientsInteractively(prompter, options, env, dependencies);
303
+ const registered = await registerClientsInteractively(prompter, options, clis, clientContext);
298
304
  // 8. Verify the install the way `doctor` does, so setup ends by reporting
299
305
  // the same facts rather than commands for the operator to copy. There
300
306
  // is nothing to start: a registered client spawns the server itself.
@@ -330,19 +336,36 @@ function existingProfileNames(manager) {
330
336
  }
331
337
  }
332
338
  async function askProfileName(prompter, existing) {
333
- return prompter.ask("Profile name", {
339
+ return prompter.ask("Profile name (letters, digits, . _ -; no spaces)", {
334
340
  default: existing.includes("dev") ? "" : "dev",
341
+ // The store's own rule, checked here so an unusable name is refused before
342
+ // the credential is typed and verified, not at the final save. The answer
343
+ // is checked exactly as it will be saved, so anything accepted can be.
335
344
  validate: (value) => {
336
- const name = value.trim();
337
- if (name === "")
338
- return "A profile name is required.";
339
- if (existing.includes(name)) {
340
- return `Profile "${name}" already exists. Choose another name, or remove it with servicenow-mcp-profile remove --name ${name}.`;
345
+ const problem = (0, profile_manager_js_1.profileNameProblem)(value);
346
+ if (problem !== undefined) {
347
+ const suggestion = suggestProfileName(value);
348
+ return suggestion !== undefined && !existing.includes(suggestion)
349
+ ? `${problem} Try "${suggestion}".`
350
+ : problem;
351
+ }
352
+ if (existing.includes(value)) {
353
+ return `Profile "${value}" already exists. Choose another name, or remove it with servicenow-mcp-profile remove --name ${value}.`;
341
354
  }
342
355
  return undefined;
343
356
  },
344
357
  });
345
358
  }
359
+ /** The nearest valid name to one that was refused, such as `my-dev` for `my dev`. */
360
+ function suggestProfileName(value) {
361
+ const candidate = value
362
+ .trim()
363
+ .replace(/\s+/gu, "-")
364
+ .replace(/[^A-Za-z0-9._-]/gu, "")
365
+ .replace(/^[.-]+/u, "")
366
+ .slice(0, 64);
367
+ return (0, profile_manager_js_1.profileNameProblem)(candidate) === undefined ? candidate : undefined;
368
+ }
346
369
  const SERVICENOW_SUFFIXES = Object.freeze([".service-now.com", ".servicenowservices.com"]);
347
370
  async function askInstance(prompter) {
348
371
  const answer = await prompter.ask("ServiceNow instance (for example dev12345.service-now.com)", { validate: instanceProblem });
@@ -624,26 +647,48 @@ async function defaultParentTable(config, table) {
624
647
  const normalized = parent.trim().toLowerCase();
625
648
  return TABLE_NAME.test(normalized) ? normalized : undefined;
626
649
  }
627
- async function registerClientsInteractively(prompter, options, env, dependencies) {
628
- const commandExists = dependencies.commandExists ?? defaultCommandExists;
629
- const runCommand = dependencies.runCommand ?? defaultRunCommand;
630
- const available = AUTO_REGISTERED_CLIENTS.filter((client) => commandExists(client === "codex" ? "codex" : "claude"));
631
- if (available.length === 0)
650
+ async function registerClientsInteractively(prompter, options, clis, context) {
651
+ if (clis.length === 0) {
652
+ // Without this, the summary's "(none registered)" is the only sign, and it
653
+ // does not say that no client CLI was found to register with.
654
+ prompter.note("\nNo Claude Code (claude) or Codex (codex) CLI was found, so no client\n" +
655
+ "was registered automatically.");
632
656
  return Object.freeze([]);
633
- if (!(await prompter.confirm(`\nRegister this server with ${available.join(" and ")}?`, true))) {
657
+ }
658
+ if (!(await prompter.confirm(`\nRegister this server with ${clis.map((cli) => cli.client).join(" and ")}?`, true))) {
634
659
  return Object.freeze([]);
635
660
  }
636
- const context = { commandExists, runCommand, env };
637
661
  const configured = [];
638
- for (const client of available) {
639
- const result = registerClient(client, options.force, context);
662
+ for (const cli of clis) {
663
+ const result = registerClient(cli, options.force, context);
640
664
  if (result.ok)
641
- configured.push(client);
665
+ configured.push(cli.client);
642
666
  else
643
- prompter.note(` skipped ${client}: ${result.reason}`);
667
+ prompter.note(` skipped ${cli.client}: ${result.reason}`);
644
668
  }
645
669
  return Object.freeze(configured);
646
670
  }
671
+ /**
672
+ * Say up front which clients setup can register with, before the operator
673
+ * spends time on a credential. With none, they can stop and install Claude
674
+ * Code first, or know that the client is theirs to configure afterwards.
675
+ */
676
+ function renderClientCliNote(clis) {
677
+ if (clis.length === 0) {
678
+ return ("No Claude Code (claude) or Codex (codex) CLI was found, so setup cannot\n" +
679
+ "register this server with a client for you. It will still create and\n" +
680
+ "verify your profile. Afterwards, either install Claude Code and run\n" +
681
+ 'servicenow-mcp-setup again (choose "clients"), or configure your client\n' +
682
+ "by hand: servicenow-mcp-setup client\n");
683
+ }
684
+ const lines = clis.map((cli) => cli.offPath
685
+ ? `Found ${CLIENT_CLI_LABELS[cli.client]} at ${cli.command},\n` +
686
+ "but its folder is not on this terminal's PATH. Setup will run it from\n" +
687
+ `there. To run ${clientBinary(cli.client)} yourself, open a new terminal; if it is\n` +
688
+ `still not recognized, add ${(0, node_path_1.dirname)(cli.command)} to your PATH.`
689
+ : `Found ${CLIENT_CLI_LABELS[cli.client]}.`);
690
+ return `${lines.join("\n")}\n`;
691
+ }
647
692
  function renderWizardSummary(profile, tableAccess, registered, home, checks) {
648
693
  const failed = checks.filter((check) => !check.ok).length;
649
694
  const lines = [
@@ -792,8 +837,7 @@ async function runInit(options, home, env, dependencies, out, err) {
792
837
  }
793
838
  const values = loadOrCreateBootstrapValues(paths, options);
794
839
  writeSecureEnvFile(paths.serverEnv, values);
795
- const commandExists = dependencies.commandExists ?? defaultCommandExists;
796
- const runCommand = dependencies.runCommand ?? defaultRunCommand;
840
+ const context = registrationContext(dependencies, env, home);
797
841
  const configuredClients = [];
798
842
  const skippedClients = [];
799
843
  for (const client of options.clients) {
@@ -801,11 +845,12 @@ async function runInit(options, home, env, dependencies, out, err) {
801
845
  skippedClients.push(`${client} (no CLI to register with)`);
802
846
  continue;
803
847
  }
804
- const registration = registerClient(client, options.force, {
805
- commandExists,
806
- runCommand,
807
- env,
808
- });
848
+ const cli = locateClientCli(client, context);
849
+ if (cli === undefined) {
850
+ skippedClients.push(`${client} (${clientBinary(client)} CLI not found)`);
851
+ continue;
852
+ }
853
+ const registration = registerClient(cli, options.force, context);
809
854
  if (registration.ok)
810
855
  configuredClients.push(client);
811
856
  else
@@ -838,6 +883,82 @@ async function runInit(options, home, env, dependencies, out, err) {
838
883
  err(`[servicenow-mcp] skipped client setup: ${skippedClients.join(", ")}\n`);
839
884
  }
840
885
  }
886
+ function registrationContext(dependencies, env, home) {
887
+ return Object.freeze({
888
+ commandExists: dependencies.commandExists ?? defaultCommandExists,
889
+ runCommand: dependencies.runCommand ?? defaultRunCommand,
890
+ env,
891
+ home,
892
+ platform: dependencies.platform ?? process.platform,
893
+ serverEntrypoint: dependencies.serverEntrypoint ?? defaultServerEntrypoint(),
894
+ });
895
+ }
896
+ const CLIENT_CLI_LABELS = Object.freeze({
897
+ codex: "Codex (codex)",
898
+ "claude-code": "Claude Code (claude)",
899
+ });
900
+ function clientBinary(client) {
901
+ return client === "codex" ? "codex" : "claude";
902
+ }
903
+ function locateClientClis(context) {
904
+ return Object.freeze(AUTO_REGISTERED_CLIENTS.map((client) => locateClientCli(client, context)).filter((cli) => cli !== undefined));
905
+ }
906
+ /**
907
+ * Find a client's CLI on PATH or, failing that, where its installer puts it.
908
+ *
909
+ * Installed but not on PATH is common on Windows: the Claude Code installer
910
+ * adds its folder to the user PATH, but a terminal opened before the install
911
+ * keeps the old PATH, so `claude` is not recognized there. Registering needs
912
+ * only the executable, not PATH, so setup runs it by full path instead of
913
+ * reporting it missing.
914
+ */
915
+ function locateClientCli(client, context) {
916
+ const binary = clientBinary(client);
917
+ if (context.commandExists(binary)) {
918
+ return Object.freeze({ client, command: binary, offPath: false });
919
+ }
920
+ const found = defaultInstallLocations(binary, context).find(isRegularFile);
921
+ return found === undefined
922
+ ? undefined
923
+ : Object.freeze({ client, command: found, offPath: true });
924
+ }
925
+ /**
926
+ * Where each CLI's documented installers put it
927
+ * (https://code.claude.com/docs/en/troubleshoot-install). WinGet and Homebrew
928
+ * installs are left out: their paths are not documented, and they normally
929
+ * land on PATH anyway.
930
+ */
931
+ function defaultInstallLocations(binary, context) {
932
+ const windows = context.platform === "win32";
933
+ // Claude Code installs under USERPROFILE, which HOME can differ from on
934
+ // Windows (Git Bash sets it), so check both.
935
+ const homes = [
936
+ ...new Set([context.home, windows ? context.env.USERPROFILE : undefined].filter((home) => Boolean(home))),
937
+ ];
938
+ const locations = [];
939
+ if (binary === "claude") {
940
+ for (const home of homes) {
941
+ // The native installer.
942
+ locations.push((0, node_path_1.join)(home, ".local", "bin", windows ? "claude.exe" : "claude"));
943
+ // The legacy local install older versions created.
944
+ if (!windows)
945
+ locations.push((0, node_path_1.join)(home, ".claude", "local", "claude"));
946
+ }
947
+ }
948
+ // npm's default global prefix on Windows, where `npm install -g` writes its
949
+ // .cmd shims: Codex always installs this way, and Claude Code can.
950
+ if (windows && context.env.APPDATA) {
951
+ locations.push((0, node_path_1.join)(context.env.APPDATA, "npm", `${binary}.cmd`));
952
+ }
953
+ return locations;
954
+ }
955
+ function isRegularFile(path) {
956
+ return (0, node_fs_1.statSync)(path, { throwIfNoEntry: false })?.isFile() ?? false;
957
+ }
958
+ /** The server entrypoint that ships beside this CLI in `dist`. */
959
+ function defaultServerEntrypoint() {
960
+ return (0, node_path_1.join)(__dirname, "index.js");
961
+ }
841
962
  /**
842
963
  * Resolve the command a client should spawn.
843
964
  *
@@ -847,25 +968,25 @@ async function runInit(options, home, env, dependencies, out, err) {
847
968
  * client's own PATH will not have — registering it anyway would produce a
848
969
  * client that fails to launch with nothing to point at. So fall back to this
849
970
  * CLI's own sibling entrypoint, which is unambiguous and always correct.
971
+ *
972
+ * Windows always gets the entrypoint. There, npm installs `servicenow-mcp` as
973
+ * a `.cmd` shim, and clients spawn stdio servers without a shell, which cannot
974
+ * run one, so the bare name fails to launch even when it is on PATH.
850
975
  */
851
- function resolveServerLaunch(commandExists) {
852
- if (commandExists(SERVER_COMMAND)) {
976
+ function resolveServerLaunch(context) {
977
+ if (context.platform !== "win32" && context.commandExists(SERVER_COMMAND)) {
853
978
  return Object.freeze({ command: SERVER_COMMAND, args: Object.freeze([]) });
854
979
  }
855
980
  return Object.freeze({
856
981
  command: process.execPath,
857
- args: Object.freeze([(0, node_path_1.join)(__dirname, "index.js")]),
982
+ args: Object.freeze([context.serverEntrypoint]),
858
983
  });
859
984
  }
860
- function registerClient(client, force, context) {
861
- const binary = client === "codex" ? "codex" : "claude";
862
- if (!context.commandExists(binary)) {
863
- return { ok: false, reason: `${binary} CLI not found` };
864
- }
865
- const launch = resolveServerLaunch(context.commandExists);
866
- const result = client === "codex"
867
- ? configureCodex(launch, force, context)
868
- : configureClaudeCode(launch, force, context);
985
+ function registerClient(cli, force, context) {
986
+ const launch = resolveServerLaunch(context);
987
+ const result = cli.client === "codex"
988
+ ? configureCodex(cli.command, launch, force, context)
989
+ : configureClaudeCode(cli.command, launch, force, context);
869
990
  if (result.status === 0)
870
991
  return { ok: true };
871
992
  return {
@@ -874,31 +995,31 @@ function registerClient(client, force, context) {
874
995
  };
875
996
  }
876
997
  /** `codex mcp add <name> -- <command> [args...]` registers a stdio server. */
877
- function configureCodex(launch, force, context) {
878
- const existing = context.runCommand("codex", ["mcp", "get", MCP_SERVER_NAME], context.env);
998
+ function configureCodex(codex, launch, force, context) {
999
+ const existing = context.runCommand(codex, ["mcp", "get", MCP_SERVER_NAME], context.env);
879
1000
  if (existing.status === 0) {
880
1001
  if (!force)
881
1002
  return Object.freeze({ status: 0 });
882
- const removed = context.runCommand("codex", ["mcp", "remove", MCP_SERVER_NAME], context.env);
1003
+ const removed = context.runCommand(codex, ["mcp", "remove", MCP_SERVER_NAME], context.env);
883
1004
  if (removed.status !== 0)
884
1005
  return removed;
885
1006
  }
886
- return context.runCommand("codex", ["mcp", "add", MCP_SERVER_NAME, "--", launch.command, ...launch.args], context.env);
1007
+ return context.runCommand(codex, ["mcp", "add", MCP_SERVER_NAME, "--", launch.command, ...launch.args], context.env);
887
1008
  }
888
1009
  /**
889
1010
  * `claude mcp add <name> -- <command> [args...]` registers a stdio server;
890
1011
  * stdio is the default transport, so `--transport` is deliberately omitted.
891
1012
  */
892
- function configureClaudeCode(launch, force, context) {
893
- const existing = context.runCommand("claude", ["mcp", "get", MCP_SERVER_NAME], context.env);
1013
+ function configureClaudeCode(claude, launch, force, context) {
1014
+ const existing = context.runCommand(claude, ["mcp", "get", MCP_SERVER_NAME], context.env);
894
1015
  if (existing.status === 0) {
895
1016
  if (!force)
896
1017
  return Object.freeze({ status: 0 });
897
- const removed = context.runCommand("claude", ["mcp", "remove", MCP_SERVER_NAME, "--scope", "user"], context.env);
1018
+ const removed = context.runCommand(claude, ["mcp", "remove", MCP_SERVER_NAME, "--scope", "user"], context.env);
898
1019
  if (removed.status !== 0)
899
1020
  return removed;
900
1021
  }
901
- return context.runCommand("claude", ["mcp", "add", "--scope", "user", MCP_SERVER_NAME, "--", launch.command, ...launch.args], context.env);
1022
+ return context.runCommand(claude, ["mcp", "add", "--scope", "user", MCP_SERVER_NAME, "--", launch.command, ...launch.args], context.env);
902
1023
  }
903
1024
  // ── client ─────────────────────────────────────────────────────────
904
1025
  function runClient(options, out) {
@@ -965,7 +1086,7 @@ function runGrant(options, home, dependencies, out) {
965
1086
  : (current.tableAccess ?? Object.freeze({}));
966
1087
  const ordinary = buildTableAccess(existing, options);
967
1088
  const tableAccess = options.atf
968
- ? buildTableAccess(ordinary, { ...options, read: ["sys_atf_test", "sys_atf_step", "sys_atf_step_config", "var_dictionary", "sys_variable_value", "sys_element_mapping"], write: ATF_AUTHOR_TABLES, tools: ["sn_atf_author"] })
1089
+ ? buildTableAccess(ordinary, { ...options, read: ["sys_atf_test_suite", "sys_atf_test", "sys_atf_step", "sys_atf_step_config", "var_dictionary", "sys_variable_value", "sys_element_mapping"], write: ATF_AUTHOR_TABLES, tools: ["sn_atf_author"] })
969
1090
  : ordinary;
970
1091
  if (options.dryRun) {
971
1092
  out(options.json
@@ -1085,9 +1206,30 @@ async function runDoctor(options, home, env, dependencies, out) {
1085
1206
  * PATH here is this shell's, which is the best available proxy. A GUI client
1086
1207
  * launched from the desktop may hold a different one, so the remedy names the
1087
1208
  * absolute-path registration that removes the question entirely.
1209
+ *
1210
+ * On Windows, clients are registered with node and the entrypoint by absolute
1211
+ * path, never the bare name (see `resolveServerLaunch`). PATH is irrelevant
1212
+ * there, so the check is that both files a client will launch exist.
1088
1213
  */
1089
1214
  function checkServerCommand(dependencies) {
1090
1215
  const name = "server command";
1216
+ const fallback = dependencies.serverEntrypoint ?? defaultServerEntrypoint();
1217
+ if ((dependencies.platform ?? process.platform) === "win32") {
1218
+ const missing = [process.execPath, fallback].filter((file) => !(0, node_fs_1.existsSync)(file));
1219
+ return missing.length === 0
1220
+ ? {
1221
+ name,
1222
+ ok: true,
1223
+ detail: `clients launch ${process.execPath} with ${fallback} over stdio`,
1224
+ }
1225
+ : {
1226
+ name,
1227
+ ok: false,
1228
+ detail: `${missing.join(" and ")} not found`,
1229
+ remedy: "Reinstall the package (npm i -g @onlyflows/servicenow-mcp), then run " +
1230
+ "servicenow-mcp-setup again from the new install.",
1231
+ };
1232
+ }
1091
1233
  const commandExists = dependencies.commandExists ?? defaultCommandExists;
1092
1234
  if (commandExists(SERVER_COMMAND)) {
1093
1235
  return {
@@ -1096,7 +1238,6 @@ function checkServerCommand(dependencies) {
1096
1238
  detail: `${SERVER_COMMAND} resolves on PATH; clients spawn it over stdio`,
1097
1239
  };
1098
1240
  }
1099
- const fallback = (0, node_path_1.join)(__dirname, "index.js");
1100
1241
  return {
1101
1242
  name,
1102
1243
  ok: false,
@@ -1683,17 +1824,15 @@ function unquoteShellValue(raw) {
1683
1824
  return raw;
1684
1825
  }
1685
1826
  function defaultCommandExists(command) {
1686
- const result = (0, node_child_process_1.spawnSync)("/bin/sh", ["-lc", `command -v ${shellQuote(command)}`], {
1687
- encoding: "utf8",
1688
- stdio: ["ignore", "pipe", "pipe"],
1689
- });
1690
- return result.status === 0;
1827
+ return (0, command_resolution_js_1.resolveCommand)(command) !== undefined;
1691
1828
  }
1692
1829
  function defaultRunCommand(command, args, env) {
1693
- const result = (0, node_child_process_1.spawnSync)(command, [...args], {
1830
+ const invocation = (0, command_resolution_js_1.commandInvocation)(command, args, { env });
1831
+ const result = (0, node_child_process_1.spawnSync)(invocation.command, [...invocation.args], {
1694
1832
  encoding: "utf8",
1695
1833
  env,
1696
1834
  stdio: ["ignore", "pipe", "pipe"],
1835
+ windowsVerbatimArguments: invocation.windowsVerbatimArguments,
1697
1836
  });
1698
1837
  return Object.freeze({
1699
1838
  status: result.status,