@rishibhushan/jenkins-mcp-server 1.1.9 → 1.1.11

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