adsmarch-ads-mcp 0.1.5 → 0.1.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.
- package/package.json +1 -1
- package/src/index.mjs +12 -2
package/package.json
CHANGED
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,17 @@ 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
|
-
|
|
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
|
+
const requireFromHere = createRequire(import.meta.url);
|
|
90
|
+
let metaEntry;
|
|
91
|
+
try {
|
|
92
|
+
metaEntry = requireFromHere.resolve('@mikusnuz/meta-ads-mcp');
|
|
93
|
+
} catch { /* exports map or resolution failure: fall back to the local path */ }
|
|
94
|
+
if (!metaEntry || !existsSync(metaEntry)) {
|
|
95
|
+
metaEntry = resolve(root, 'node_modules', '@mikusnuz', 'meta-ads-mcp', 'dist', 'index.js');
|
|
96
|
+
}
|
|
87
97
|
const definitions = {
|
|
88
98
|
google: { name: 'google', command: googleBinary, args: [], cwd: root, env: googleEnv },
|
|
89
99
|
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_') },
|