filesystem: expandHome() does not handle Windows backslash separator (~\path)
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 76/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- node.js, typescript
- Área
- backend
Línea de trabajo
Lee src/filesystem/path-utils.ts y src/filesystem/roots-utils.ts, donde el issue muestra las comprobaciones de expansión de la tilde. Compara cómo se manejan las rutas ~/ y ~\ y luego busca pruebas que cubran expandHome y la expansión de rutas raíz. Se considera terminado cuando las rutas de Windows con tilde y barra invertida se expandan al directorio personal y los casos existentes sigan funcionando.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Which server?
filesystem (@modelcontextprotocol/server-filesystem)
Server version
latest (v2/main)
How did you run the server?
npx (npm package)
Transport
stdio
Protocol era
Modern (2026-07-28)
MCP client and version
Claude Desktop / MCP Inspector
Operating system and runtime
Windows 11 / Windows Server, Node.js v20+ / v22+
Server configuration
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "~\\projects"]
}
}
}
Steps to reproduce
- Run
@modelcontextprotocol/server-filesystemon Windows. - Supply an allowed directory argument or path with native Windows backslash tilde notation, e.g.,
~\projectsor~\Documents\notes.txt. expandHomeinsrc/filesystem/path-utils.tsexecutes:
And similarly inexport function expandHome(filepath: string): string { if (filepath.startsWith("~/") || filepath === "~") { return path.join(os.homedir(), filepath.slice(1)); } return filepath; }src/filesystem/roots-utils.ts:if (rawPath.startsWith("~/") || rawPath === "~") { ... }
Expected behavior
On Windows platforms, tilde followed by a backslash (~\) is the natural path separator convention when invoking CLI commands or passing configurations (e.g. ~\workspace). expandHome should recognize both ~/ and ~\ prefixes and expand them to os.homedir().
Actual behavior
Because the condition strictly checks .startsWith("~/"), any path formatted with backslashes (such as ~\projects or ~\\projects) fails to match. expandHome returns the raw string unchanged.
Downstream, path.resolve() interprets ~ as a literal directory name relative to the current working directory (e.g. C:\current\dir\~\projects), causing directory validation to fail with:
Access denied - Path does not exist or is outside allowed directories
Logs or error output
Node.js REPL test:
> const path = require('path');
> const os = require('os');
> function expandHome(p) { if (p.startsWith('~/') || p === '~') return path.join(os.homedir(), p.slice(1)); return p; }
> expandHome('~/test')
'C:\\Users\\User\\test' // OK (POSIX slash)
> expandHome('~\\test')
'~\\test' // Fails to expand Windows backslash
Already prototyped a fix?
Update expandHome in src/filesystem/path-utils.ts and roots-utils.ts to recognize ~\:
export function expandHome(filepath: string): string {
if (filepath === "~" || filepath.startsWith("~/") || filepath.startsWith("~\\")) {
return path.join(os.homedir(), filepath.slice(1));
}
return filepath;
}
Before you submit
- I searched existing issues and this is not a duplicate.
- This is not a security vulnerability report (those go through the private advisory form).
- Lenguaje dominante
- TypeScript
- Estrellas
- 91.4k
- Forks
- 11.8k
- Merge medio
- 7 h 36 min
- PR fusionados (30 d)
- 126
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de modelcontextprotocol/servers
-
filesystem: search_files does not expand non-wildcard excludePatterns like directory_tree doesAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
modelcontextprotocol/servers#5216 ·
Los mantenedores suelen responder en 1 día
-
bug v2
Dificultad 2/5 1-3 horas Aptitud para principiantes 79/100
modelcontextprotocol/servers#5215 ·
Los mantenedores suelen responder en 1 día
-
documentation server-git server-time v2
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
modelcontextprotocol/servers#5213 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
documentation v2
Dificultad 1/5 1-3 horas Aptitud para principiantes 78/100
modelcontextprotocol/servers#5212 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
documentation v2
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
modelcontextprotocol/servers#5211 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de modelcontextprotocol/servers
Issues similares
-
area:editor bug issue-form:bug P0 platform:windows review: low
Dificultad 2/5 1-3 horas Aptitud para principiantes 64/100
1lck/Lithe-IDEA#1388 ·
Los mantenedores suelen responder en 1 día
-
fix(api): isToolAuditEnabled swallows database read errors on auditToolOperations without loggingAbiertoarea: backend bug priority: low
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
snapotter-hq/SnapOtter#3238 ·
Los mantenedores suelen responder en 1 día
-
rig up --plan times out after 5 s and reports an UNKNOWN outcome while the daemon completes the planAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
deferred
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Los mantenedores suelen responder en 1 día