@virsanghavi/axis-server 1.0.7 → 1.0.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.
- package/bin/cli.ts +47 -32
- package/dist/cli.js +13 -1
- package/package.json +1 -1
package/bin/cli.ts
CHANGED
|
@@ -16,45 +16,60 @@ program
|
|
|
16
16
|
.description("Start the Axis Shared Context MCP Server")
|
|
17
17
|
.version("1.0.0");
|
|
18
18
|
|
|
19
|
-
program
|
|
20
|
-
|
|
19
|
+
program
|
|
20
|
+
.argument('[root]', 'Project root directory (optional)')
|
|
21
|
+
.action((root) => {
|
|
22
|
+
console.error(chalk.bold.blue("Axis MCP Server Starting..."));
|
|
21
23
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
// If root is provided, change CWD
|
|
25
|
+
if (root) {
|
|
26
|
+
const resolvedRoot = path.resolve(root);
|
|
27
|
+
if (fs.existsSync(resolvedRoot)) {
|
|
28
|
+
console.error(chalk.blue(`Setting CWD to: ${resolvedRoot}`));
|
|
29
|
+
process.chdir(resolvedRoot);
|
|
30
|
+
} else {
|
|
31
|
+
console.error(chalk.red(`Error: Project root not found: ${resolvedRoot}`));
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
24
35
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
console.error(chalk.yellow(`Expected at: ${serverScript}`));
|
|
28
|
-
console.error(chalk.gray("Did you run 'npm run build'?"));
|
|
29
|
-
process.exit(1);
|
|
30
|
-
}
|
|
36
|
+
// Locate the bundled server script
|
|
37
|
+
const serverScript = path.resolve(__dirname, "../dist/mcp-server.mjs");
|
|
31
38
|
|
|
32
|
-
|
|
39
|
+
if (!fs.existsSync(serverScript)) {
|
|
40
|
+
console.error(chalk.red("Error: Server script not found."));
|
|
41
|
+
console.error(chalk.yellow(`Expected at: ${serverScript}`));
|
|
42
|
+
console.error(chalk.gray("Did you run 'npm run build'?"));
|
|
43
|
+
process.exit(1);
|
|
44
|
+
}
|
|
33
45
|
|
|
34
|
-
|
|
35
|
-
const args = [serverScript, ...process.argv.slice(2)];
|
|
46
|
+
console.error(chalk.gray(`Launching server context...`));
|
|
36
47
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
stdio: "inherit",
|
|
40
|
-
env: { ...process.env, FORCE_COLOR: '1' }
|
|
41
|
-
});
|
|
48
|
+
// Pass through all arguments from the CLI to the underlying server
|
|
49
|
+
const args = [serverScript, ...process.argv.slice(2)];
|
|
42
50
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
});
|
|
51
|
+
// Spawn the node process with the bundled script
|
|
52
|
+
const proc = spawn("node", args, {
|
|
53
|
+
stdio: "inherit",
|
|
54
|
+
cwd: process.cwd(), // Pass the CWD to the child process
|
|
55
|
+
env: { ...process.env, FORCE_COLOR: '1' }
|
|
56
|
+
});
|
|
50
57
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
58
|
+
proc.on("close", (code) => {
|
|
59
|
+
if (code !== 0) {
|
|
60
|
+
console.error(chalk.red(`Server process exited with code ${code}`));
|
|
61
|
+
} else {
|
|
62
|
+
console.error(chalk.green("Server stopped gracefully."));
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// Handle signals to cleanup child
|
|
67
|
+
process.on('SIGINT', () => {
|
|
68
|
+
proc.kill('SIGINT');
|
|
69
|
+
});
|
|
70
|
+
process.on('SIGTERM', () => {
|
|
71
|
+
proc.kill('SIGTERM');
|
|
72
|
+
});
|
|
57
73
|
});
|
|
58
|
-
});
|
|
59
74
|
|
|
60
75
|
program.parse();
|
package/dist/cli.js
CHANGED
|
@@ -37,8 +37,18 @@ var import_fs = __toESM(require("fs"));
|
|
|
37
37
|
var __filename2 = (0, import_url.fileURLToPath)(importMetaUrl);
|
|
38
38
|
var __dirname = import_path.default.dirname(__filename2);
|
|
39
39
|
import_commander.program.name("axis-server").description("Start the Axis Shared Context MCP Server").version("1.0.0");
|
|
40
|
-
import_commander.program.action(() => {
|
|
40
|
+
import_commander.program.argument("[root]", "Project root directory (optional)").action((root) => {
|
|
41
41
|
console.error(import_chalk.default.bold.blue("Axis MCP Server Starting..."));
|
|
42
|
+
if (root) {
|
|
43
|
+
const resolvedRoot = import_path.default.resolve(root);
|
|
44
|
+
if (import_fs.default.existsSync(resolvedRoot)) {
|
|
45
|
+
console.error(import_chalk.default.blue(`Setting CWD to: ${resolvedRoot}`));
|
|
46
|
+
process.chdir(resolvedRoot);
|
|
47
|
+
} else {
|
|
48
|
+
console.error(import_chalk.default.red(`Error: Project root not found: ${resolvedRoot}`));
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
42
52
|
const serverScript = import_path.default.resolve(__dirname, "../dist/mcp-server.mjs");
|
|
43
53
|
if (!import_fs.default.existsSync(serverScript)) {
|
|
44
54
|
console.error(import_chalk.default.red("Error: Server script not found."));
|
|
@@ -50,6 +60,8 @@ import_commander.program.action(() => {
|
|
|
50
60
|
const args = [serverScript, ...process.argv.slice(2)];
|
|
51
61
|
const proc = (0, import_child_process.spawn)("node", args, {
|
|
52
62
|
stdio: "inherit",
|
|
63
|
+
cwd: process.cwd(),
|
|
64
|
+
// Pass the CWD to the child process
|
|
53
65
|
env: { ...process.env, FORCE_COLOR: "1" }
|
|
54
66
|
});
|
|
55
67
|
proc.on("close", (code) => {
|