@electric-ax/agents-mcp 0.2.0 → 0.2.1

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/dist/index.cjs CHANGED
@@ -27,8 +27,8 @@ const __modelcontextprotocol_sdk_client_streamableHttp_js = __toESM(require("@mo
27
27
  const __modelcontextprotocol_sdk_client_stdio_js = __toESM(require("@modelcontextprotocol/sdk/client/stdio.js"));
28
28
  const node_fs_promises = __toESM(require("node:fs/promises"));
29
29
  const node_fs = __toESM(require("node:fs"));
30
- const node_child_process = __toESM(require("node:child_process"));
31
30
  const node_path = __toESM(require("node:path"));
31
+ const node_child_process = __toESM(require("node:child_process"));
32
32
 
33
33
  //#region src/tools.ts
34
34
  const MCP_TOOLS_SENTINEL = Symbol.for(`@electric-ax/agents-mcp/tools-sentinel`);
@@ -744,10 +744,22 @@ async function watchConfig(path$1, opts) {
744
744
  opts.onError?.(err);
745
745
  }
746
746
  };
747
- const watcher = node_fs.default.watch(path$1, () => {
747
+ const watchPath = node_path.default.resolve(path$1);
748
+ const watchParentPath = node_path.default.dirname(watchPath);
749
+ const watchFileName = node_path.default.basename(watchPath);
750
+ let watcher;
751
+ const onFileChanged = () => {
748
752
  if (timer) clearTimeout(timer);
749
753
  timer = setTimeout(reload, debounce);
750
- });
754
+ };
755
+ try {
756
+ watcher = node_fs.default.watch(watchPath, onFileChanged);
757
+ } catch (err) {
758
+ if (err.code !== `ENOENT`) throw err;
759
+ watcher = node_fs.default.watch(watchParentPath, (_event, filename) => {
760
+ if (filename === null || filename.toString() === watchFileName) onFileChanged();
761
+ });
762
+ }
751
763
  return () => {
752
764
  if (timer) clearTimeout(timer);
753
765
  watcher.close();
package/dist/index.js CHANGED
@@ -3,8 +3,8 @@ import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/
3
3
  import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
4
4
  import fs from "node:fs/promises";
5
5
  import fs$1 from "node:fs";
6
+ import pathModule from "node:path";
6
7
  import { spawn } from "node:child_process";
7
- import path from "node:path";
8
8
 
9
9
  //#region src/tools.ts
10
10
  const MCP_TOOLS_SENTINEL = Symbol.for(`@electric-ax/agents-mcp/tools-sentinel`);
@@ -694,8 +694,8 @@ function parseConfig(raw, env = process.env) {
694
694
  raw
695
695
  };
696
696
  }
697
- async function loadConfig(path$1, env = process.env) {
698
- const text = await fs.readFile(path$1, `utf-8`);
697
+ async function loadConfig(path, env = process.env) {
698
+ const text = await fs.readFile(path, `utf-8`);
699
699
  return parseConfig(JSON.parse(text), env);
700
700
  }
701
701
 
@@ -709,21 +709,33 @@ async function loadConfig(path$1, env = process.env) {
709
709
  * subscription so the caller can fully await its first apply before
710
710
  * subsequent change events start firing.
711
711
  */
712
- async function watchConfig(path$1, opts) {
712
+ async function watchConfig(path, opts) {
713
713
  const debounce = opts.debounceMs ?? 200;
714
714
  let timer;
715
715
  const reload = async () => {
716
716
  try {
717
- const cfg = await loadConfig(path$1, opts.env);
717
+ const cfg = await loadConfig(path, opts.env);
718
718
  opts.onChange(cfg);
719
719
  } catch (err) {
720
720
  opts.onError?.(err);
721
721
  }
722
722
  };
723
- const watcher = fs$1.watch(path$1, () => {
723
+ const watchPath = pathModule.resolve(path);
724
+ const watchParentPath = pathModule.dirname(watchPath);
725
+ const watchFileName = pathModule.basename(watchPath);
726
+ let watcher;
727
+ const onFileChanged = () => {
724
728
  if (timer) clearTimeout(timer);
725
729
  timer = setTimeout(reload, debounce);
726
- });
730
+ };
731
+ try {
732
+ watcher = fs$1.watch(watchPath, onFileChanged);
733
+ } catch (err) {
734
+ if (err.code !== `ENOENT`) throw err;
735
+ watcher = fs$1.watch(watchParentPath, (_event, filename) => {
736
+ if (filename === null || filename.toString() === watchFileName) onFileChanged();
737
+ });
738
+ }
727
739
  return () => {
728
740
  if (timer) clearTimeout(timer);
729
741
  watcher.close();
@@ -1083,7 +1095,7 @@ async function readSafe(file) {
1083
1095
  }
1084
1096
  }
1085
1097
  async function writeSafe(file, data) {
1086
- await fs.mkdir(path.dirname(file), { recursive: true });
1098
+ await fs.mkdir(pathModule.dirname(file), { recursive: true });
1087
1099
  const tmp = `${file}.tmp`;
1088
1100
  await fs.writeFile(tmp, JSON.stringify(data, null, 2), { mode: 384 });
1089
1101
  await fs.rename(tmp, file);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@electric-ax/agents-mcp",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Model Context Protocol registry, transports, and OAuth bridges for Electric Agents",
5
5
  "keywords": [
6
6
  "mcp",