You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(filesystem): hide dot directories by default to reduce token usage and improve security
Fixes#2219
- Add environment variable MCP_FILESYSTEM_SHOW_DOT_DIRECTORIES for global control
- Add optional showDot parameter to list_directory, list_directory_with_sizes, directory_tree, and search_files tools
- Filter out dot directories (.git, .vscode, .terraform, etc.) by default in all directory operations
- Update tool descriptions to explain the new behavior
- Maintain backward compatibility while improving security and performance
This significantly reduces token consumption when working with repositories containing large .git directories and prevents accidental exposure of sensitive information in hidden directories.
The fix can be overridden per-operation using showDot: true parameter or globally using the environment variable.
This fix addresses issue #2219 where dot directories (like `.git`, `.terraform`, etc.) were being included in filesystem MCP search tools, causing massive token usage and potential security issues.
- When set to `'true'`, dot directories are shown by default
12
+
- When not set or set to any other value, dot directories are hidden by default
13
+
14
+
### 2. Helper Functions
15
+
-`isDotPath(name: string)`: Checks if a file/directory name starts with a dot
16
+
-`shouldShowDotDirectories(showDot?: boolean)`: Determines whether to show dot directories based on parameter or environment variable
17
+
18
+
### 3. Updated Tool Schemas
19
+
Added optional `showDot` parameter to the following tools:
20
+
-`list_directory`
21
+
-`list_directory_with_sizes`
22
+
-`directory_tree`
23
+
-`search_files`
24
+
25
+
### 4. Updated Tool Implementations
26
+
Modified the following functions to filter out dot directories by default:
27
+
-`list_directory` handler
28
+
-`list_directory_with_sizes` handler
29
+
-`directory_tree` handler and `buildTree` function
30
+
-`search_files` handler and `searchFiles` function
31
+
32
+
### 5. Updated Tool Descriptions
33
+
Enhanced tool descriptions to mention that dot directories are hidden by default for security and performance reasons, with instructions on how to include them using the `showDot` parameter.
34
+
35
+
## Usage
36
+
37
+
### Default Behavior (Dot Directories Hidden)
38
+
```bash
39
+
# Dot directories will be hidden by default
40
+
node index.js /path/to/directory
41
+
```
42
+
43
+
### Show Dot Directories via Environment Variable
44
+
```bash
45
+
# Show dot directories for all operations by default
0 commit comments