@rishibhushan/jenkins-mcp-server 1.1.9 → 1.1.10

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/bin/jenkins-mcp.js +66 -72
  2. package/package.json +1 -1
@@ -28,87 +28,81 @@ const pythonPath = path.join(
28
28
  "python"
29
29
  );
30
30
 
31
- if (!fs.existsSync(pythonPath)) {
32
- console.error("[jenkins-mcp] Python venv not found, bootstrapping...");
33
-
34
- const bootstrap = spawn("python3", ["-m", "venv", ".venv"], {
35
- cwd: PACKAGE_ROOT,
36
- stdio: "inherit",
31
+ async function run(cmd, args, cwd) {
32
+ return new Promise((resolve, reject) => {
33
+ const p = spawn(cmd, args, { cwd, stdio: "inherit" });
34
+ p.on("exit", (code) =>
35
+ code === 0 ? resolve() : reject(new Error(`${cmd} failed`))
36
+ );
37
37
  });
38
+ }
38
39
 
39
- bootstrap.on("exit", (code) => {
40
- if (code !== 0) {
41
- console.error("[jenkins-mcp] Failed to create venv");
42
- process.exit(1);
43
- }
44
-
45
- const pip = path.join(PACKAGE_ROOT, ".venv", "bin", "pip");
46
-
47
- const install = spawn(pip, ["install", "-r", "requirements.txt"], {
48
- cwd: PACKAGE_ROOT,
49
- stdio: "inherit",
50
- });
40
+ async function ensureVenv() {
41
+ if (fs.existsSync(pythonPath)) {
42
+ return;
43
+ }
51
44
 
52
- install.on("exit", (pipCode) => {
53
- if (pipCode !== 0) {
54
- console.error("[jenkins-mcp] Failed to install dependencies");
55
- process.exit(1);
56
- }
45
+ console.error("[jenkins-mcp] Python venv not found, bootstrapping...");
57
46
 
58
- console.error("[jenkins-mcp] Bootstrap complete, restarting...");
47
+ await run("python3", ["-m", "venv", ".venv"], PACKAGE_ROOT);
59
48
 
60
- spawn(process.execPath, process.argv.slice(1), {
61
- stdio: "inherit",
62
- });
63
- process.exit(0);
64
- });
65
- });
49
+ const pip = path.join(PACKAGE_ROOT, ".venv", "bin", "pip");
50
+ await run(pip, ["install", "-r", "requirements.txt"], PACKAGE_ROOT);
66
51
 
67
- process.exit(0);
52
+ console.error("[jenkins-mcp] Bootstrap complete");
68
53
  }
69
54
 
70
- /**
71
- * Forward CLI arguments (e.g. --env-file ...)
72
- */
73
- const args = process.argv.slice(2);
74
-
75
- /**
76
- * Final Python command:
77
- * python -m jenkins_mcp_server <args>
78
- */
79
- const pythonArgs = [
80
- "-m",
81
- "jenkins_mcp_server",
82
- ...args,
83
- ];
55
+ (async () => {
56
+ try {
57
+ await ensureVenv();
58
+ } catch (err) {
59
+ console.error("[jenkins-mcp] Bootstrap failed:", err);
60
+ process.exit(1);
61
+ }
84
62
 
85
- console.error("[jenkins-mcp] Python:", pythonPath);
86
- console.error("[jenkins-mcp] Args:", pythonArgs.join(" "));
63
+ /**
64
+ * Forward CLI arguments (e.g. --env-file ...)
65
+ */
66
+ const args = process.argv.slice(2);
67
+
68
+ /**
69
+ * Final Python command:
70
+ * python -m jenkins_mcp_server <args>
71
+ */
72
+ const pythonArgs = [
73
+ "-m",
74
+ "jenkins_mcp_server",
75
+ ...args,
76
+ ];
77
+
78
+ console.error("[jenkins-mcp] Python:", pythonPath);
79
+ console.error("[jenkins-mcp] Args:", pythonArgs.join(" "));
80
+
81
+ /**
82
+ * Spawn Python MCP server
83
+ */
84
+ const child = spawn(pythonPath, pythonArgs, {
85
+ cwd: PACKAGE_ROOT, // 🔑 critical
86
+ env: {
87
+ ...process.env,
88
+ PYTHONPATH: path.join(PACKAGE_ROOT, "src"), // 🔑 critical
89
+ },
90
+ stdio: ["inherit", "inherit", "inherit"], // MCP stdio
91
+ });
87
92
 
88
- /**
89
- * Spawn Python MCP server
90
- */
91
- const child = spawn(pythonPath, pythonArgs, {
92
- cwd: PACKAGE_ROOT, // 🔑 critical
93
- env: {
94
- ...process.env,
95
- PYTHONPATH: path.join(PACKAGE_ROOT, "src"), // 🔑 critical
96
- },
97
- stdio: ["inherit", "inherit", "inherit"], // MCP stdio
98
- });
93
+ /**
94
+ * Propagate exit code
95
+ */
96
+ child.on("exit", (code, signal) => {
97
+ if (signal) {
98
+ console.error("[jenkins-mcp] exited due to signal:", signal);
99
+ process.exit(1);
100
+ }
101
+ process.exit(code ?? 0);
102
+ });
99
103
 
100
- /**
101
- * Propagate exit code
102
- */
103
- child.on("exit", (code, signal) => {
104
- if (signal) {
105
- console.error("[jenkins-mcp] exited due to signal:", signal);
104
+ child.on("error", (err) => {
105
+ console.error("[jenkins-mcp] failed to start:", err);
106
106
  process.exit(1);
107
- }
108
- process.exit(code ?? 0);
109
- });
110
-
111
- child.on("error", (err) => {
112
- console.error("[jenkins-mcp] failed to start:", err);
113
- process.exit(1);
114
- });
107
+ });
108
+ })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rishibhushan/jenkins-mcp-server",
3
- "version": "1.1.9",
3
+ "version": "1.1.10",
4
4
  "description": "AI-enabled Jenkins automation via Model Context Protocol (MCP)",
5
5
  "main": "bin/jenkins-mcp.js",
6
6
  "bin": {