Commit 4127473
fix(filesystem): preserve CLI directories when merging with MCP roots
The oninitialized and roots/list_changed handlers replaced all
CLI-provided allowed directories with client roots, silently
discarding any extra directories passed via command-line arguments.
Store CLI directories as an immutable baseline and merge them with
client roots using a Set for deduplication. When roots become empty
or invalid, fall back to the CLI baseline instead of keeping stale
roots.
Fixes #3602
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent b60eca1 commit 4127473
3 files changed
Lines changed: 58 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | | - | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
92 | 97 | | |
93 | 98 | | |
94 | 99 | | |
| |||
702 | 707 | | |
703 | 708 | | |
704 | 709 | | |
705 | | - | |
| 710 | + | |
| 711 | + | |
706 | 712 | | |
707 | 713 | | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
708 | 717 | | |
709 | | - | |
710 | | - | |
711 | | - | |
| 718 | + | |
712 | 719 | | |
713 | | - | |
| 720 | + | |
714 | 721 | | |
715 | 722 | | |
716 | 723 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | | - | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
0 commit comments