{"version":"2.1.287","anchor":"commands-changed-emission-deduplicated-and-deferrable-in-str","canonical_anchor":"commands-changed-emission-deduplicated-and-deferrable-in-str","heading":"SDK sessions send fewer duplicate command-list updates and close removed MCP servers","tier":"notice","area":"SDK","url":"https:\/\/changelogs.core-directive.com\/v\/2.1.287\/e\/commands-changed-emission-deduplicated-and-deferrable-in-str","release_url":"https:\/\/changelogs.core-directive.com\/v\/2.1.287","markdown":"### SDK sessions send fewer duplicate command-list updates and close removed MCP servers\n\nIn stream-json mode commands_changed is sent only when the command list changes, and SDK MCP servers are closed on removal, replacement or disable\n\n**Unclear.** What causes the message to be held back is not known.\n\n**What**\n\nThese changes affect headless sessions, where a program drives Claude Code through the SDK using the `stream-json` output mode instead of the interactive screen:\n\n- `commands_changed`: this system message is now sent only when the list of commands differs from the last one sent. Before, it was sent on every state change. Updates that arrive while a hold is active are deferred and replayed afterwards, and command reloads are tracked as a single in-progress task.\n\n- SDK MCP servers: MCP servers are add-on tool providers. Headless sessions now keep a record of their SDK MCP connections and close them when a server is removed, replaced, or switched off with `mcp_toggle`. Before, only the connected client was cleaned up, and only on disable. If closing fails, the error \"Failed to close SDK MCP server after mcp_toggle disabled it\" is reported.\n\n**Why**\n\nPrograms built on the SDK receive fewer redundant command-list events, and removed or replaced MCP servers no longer leave connections open.\n\n- Area: SDK\n- Tier: You'll notice\n- Useful: 2\/5\n- Signal: 1\/5"}