Title: MCP server processes orphaned when parent (Claude CLI) dies — 4GB memory leak · Issue #273 · getsentry/XcodeBuildMCP · GitHub
Open Graph Title: MCP server processes orphaned when parent (Claude CLI) dies — 4GB memory leak · Issue #273 · getsentry/XcodeBuildMCP
X Title: MCP server processes orphaned when parent (Claude CLI) dies — 4GB memory leak · Issue #273 · getsentry/XcodeBuildMCP
Description: Problem When XcodeBuildMCP is launched as an MCP server via npm exec xcodebuildmcp@latest mcp (as Claude Code does), the process persists indefinitely after the parent process exits. Each orphaned instance consumes up to 4GB of resident ...
Open Graph Description: Problem When XcodeBuildMCP is launched as an MCP server via npm exec xcodebuildmcp@latest mcp (as Claude Code does), the process persists indefinitely after the parent process exits. Each orphaned ...
X Description: Problem When XcodeBuildMCP is launched as an MCP server via npm exec xcodebuildmcp@latest mcp (as Claude Code does), the process persists indefinitely after the parent process exits. Each orphaned ...
Opengraph URL: https://github.com/getsentry/XcodeBuildMCP/issues/273
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"MCP server processes orphaned when parent (Claude CLI) dies — 4GB memory leak","articleBody":"## Problem\n\nWhen XcodeBuildMCP is launched as an MCP server via `npm exec xcodebuildmcp@latest mcp` (as Claude Code does), the process persists indefinitely after the parent process exits. Each orphaned instance consumes up to **4GB of resident memory**.\n\nThis is especially painful when running multiple Claude Code sessions — orphaned `xcodebuildmcp` processes accumulate and grind the system to a halt.\n\n```\n$ ps aux | grep xcodebuild\ndale 24113 352.3 23.5 450778096 3945760 ?? R 3:59PM 1:15.03 node ...xcodebuildmcp mcp\ndale 24114 0.0 0.3 446631664 48928 ?? S 3:59PM 0:00.84 node ...xcodebuildmcp mcp\ndale 24053 0.0 0.3 435888672 47712 ?? S 3:59PM 0:00.63 npm exec xcodebuildmcp@latest mcp\ndale 24052 0.0 0.3 435888944 47712 ?? S 3:59PM 0:00.64 npm exec xcodebuildmcp@latest mcp\n```\n\n## Root Cause\n\n`start-mcp-server.js` relies on `stdin` end/close events to detect parent death (lines 99–104). However, when spawned through `npm exec`, there's an intermediate node wrapper process. When the parent (Claude CLI) dies:\n\n1. The `npm exec` wrapper becomes orphaned (reparented to launchd/PID 1)\n2. The wrapper doesn't close its stdin pipe to the actual xcodebuildmcp process\n3. The MCP server never receives the stdin end/close event\n4. The process runs forever with no work to do\n\nAdditionally, unlike daemon mode (which has `idle-shutdown.js` with a 10-minute timeout), the MCP server mode has **no idle timeout at all**.\n\n## Suggested Fix\n\nAdd a parent-PID watchdog to `start-mcp-server.js`. When the parent process dies, macOS/Linux reparents the child to init/launchd (PID 1). Polling `process.ppid` detects this:\n\n```diff\n--- a/src/server/start-mcp-server.ts\n+++ b/src/server/start-mcp-server.ts\n@@ in startMcpServer(), after enrichSentryContext() and before shuttingDown declaration\n+ // Parent-process watchdog: detect orphaned process when parent dies.\n+ // When the parent (Claude CLI / npm exec) exits, the OS reparents us to\n+ // init/launchd (PID 1). Poll every 5s and shut down if that happens.\n+ const originalPpid = process.ppid;\n+ const ppidWatchdog = setInterval(() =\u003e {\n+ if (process.ppid !== originalPpid) {\n+ clearInterval(ppidWatchdog);\n+ log(\"info\", `Parent process died (was ${originalPpid}, now ${process.ppid}); shutting down`);\n+ void shutdown(\"parent-died\");\n+ }\n+ }, 5000);\n+ ppidWatchdog.unref(); // Don't keep the event loop alive just for this\n```\n\nThis is 8 lines, zero dependencies, works on macOS and Linux, and has no effect during normal operation.\n\n## Environment\n\n- macOS 15 (Darwin 25.3.0), Apple Silicon\n- XcodeBuildMCP 2.2.1\n- Claude Code 2.1.75 (VS Code extension)\n- Launched via: `npm exec xcodebuildmcp@latest mcp`\n\n🤖 Generated with [Claude Code](https://claude.com/claude-code)","author":{"url":"https://github.com/dalegass","@type":"Person","name":"dalegass"},"datePublished":"2026-03-14T01:30:19.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":7},"url":"https://github.com/273/XcodeBuildMCP/issues/273"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:eb3b1bd3-6bd6-273c-6ad0-901224c8c3d9 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | ED7C:1929FC:283C49F:3914E97:6A4CEE68 |
| html-safe-nonce | 75f4500de786df181d0343a7711e52876da28673326e2c45ac159ea8e0e6eb68 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFRDdDOjE5MjlGQzoyODNDNDlGOjM5MTRFOTc6NkE0Q0VFNjgiLCJ2aXNpdG9yX2lkIjoiMjIwOTk3MDYwNDk4NjkyMDU1MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | f423632b4814680ff2a9515ea68575390c2deffe124517dc150a571e4bbe6c18 |
| hovercard-subject-tag | issue:4074239881 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/XcodeBuildMCP/273/issue_layout |
| twitter:image | https://opengraph.githubassets.com/bb941b6245d673d8eb9311481f42056efe787b0a0481f506a1fdd1550f692311/getsentry/XcodeBuildMCP/issues/273 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/bb941b6245d673d8eb9311481f42056efe787b0a0481f506a1fdd1550f692311/getsentry/XcodeBuildMCP/issues/273 |
| og:image:alt | Problem When XcodeBuildMCP is launched as an MCP server via npm exec xcodebuildmcp@latest mcp (as Claude Code does), the process persists indefinitely after the parent process exits. Each orphaned ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dalegass |
| hostname | github.com |
| expected-hostname | github.com |
| None | 299b43bca6e02ad35197ffeba30d2466846d5fb02ab96fbced5b5e6cec589fb8 |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/XcodeBuildMCP git https://github.com/getsentry/XcodeBuildMCP.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 945551361 |
| octolytics-dimension-repository_nwo | getsentry/XcodeBuildMCP |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 945551361 |
| octolytics-dimension-repository_network_root_nwo | getsentry/XcodeBuildMCP |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | efec6750a5afcaeaf5dfcf629f404cf98c8371e3 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width