@raghulm/aegis-mcp 1.0.3 → 1.0.4

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.
@@ -3,21 +3,42 @@
3
3
 
4
4
  const crypto = require("crypto");
5
5
  const fs = require("fs");
6
+ const os = require("os");
6
7
  const path = require("path");
7
8
  const { spawnSync } = require("child_process");
8
9
 
9
10
  const PROJECT_ROOT = path.resolve(__dirname, "..");
10
11
  const REQUIREMENTS_FILE = path.join(PROJECT_ROOT, "requirements.txt");
11
- const VENV_DIR = path.join(PROJECT_ROOT, ".venv");
12
- const REQUIREMENTS_STAMP = path.join(VENV_DIR, ".requirements.sha256");
12
+ const RUNTIME_ROOT = process.env.AEGIS_HOME || path.join(os.homedir(), ".aegis-mcp");
13
+ const VENV_DIR = path.join(RUNTIME_ROOT, "venv");
14
+ const REQUIREMENTS_STAMP = path.join(RUNTIME_ROOT, ".requirements.sha256");
13
15
  const IS_WINDOWS = process.platform === "win32";
16
+ const DEBUG = process.env.AEGIS_DEBUG === "1";
14
17
 
15
18
  function run(command, args, options = {}) {
16
- return spawnSync(command, args, {
19
+ const result = spawnSync(command, args, {
17
20
  cwd: PROJECT_ROOT,
18
- stdio: "inherit",
21
+ encoding: "utf8",
22
+ stdio: ["ignore", "pipe", "pipe"],
19
23
  ...options
20
24
  });
25
+
26
+ if (DEBUG && result.stdout) {
27
+ process.stderr.write(result.stdout);
28
+ }
29
+ if (DEBUG && result.stderr) {
30
+ process.stderr.write(result.stderr);
31
+ }
32
+
33
+ return result;
34
+ }
35
+
36
+ function throwCommandError(result, contextMessage) {
37
+ const output = `${result?.stdout || ""}\n${result?.stderr || ""}`.trim();
38
+ if (output) {
39
+ process.stderr.write(`${output}\n`);
40
+ }
41
+ throw new Error(contextMessage);
21
42
  }
22
43
 
23
44
  function candidatePythonCommands() {
@@ -43,10 +64,7 @@ function candidatePythonCommands() {
43
64
 
44
65
  function findWorkingPython() {
45
66
  for (const candidate of candidatePythonCommands()) {
46
- const versionCheck = run(candidate.command, [...candidate.prefixArgs, "--version"], {
47
- stdio: "pipe",
48
- encoding: "utf8"
49
- });
67
+ const versionCheck = run(candidate.command, [...candidate.prefixArgs, "--version"]);
50
68
  if (versionCheck.status === 0) {
51
69
  return candidate;
52
70
  }
@@ -77,29 +95,44 @@ function requirementsHash() {
77
95
  }
78
96
 
79
97
  function ensureVirtualEnvironment(python) {
98
+ fs.mkdirSync(RUNTIME_ROOT, { recursive: true });
99
+
80
100
  const pythonInVenv = venvPythonPath();
81
101
  if (fs.existsSync(pythonInVenv)) {
82
102
  return;
83
103
  }
84
104
 
85
- console.error("[aegis-mcp] Creating Python virtual environment...");
86
105
  const created = run(python.command, [...python.prefixArgs, "-m", "venv", VENV_DIR]);
87
106
  if (created.status !== 0) {
88
- throw new Error("Failed to create Python virtual environment.");
107
+ throwCommandError(created, "Failed to create Python virtual environment.");
89
108
  }
90
109
  }
91
110
 
92
111
  function installDependencies(pythonInVenv) {
93
- console.error("[aegis-mcp] Installing Python dependencies from requirements.txt...");
94
-
95
- const pipUpgrade = run(pythonInVenv, ["-m", "pip", "install", "--upgrade", "pip"]);
112
+ const pipUpgrade = run(pythonInVenv, [
113
+ "-m",
114
+ "pip",
115
+ "install",
116
+ "--disable-pip-version-check",
117
+ "--quiet",
118
+ "--upgrade",
119
+ "pip"
120
+ ]);
96
121
  if (pipUpgrade.status !== 0) {
97
- throw new Error("Failed to upgrade pip in virtual environment.");
122
+ throwCommandError(pipUpgrade, "Failed to upgrade pip in virtual environment.");
98
123
  }
99
124
 
100
- const pipInstall = run(pythonInVenv, ["-m", "pip", "install", "-r", REQUIREMENTS_FILE]);
125
+ const pipInstall = run(pythonInVenv, [
126
+ "-m",
127
+ "pip",
128
+ "install",
129
+ "--disable-pip-version-check",
130
+ "--quiet",
131
+ "-r",
132
+ REQUIREMENTS_FILE
133
+ ]);
101
134
  if (pipInstall.status !== 0) {
102
- throw new Error("Failed to install Python dependencies.");
135
+ throwCommandError(pipInstall, "Failed to install Python dependencies.");
103
136
  }
104
137
  }
105
138
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raghulm/aegis-mcp",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "DevSecOps-focused MCP server for AWS, Kubernetes, CI/CD, and security tooling.",
5
5
  "license": "MIT",
6
6
  "author": "Raghul M",
@@ -46,5 +46,8 @@
46
46
  },
47
47
  "engines": {
48
48
  "node": ">=18"
49
+ },
50
+ "dependencies": {
51
+ "@raghulm/aegis-mcp": "^1.0.3"
49
52
  }
50
53
  }