adsmarch-ads-mcp 0.1.5 → 0.1.7

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 +19 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adsmarch-ads-mcp",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
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
@@ -4,6 +4,7 @@ import { spawnSync } from 'node:child_process';
4
4
  import { loadEnvFile } from 'node:process';
5
5
  import { dirname, resolve } from 'node:path';
6
6
  import { fileURLToPath } from 'node:url';
7
+ import { createRequire } from 'node:module';
7
8
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
8
9
  import { AdsGateway, createServer } from './gateway.mjs';
9
10
 
@@ -82,8 +83,24 @@ if (selected.includes('google') && !existsSync(googleBinary) && process.env.ADS_
82
83
  if (run.error || run.status !== 0) console.error('[adsmarch-ads-mcp] Download failed. Run `npm run setup:google` or set ADS_PROVIDERS=meta to start without Google.');
83
84
  }
84
85
 
85
- // Meta adapter ships as a compiled npm dependency.
86
- const metaEntry = resolve(root, 'node_modules', '@mikusnuz', 'meta-ads-mcp', 'dist', 'index.js');
86
+ // Meta adapter ships as a compiled npm dependency. Resolve it through the
87
+ // Node module resolver so it works both when deps are installed inside the
88
+ // package (dev) and when npm hoists them to a parent node_modules (npx/global).
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).
92
+ let metaEntry;
93
+ try {
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
+ }
101
+ if (!metaEntry || !existsSync(metaEntry)) {
102
+ metaEntry = resolve(root, 'node_modules', '@mikusnuz', 'meta-ads-mcp', 'dist', 'index.js');
103
+ }
87
104
  const definitions = {
88
105
  google: { name: 'google', command: googleBinary, args: [], cwd: root, env: googleEnv },
89
106
  meta: { name: 'meta', command: process.execPath, args: [...(process.env.HTTPS_PROXY && process.allowedNodeEnvironmentFlags.has('--use-env-proxy') ? ['--use-env-proxy'] : []), metaEntry], cwd: root, env: envFor('META_') },