Fix filesystem server crashes on invalid paths with graceful validation#2603
Fix filesystem server crashes on invalid paths with graceful validation#2603sebastien-rosset wants to merge 1 commit intomodelcontextprotocol:mainfrom
Conversation
c6832b8 to
63918dd
Compare
376aa98 to
5786738
Compare
| } | ||
| } 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)}`); |
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
left a comment
There was a problem hiding this comment.
Hi, thanks for the PR, Added a comment below.
|
Closing this PR — the graceful startup validation has already been implemented on Your approach of keeping inaccessible paths for runtime retry was an interesting design choice for NAS/VPN scenarios, but as noted in review, it created a confusing experience when paths had typos. The current implementation takes the simpler approach of skipping them. Thank you for the contribution — the core issue you identified (server crashing on invalid paths) has been resolved. This comment was posted by Claude Code on behalf of @olaservo. |
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.