devglow-mcp 1.0.1 → 1.0.3

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/build/index.js +37 -1
  2. package/package.json +1 -1
package/build/index.js CHANGED
@@ -14,6 +14,9 @@ import { loadProjects, loadAiProcesses, loadStatuses, loadExportedLogs, } from "
14
14
  import { startProject, stopProject, runProcess, stopProcess, exportLogs, } from "./deeplink.js";
15
15
  const __dirname = dirname(fileURLToPath(import.meta.url));
16
16
  const pkg = JSON.parse(readFileSync(join(__dirname, "..", "package.json"), "utf-8"));
17
+ // --- Orphan process prevention constants ---
18
+ const IDLE_TIMEOUT_MS = 30 * 60 * 1000; // 30 minutes
19
+ const IDLE_CHECK_INTERVAL_MS = 60 * 1000; // Check every 1 minute
17
20
  // --- Server factory ---
18
21
  // Each transport connection gets its own McpServer instance
19
22
  function createMcpServer() {
@@ -195,7 +198,7 @@ function createMcpServer() {
195
198
  title: "Run a new AI process",
196
199
  description: "Create and start a new temporary process. Shows in DevGlow's AI Processes section. User can later [keep] or [dismiss] it.",
197
200
  inputSchema: {
198
- name: z.string().describe("Display name for the process"),
201
+ name: z.string().describe("Display name for the process. Do NOT include port number in the name — use the port parameter instead."),
199
202
  path: z.string().describe("Working directory (supports ~/)"),
200
203
  command: z.string().describe("Shell command to execute"),
201
204
  port: z
@@ -383,6 +386,39 @@ async function main() {
383
386
  const transport = new StdioServerTransport();
384
387
  await mcpServer.connect(transport);
385
388
  console.error("devglow MCP server running on stdio");
389
+ // --- Orphan process prevention (stdio mode) ---
390
+ // When Claude Code exits abnormally, the npx → npm → node chain
391
+ // may not propagate stdin pipe close properly, leaving this process orphaned.
392
+ let lastActivityTime = Date.now();
393
+ let exiting = false;
394
+ let idleTimer;
395
+ function gracefulExit(reason) {
396
+ if (exiting)
397
+ return;
398
+ exiting = true;
399
+ console.error(`devglow-mcp: ${reason}, shutting down`);
400
+ clearInterval(idleTimer);
401
+ try {
402
+ mcpServer.close();
403
+ }
404
+ catch { }
405
+ process.exit(0);
406
+ }
407
+ // Track incoming messages for idle detection
408
+ process.stdin.on("data", () => {
409
+ lastActivityTime = Date.now();
410
+ });
411
+ // 1st defense: detect stdin pipe close (parent process gone)
412
+ process.stdin.resume();
413
+ process.stdin.on("end", () => gracefulExit("stdin ended"));
414
+ process.stdin.on("close", () => gracefulExit("stdin closed"));
415
+ // 2nd defense: idle timeout (no messages for 30 min)
416
+ idleTimer = setInterval(() => {
417
+ if (Date.now() - lastActivityTime >= IDLE_TIMEOUT_MS) {
418
+ gracefulExit(`idle timeout (${IDLE_TIMEOUT_MS / 60_000}m)`);
419
+ }
420
+ }, IDLE_CHECK_INTERVAL_MS);
421
+ idleTimer.unref();
386
422
  }
387
423
  }
388
424
  const MAX_BODY_SIZE = 1024 * 1024; // 1MB
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "devglow-mcp",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "MCP server for DevGlow — manage local dev processes through AI agents",
5
5
  "type": "module",
6
6
  "bin": {