Why does filesystem MCP server always error 'Parent directory does not exist' on Windows?
On Windows, using modelcontextprotocol/server-filesystem always fails with 'Parent directory does not exist' even when the allowed directories configuration appears correct. Why does this happen and what change makes it work?
Originally asked on GitHub: https://github.com/modelcontextprotocol/servers/issues/1820
2 answers
Status: explained - the cause is a case-sensitive path check on Windows; the issue is closed as a duplicate and the maintainer said it was going to be merged into #470 for tracking. No fixed release version is mentioned in the thread.
The reporter debugged the server and found this check:
const isParentAllowed = allowedDirectories.some(dir => normalizedParent.startsWith(dir));
On Windows, normalizedParent uppercases the drive letter, so a configured path like e:\test becomes E:\test and never starts with the configured lowercase directory string.
The patch that worked compares case-insensitively only on Windows:
const isParentAllowed = allowedDirectories.some(dir => process.platform === 'win32' ? normalizedParent.toLowerCase().startsWith(dir.toLowerCase()) : normalizedParent.startsWith(dir) );
Apply that to a local copy of the server source if you need an immediate workaround; the thread does not say whether an official fix exists. One commenter reported the same error but offered no additional fix. General advice: keep the case-insensitive comparison scoped to Windows so other platforms keep their original behavior, and do not widen the configured allowed directories beyond what your workflow needs.
Did this work for you?What a GitHub user tried on GitHub (Worked)
The reporter traced the error to normalizedParent.startsWith(dir) comparing uppercase E:\test against a configured lowercase e:\test. They patched the check to use toLowerCase().startsWith(dir.toLowerCase()) when process.platform === 'win32', and the server then ran successfully.
Source: https://github.com/modelcontextprotocol/servers/issues/1820 (opens external site)
Did this work for you?
Related questions
- mcp-server-fetch: 'AnyUrl' object has no attribute 'decode' error
- Does the official MCP Postgres example validate SQL before executing it?
- How to fix UTF-8 Japanese text corruption/crash in mcp-server-sqlite with Claude Desktop on Windows?
- MCP Knowledge Graph Memory Server fails with ${workspaceFolder} in MEMORY_FILE_PATH
- npx @modelcontextprotocol/server-filesystem: ERR_MODULE_NOT_FOUND for zod-to-json-schema