Fix filesystem server crashes on invalid paths with graceful validation#2603
Open
sebastien-rosset wants to merge 1 commit intomodelcontextprotocol:mainfrom
Open
Fix filesystem server crashes on invalid paths with graceful validation#2603sebastien-rosset wants to merge 1 commit intomodelcontextprotocol:mainfrom
sebastien-rosset wants to merge 1 commit intomodelcontextprotocol:mainfrom
Conversation
c6832b8 to
63918dd
Compare
376aa98 to
5786738
Compare
olaservo
reviewed
Aug 24, 2025
| } | ||
| } catch (error) { | ||
| // Include inaccessible paths - they might become accessible when storage/network reconnects | ||
| console.error(`Directory not accessible: ${dir} - ${error instanceof Error ? error.message : String(error)}`); |
Member
There was a problem hiding this comment.
I'm not sure it makes sense to include invalid drives is the list of allowed directories, since it create a weird experience if someone makes a mistake with a filepath. For example, I tested with a purposeful typo and Claude tired to search for files in the directory and failed. Skipping those and logging an error seem like a better way to go from a user experience point of view?
And/or it might make sense to include a validate_allowed_directories tool that the LLM could use to help the user figure out if any directories have issues?
olaservo
requested changes
Aug 24, 2025
Member
olaservo
left a comment
There was a problem hiding this comment.
Hi, thanks for the PR, Added a comment below.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes filesystem server crashes when invalid or inaccessible paths are configured by implementing graceful path validation. The server now logs warnings for problematic paths at startup but continues running, allowing operations to retry at runtime when storage becomes available.
Server Details
Motivation and Context
Addresses GitHub issues #2113 and #2483. The filesystem server would crash immediately if any configured directory path was invalid, inaccessible, or pointed to a file instead of a directory. This was problematic for users with:
The original behavior provided a poor user experience and made the server fragile in dynamic storage environments.
How Has This Been Tested?
Breaking Changes
No breaking changes. This is backwards compatible - existing configurations continue to work. The only change is that invalid paths now generate warnings instead of crashes.
Types of changes
Checklist
Additional context
Implementation Details:
Promise.allfor better performanceDesign Philosophy:
The new approach is optimistic about dynamic storage - we include paths that might become valid directories later while permanently excluding things that can never be directories. This balances robustness with usability for modern storage environments.