diff --git a/typescript/packages/mcp/bin/x402-mcp.js b/typescript/packages/mcp/bin/x402-mcp.js index c3879222..7410c124 100755 --- a/typescript/packages/mcp/bin/x402-mcp.js +++ b/typescript/packages/mcp/bin/x402-mcp.js @@ -3,13 +3,16 @@ const { spawnSync } = require("node:child_process"); const path = require("node:path"); const entryPath = path.resolve(__dirname, "../src/command/mcp-server.ts"); +const packageRoot = path.resolve(__dirname, ".."); +const tsxLoaderPath = path.resolve(packageRoot, "node_modules/tsx/dist/loader.mjs"); const result = spawnSync( process.execPath, - ["--import", "tsx", entryPath, ...process.argv.slice(2)], + ["--import", tsxLoaderPath, entryPath, ...process.argv.slice(2)], { stdio: "inherit", env: process.env, + cwd: packageRoot, }, ); diff --git a/typescript/packages/mcp/bin/x402.js b/typescript/packages/mcp/bin/x402.js index 31ca36de..9853f5ee 100755 --- a/typescript/packages/mcp/bin/x402.js +++ b/typescript/packages/mcp/bin/x402.js @@ -3,11 +3,18 @@ const { spawnSync } = require("node:child_process"); const path = require("node:path"); const cliPath = path.resolve(__dirname, "../src/command/cli.ts"); +const packageRoot = path.resolve(__dirname, ".."); +const tsxLoaderPath = path.resolve(packageRoot, "node_modules/tsx/dist/loader.mjs"); -const result = spawnSync(process.execPath, ["--import", "tsx", cliPath, ...process.argv.slice(2)], { - stdio: "inherit", - env: process.env, -}); +const result = spawnSync( + process.execPath, + ["--import", tsxLoaderPath, cliPath, ...process.argv.slice(2)], + { + stdio: "inherit", + env: process.env, + cwd: packageRoot, + }, +); if (result.error) { throw result.error;