From d7ea463aa5dac91cf762271dad2084f7898c8a1e Mon Sep 17 00:00:00 2001 From: EthBerryAdmin Date: Sun, 16 Mar 2025 16:39:24 +0400 Subject: [PATCH] allow ~ to be used in config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit following config throws error ``` "filesystem": { "command": "npx", "args": [ "-y", "@modelcontextprotocol/server-filesystem", "~" ] }, ``` ``` Error accessing directory ~: Error: ENOENT: no such file or directory, stat '~' at async Object.stat (node:internal/fs/promises:1032:18) at async file:///Users/USER_NAME/.npm/_npx/a3241bba59c344f5/node_modules/@modelcontextprotocol/server-filesystem/dist/index.js:33:23━━━━━━━━━━━━━━━━━ at async Promise.all (index 0) at async file:///Users/USER_NAME/.npm/_npx/a3241bba59c344f5/node_modules/@modelcontextprotocol/server-filesystem/dist/index.js:31:1 { errno: -2, code: 'ENOENT', syscall: 'stat', path: '~' } ``` this commit fixes error and allows to set ~ as allowed directory --- src/filesystem/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/filesystem/index.ts b/src/filesystem/index.ts index b4d5c419fc..c544ff2571 100644 --- a/src/filesystem/index.ts +++ b/src/filesystem/index.ts @@ -42,7 +42,7 @@ const allowedDirectories = args.map(dir => // Validate that all directories exist and are accessible await Promise.all(args.map(async (dir) => { try { - const stats = await fs.stat(dir); + const stats = await fs.stat(expandHome(dir)); if (!stats.isDirectory()) { console.error(`Error: ${dir} is not a directory`); process.exit(1);