adsmarch-ads-mcp 0.1.6 → 0.1.8

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.mjs +11 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adsmarch-ads-mcp",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "AdsMarch unified Google Ads + Meta Ads MCP gateway for WorkBuddy connectors",
5
5
  "type": "module",
6
6
  "bin": {
package/src/index.mjs CHANGED
@@ -20,7 +20,7 @@ const bool = (key, fallback) => {
20
20
  if (!['true', 'false'].includes(raw)) throw new Error(`${key} must be true or false`);
21
21
  return raw === 'true';
22
22
  };
23
- const allowWrites = bool('ADS_ALLOW_WRITES', false);
23
+ const allowWrites = bool('ADS_ALLOW_WRITES', true);
24
24
  const selected = (value('ADS_PROVIDERS') || 'google,meta').split(',').map(x => x.trim());
25
25
  if (new Set(selected).size !== selected.length || selected.some(x => !['google', 'meta'].includes(x))) throw new Error('ADS_PROVIDERS must be google, meta, or google,meta');
26
26
  mkdirSync(resolve(root, 'logs'), { recursive: true });
@@ -86,11 +86,18 @@ if (selected.includes('google') && !existsSync(googleBinary) && process.env.ADS_
86
86
  // Meta adapter ships as a compiled npm dependency. Resolve it through the
87
87
  // Node module resolver so it works both when deps are installed inside the
88
88
  // package (dev) and when npm hoists them to a parent node_modules (npx/global).
89
- const requireFromHere = createRequire(import.meta.url);
89
+ // The upstream package only exposes an "import" condition in its exports map,
90
+ // so ESM import.meta.resolve is the primary strategy (require.resolve would
91
+ // throw ERR_PACKAGE_PATH_NOT_EXPORTED).
90
92
  let metaEntry;
91
93
  try {
92
- metaEntry = requireFromHere.resolve('@mikusnuz/meta-ads-mcp');
93
- } catch { /* exports map or resolution failure: fall back to the local path */ }
94
+ metaEntry = fileURLToPath(import.meta.resolve('@mikusnuz/meta-ads-mcp'));
95
+ } catch { /* ESM resolution failure: try CJS resolution, then local path */ }
96
+ if (!metaEntry || !existsSync(metaEntry)) {
97
+ try {
98
+ metaEntry = createRequire(import.meta.url).resolve('@mikusnuz/meta-ads-mcp');
99
+ } catch { /* exports map blocks the require condition: fall back */ }
100
+ }
94
101
  if (!metaEntry || !existsSync(metaEntry)) {
95
102
  metaEntry = resolve(root, 'node_modules', '@mikusnuz', 'meta-ads-mcp', 'dist', 'index.js');
96
103
  }