{"slug": "why-my-mcp-server-kept-crashing-the-claude-desktop-app", "title": "Why my MCP server kept crashing the Claude Desktop app", "summary": "A developer's MCP server crashed the Claude Desktop app due to an out-of-memory error (Exit Code 137), caused by recursive fetching of Jira ticket dependencies and large payloads. After optimizing the fetch logic with a depth cap and queue-based approach, RAM usage dropped from 2.1 GB to 180 MB and stability improved from failing after 12 queries to handling 500+ queries. The developer advises treating AI-generated MCP servers as drafts and manually implementing caps and limits.", "body_md": "# Why my MCP server kept crashing the Claude Desktop app\n\n[Claude](/en/tags/claude/)Desktop, thinking it would be a quick afternoon project. I had the TypeScript code running fine in a standalone terminal, but the moment I linked it to the Claude config file, the whole desktop app started lagging.\n\nThen it happened.\n\n`Error: MCP server disconnected unexpectedly. Exit code 137`\n\nFor those who don't spend their weekends digging through logs, Exit Code 137 is the classic \"OOM\" (Out Of Memory) signal. The OS killed the process because it was eating RAM like it was free.\n\n### The blind spot in the local loop\n\nThe frustrating part? My local tests showed the server only used about 150MB. But in the Claude Desktop environment, it spiked to 2GB in under ten minutes. I was using a recursive function to fetch Jira ticket dependencies—a classic \"I'll just trust the API\" mistake. The AI was requesting nested child issues, which triggered more requests, which triggered more nesting.\n\nI tried to fix it by adding a simple depth limit to the recursion, but the crashes persisted. I suspected the way the [MCP](/en/tags/mcp/) server handles the JSON-RPC transport layer.\n\nI felt like I was screaming into a void until I hopped into a [Generative AI Forum](https://promptcube.io) thread where a few other devs were complaining about the exact same behavior with the `mcp-sdk`\n\n. One user pointed out that the current SDK version handles large context windows by caching previous responses in a way that doesn't always garbage collect efficiently when the server is hosted as a child process.\n\n### The actual fix and the benchmarks\n\nIt wasn't just the recursion; it was the payload size. I was sending the entire Jira ticket body—including massive comments and system logs—into the context.\n\nI rewrote the fetch logic to strip everything except the summary and the last three comments. I also switched from a recursive loop to a queue-based approach.\n\nHere is the snippet that actually stopped the bleeding:\n\n```\nasync function fetchTickets(ticketIds: string[], depth = 0) {\n  if (depth > 2) return []; // Hard cap to prevent OOM\n  \n  const results = await Promise.all(ticketIds.map(async (id) => {\n    const data = await jiraClient.getTicket(id);\n    return {\n      key: data.key,\n      summary: data.fields.summary,\n      // Strip the bloat\n      snippet: data.fields.description?.substring(0, 200) + \"...\" \n    };\n  }));\n  \n  return results;\n}\n```\n\nThe difference was immediate. I ran a benchmark on my local machine using `top`\n\nto monitor the process:\n\n| Version | Max RAM Usage | Response Time | Stability |\n\n| :--- | :--- | :--- | :--- |\n\n| Original (Recursive) | 2.1 GB | 1.2s (until crash) | Fails after 12 queries |\n\n| Optimized (Queue/Cap) | 180 MB | 0.8s | Stable for 500+ queries |\n\n### Why solo debugging is a trap\n\nI could have spent another three days guessing. That's the problem with the current state of AI coding tools; the tools ([Cursor](/en/tags/cursor/), Claude, Windsurf) are so fast at generating code that they often generate bugs faster than we can conceptually map the architecture. You get a working feature, but you don't get the \"tribal knowledge\" of why it might crash in a specific environment.\n\nFinding a community of people actually shipping things—not just people posting \"Top 10 Prompts\" lists—is the only way to stay sane. That's why I started spending more time in the [PromptCube homepage](/en/) circles. It's less about \"how to prompt\" and more about \"why is my agent looping on this specific API call?\"\n\n### Shifting the workflow\n\nThis mess taught me that my [Workflows](/en/category/workflows/) were too optimistic. I was relying on the AI to handle the edge cases of API pagination and memory management.\n\nNow, I treat AI-generated MCP servers as \"drafts.\" I don't trust the memory profile until I've manually implemented caps and limits. The AI is great at the boilerplate, but it's terrible at imagining a memory leak in a child process it can't see.\n\n### Finding a place to vent and solve\n\nMost AI discussions are too surface-level. They talk about \"productivity gains\" while ignoring the fact that the tool just hallucinated a library that doesn't exist. I need places where someone will tell me, \"Yeah, that's a known bug in the SDK, use this workaround,\" rather than \"Try asking the AI to fix it.\"\n\nIf you're hitting these same walls, check out the [Resources](/en/category/resources/) section in the community. There are actual logs and implementation patterns there that save you from the \"Exit Code 137\" nightmare.\n\nTo join the PromptCube community, you just need to sign up on the site. It's mostly developers who are tired of the hype and just want to know why their code isn't working. It's the difference between reading a manual and talking to the guy who actually built the machine.\n\n[Next Why specialized Vertical AI is actually just 90s software in a →](/en/threads/5693/)\n\n## All Replies （0）\n\nNo replies yet — be the first!", "url": "https://wpnews.pro/news/why-my-mcp-server-kept-crashing-the-claude-desktop-app", "canonical_source": "https://promptcube3.com/en/threads/5782/", "published_at": "2026-08-10 13:03:58+00:00", "updated_at": "2026-08-10 13:22:17.376274+00:00", "lang": "en", "topics": ["developer-tools", "ai-tools", "artificial-intelligence"], "entities": ["Claude Desktop", "MCP", "Jira", "PromptCube", "Cursor", "Windsurf"], "alternates": {"html": "https://wpnews.pro/news/why-my-mcp-server-kept-crashing-the-claude-desktop-app", "markdown": "https://wpnews.pro/news/why-my-mcp-server-kept-crashing-the-claude-desktop-app.md", "text": "https://wpnews.pro/news/why-my-mcp-server-kept-crashing-the-claude-desktop-app.txt", "jsonld": "https://wpnews.pro/news/why-my-mcp-server-kept-crashing-the-claude-desktop-app.jsonld"}}