Skip to content

Remove sync-roots workaround when Claude Code fixes /add-dir root notifications #18

@m-wells

Description

@m-wells

Context

Claude Code's /add-dir command does not send notifications/roots/list_changed to MCP servers. This means Catenary never learns about directories added mid-session, and path-validated tools like list_directory reject paths in the new directory.

Upstream issue: anthropics/claude-code#26663

Current Workaround

A PreToolUse hook runs catenary sync-roots on every tool call. It:

  1. Parses the Claude Code transcript JSONL for /add-dir confirmation messages
  2. Sends discovered roots to the running session's notify socket
  3. Uses a byte-offset cache to avoid re-scanning the full transcript

Files involved:

  • src/main.rsSyncRoots subcommand and run_sync_roots()
  • src/notify.rsAddRoots variant in NotifyRequest, process_add_roots()
  • src/bridge/path_security.rsroots() getter on PathValidator
  • plugins/catenary/hooks/hooks.jsonPreToolUse hook entry

When to close

When Claude Code sends notifications/roots/list_changed after /add-dir, the sync-roots hook becomes unnecessary. At that point:

  1. Remove the SyncRoots subcommand from src/main.rs
  2. Remove the AddRoots variant from NotifyRequest in src/notify.rs (keep process_add_roots on the server side — it's useful for any root addition path)
  3. Remove the PreToolUse hook from plugins/catenary/hooks/hooks.json
  4. The roots() getter on PathValidator can stay — it's generally useful

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions