Building an MCP Server for a Mostly-Closed Mac App: A Developer's Long Hardship Post
roaringfantong · reddit · 2026-11-03
The author maintains an Electron Mac app driven over MCP by Claude Desktop/Claude Code/Codex. The tricky part: MCP clients require a persistent stdio command, but the app is usually not running—so he wrote a stdio broker and hit a chain of pitfalls:- Using ELECTRONRUNASNODE=1 to reuse the app's bundled Electron runtime to run the broker, at just 12MB (an empty Electron is 45MB); paired with a 58KB Swift launcher that locates the runtime, avoiding 141MB from bundling Node.- Code signing modifies the binary so manifest checksums never match; he eventually dropped the checksum—macOS itself wraps the helper into the app's signature and verifies it at launch.- The broker's lifetime matches the client's (people never quit Claude Desktop), so a handshake is needed to detect stale brokers; version comparison falsely kills dev builds, so he switched to rejecting only when both "version + tool structure" change.- The broker keeping its own copy of tool schemas would silently drop new parameters after updates based on stale checksums; the fix was fetching the live tool list from the running app, letting the app validate parameters itself, and sending notifications/tools/listchanged on hash changes; the local fallback copy is used only when the app is closed.- Tasks longer than 45 seconds return a run id first, with results collected via a waitforrun tool, sidestepping Claude Desktop's 1-minute call timeout.- Handled edge cases like two app instances fighting over the socket and updates replacing the broker while the old app still runs; error messages were also changed from a raw client ID to "quit and reopen Claude".
More from coding & agent
- Reddit user shares Agent Router trick: $50 free credits pooling Claude, GPT, DeepSeek, GLM — RAFRAGE · 2026-11-03
- ComfyUI node expands prompts with a local LLM that offloads VRAM after each generation — ProcedureFit789 · 2026-11-03
- Grok Build ships major upgrade: duplicate MCP results fix cuts context usage roughly in half — elonmusk · 2026-11-03
- Microsoft Distinguished Engineer Stephen Toub rewrites 400KLOC Copilot runtime in Rust single-handedly — dfinke · 2026-11-03
- LongCat-2.5 vs Qwen3.8-Max: same browser game built for $0.28 vs $0.82 — omarsar0 · 2026-11-03
- Free 30-min lesson: check if your model's 0.8 really means 80% — bgoncalves · 2026-11-03