{"version":"2.1.309","anchor":"mcp-serve-sessionend-hooks-supplied-by-the-caller","canonical_anchor":"mcp-serve-sessionend-hooks-supplied-by-the-caller","heading":"mcp serve can run SessionEnd hooks sent by the program calling it","tier":"use","area":"MCP Serve","scope":"individual","heads_up":false,"url":"https:\/\/changelogs.core-directive.com\/v\/2.1.309\/e\/mcp-serve-sessionend-hooks-supplied-by-the-caller","release_url":"https:\/\/changelogs.core-directive.com\/v\/2.1.309","markdown":"### `mcp serve` can run SessionEnd hooks sent by the program calling it\n\nWhen Claude Code runs as an MCP server, the caller can now hand it SessionEnd hooks to run, up to 8 KiB, unless machine policy forbids it\n\n**What**\n\n`mcp serve` runs Claude Code as an MCP server, so another program can use it as a tool. A SessionEnd hook is a command that runs automatically when a session ends. The program calling `mcp serve` can now send a set of SessionEnd hooks along with its request, and Claude Code holds them to run when the session ends.\n\n- The hooks must fit in 8 KiB. If they are larger, or cannot be read, Claude Code logs a warning and holds no SessionEnd hook.\n\n- Claude Code refuses to run these hooks when this machine's policy would stop `claude` from starting.\n\n**Why**\n\nA program controlling Claude Code remotely can set up cleanup steps that run on this machine when the session ends, while machine policy still has the final say.\n\n- Area: MCP Serve\n- Tier: Use it now\n- Useful: 4\/5\n- Signal: 3\/5\n- Scope: individual\n- Heads-up: no"}