/add-dir does not send notifications/roots/list_changed to MCP servers

Resolved 💬 2 comments Opened Feb 18, 2026 by m-wells Closed Mar 19, 2026

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

  1. Start Claude Code with an MCP server that uses workspace roots (e.g., for path validation)
  2. /add-dir /some/other/directory
  3. Observe that the MCP server never receives a notifications/roots/list_changed notification
  4. 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

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗