{"version":"2.1.321","anchor":"mcp-server-tool-server-garbage-collection-tuning-via-env-var","canonical_anchor":"mcp-server-tool-server-garbage-collection-tuning-via-env-var","heading":"New setting tunes memory cleanup for claude mcp serve","tier":"use","area":"MCP","scope":"individual","heads_up":false,"url":"https:\/\/changelogs.core-directive.com\/v\/2.1.321\/e\/mcp-server-tool-server-garbage-collection-tuning-via-env-var","release_url":"https:\/\/changelogs.core-directive.com\/v\/2.1.321","markdown":"### New setting tunes memory cleanup for claude mcp serve\n\nCLAUDE_CODE_MCP_SERVE_GARBAGE_COLLECTIONS controls when mcp serve frees unused memory, and slow cleanups switch it off\n\n**Unclear.** It is unclear whether the default cleanup schedule applies when the variable is not set.\n\n**What**\n\n`mcp serve` runs Claude Code as an MCP server, so other programs can use its tools. A new environment variable, `CLAUDE_CODE_MCP_SERVE_GARBAGE_COLLECTIONS`, controls garbage collection there, which is the step that frees memory the program no longer uses. It takes comma-separated parts:\n\n- `first`: `listen`, `rest`, `skip` or `never`, for the first collection\n\n- `later`: `young` or `full`, for collections after that\n\n- `rest_delay_ms`: a delay in milliseconds\n\n- `min_growth_mib`: a minimum memory growth in MiB\n\n- `between_growth_mib`: memory growth in MiB between collections\n\nThe defaults are first `listen`, later `full`, 1500 ms, 16 MiB and 8 MiB, and they apply only when a built-in check that is on by default passes. If a collection blocks for more than 250 ms, Claude Code stops running further ones. This needs Bun's JavaScriptCore support.\n\n**Why**\n\nPeople running `mcp serve` for long stretches get a way to manage its memory use, with a safety stop if cleanup starts slowing the server down.\n\n- Area: MCP\n- Names: `claude mcp serve`\n- Tier: Use it now\n- Useful: 5\/5\n- Signal: 2\/5\n- Scope: individual\n- Heads-up: no"}