/add-dir does not send notifications/roots/list_changed to MCP servers
Description
/add-dir updates Claude Code's internal working directories but never sends notifications/roots/list_changed to connected MCP servers via the MCP protocol. MCP servers have no way to learn about directories added mid-session.
Steps to Reproduce
- Start Claude Code with an MCP server that uses workspace roots (e.g., for path validation)
/add-dir /some/other/directory- Observe that the MCP server never receives a
notifications/roots/list_changednotification - MCP server tools that validate paths against workspace roots reject paths in the newly added directory
Expected Behavior
After /add-dir, Claude Code should send notifications/roots/list_changed to all connected MCP servers that advertised roots capability, so they can call roots/list and update their internal state.
Actual Behavior
The MCP server's root list remains unchanged. Any path validation against workspace roots fails for the newly added directory.
Context
The MCP specification defines notifications/roots/list_changed (client → server) for exactly this purpose. Gemini CLI's equivalent (/dir add) correctly sends the notification.
Workaround
We implemented a PreToolUse hook that parses the Claude Code transcript JSONL for /add-dir confirmation messages and sends the new roots to the MCP server via an out-of-band channel. This works but is fragile and shouldn't be necessary.
Environment
- Claude Code v2.1.39
- MCP protocol version 2024-11-05
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗