par5-mcp 0.1.1 → 0.1.2

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.
@@ -1,3 +1,3 @@
1
1
  {
2
- ".": "0.1.1"
2
+ ".": "0.1.2"
3
3
  }
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.1.2](https://github.com/jrandolf/par5-mcp/compare/v0.1.1...v0.1.2) (2025-12-30)
4
+
5
+
6
+ ### Features
7
+
8
+ * add process cleanup on shutdown to manage active child processes ([68cbbbe](https://github.com/jrandolf/par5-mcp/commit/68cbbbec5188d9caba55bf17f8aa6a022e70cc17))
9
+
3
10
  ## [0.1.1](https://github.com/jrandolf/par5-mcp/compare/v0.1.0...v0.1.1) (2025-12-30)
4
11
 
5
12
 
package/dist/index.js CHANGED
@@ -8,6 +8,29 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
8
8
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
9
9
  import generatePassphrase from "eff-diceware-passphrase";
10
10
  import { z } from "zod";
11
+ // Track all active child processes for cleanup on shutdown
12
+ const activeProcesses = new Set();
13
+ // Cleanup function to kill all active child processes
14
+ function cleanupProcesses() {
15
+ for (const child of activeProcesses) {
16
+ if (!child.killed) {
17
+ child.kill("SIGTERM");
18
+ }
19
+ }
20
+ activeProcesses.clear();
21
+ }
22
+ // Register shutdown handlers
23
+ process.on("SIGTERM", () => {
24
+ cleanupProcesses();
25
+ process.exit(0);
26
+ });
27
+ process.on("SIGINT", () => {
28
+ cleanupProcesses();
29
+ process.exit(0);
30
+ });
31
+ process.on("exit", () => {
32
+ cleanupProcesses();
33
+ });
11
34
  // Helper to create a safe filename from an item string
12
35
  function toSafeFilename(item) {
13
36
  // Get basename if it's a path
@@ -29,6 +52,8 @@ function runCommandToFiles(command, stdoutFile, stderrFile, options = {}) {
29
52
  const child = spawn("sh", ["-c", command], {
30
53
  stdio: ["ignore", "pipe", "pipe"],
31
54
  });
55
+ // Track the child process for cleanup on shutdown
56
+ activeProcesses.add(child);
32
57
  let timeoutId;
33
58
  if (options.timeout) {
34
59
  timeoutId = setTimeout(() => {
@@ -38,6 +63,7 @@ function runCommandToFiles(command, stdoutFile, stderrFile, options = {}) {
38
63
  child.stdout.pipe(stdoutStream);
39
64
  child.stderr.pipe(stderrStream);
40
65
  child.on("close", async () => {
66
+ activeProcesses.delete(child);
41
67
  if (timeoutId)
42
68
  clearTimeout(timeoutId);
43
69
  stdoutStream.end();
@@ -47,6 +73,7 @@ function runCommandToFiles(command, stdoutFile, stderrFile, options = {}) {
47
73
  resolve();
48
74
  });
49
75
  child.on("error", async (err) => {
76
+ activeProcesses.delete(child);
50
77
  if (timeoutId)
51
78
  clearTimeout(timeoutId);
52
79
  stderrStream.write(`\nERROR: ${err.message}\n`);
@@ -149,6 +176,8 @@ WORKFLOW:
149
176
  const child = spawn("sh", ["-c", command], {
150
177
  stdio: ["ignore", "pipe", "pipe"],
151
178
  });
179
+ // Track the child process for cleanup on shutdown
180
+ activeProcesses.add(child);
152
181
  let stdout = "";
153
182
  let stderr = "";
154
183
  child.stdout.on("data", (data) => {
@@ -158,6 +187,7 @@ WORKFLOW:
158
187
  stderr += data.toString();
159
188
  });
160
189
  child.on("close", (code) => {
190
+ activeProcesses.delete(child);
161
191
  if (code !== 0 && stderr) {
162
192
  resolve({
163
193
  content: [
@@ -198,6 +228,7 @@ WORKFLOW:
198
228
  });
199
229
  });
200
230
  child.on("error", (err) => {
231
+ activeProcesses.delete(child);
201
232
  resolve({
202
233
  content: [
203
234
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "par5-mcp",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "MCP server for parallel list operations - run shell commands and AI agents across lists in parallel",
5
5
  "main": "dist/index.js",
6
6
  "bin": {