mcp/filesystem cannot use working directory only on LM Studio
Describe the bug mcp/filesystem does not start under LM Studio without specified path or with working directory as described in intelij idea integration
To Reproduce Steps to reproduce the behavior:
- put the tool in mcp.json
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
]
}
}
}
- Enable it Expected behavior The tool should be usable.
Logs
2025-07-20 22:12:47 [ERROR]
[Plugin(mcp/filesystem)] stderr: Usage: mcp-server-filesystem <allowed-directory> [additional-directories...]
2025-07-20 22:12:47 [ERROR]
[Plugin(mcp/filesystem)] stderr: Error in LM Studio MCP bridge process: _0x4143fb [McpError]: MCP error -32000: Connection closed
at _0x477d3a._onclose (D:\Program Files\LM Studio\resources\app\.webpack\lib\mcpbridgeworker.js:1:822761)
at <computed>.onclose (D:\Program Files\LM Studio\resources\app\.webpack\lib\mcpbridgeworker.js:1:821476)
at ChildProcess.<anonymous> (D:\Program Files\LM Studio\resources\app\.webpack\lib\mcpbridgeworker.js:1:796633)
at ChildProcess.emit (node:events:519:28)
at _0x4f9a1e.<computed> [as emit] (D:\Program Files\LM Studio\resources\app\.webpack\lib\mcpbridgeworker.js:1:279636)
at maybeClose (node:internal/child_process:1105:16)
at ChildProcess._handle.onexit (node:internal/child_process:305:5) {
code: -32000,
data: undefined
}
_0x4143fb [McpError]: MCP error -32000: Connection closed
at _0x477d3a._onclose (D:\Program Files\LM Studio\resources\app\.webpack\lib\mcpbridgeworker.js:1:822761)
at <computed>.onclose (D:\Program Files\LM Studio\resources\app\.webpack\lib\mcpbridgeworker.js:1:821476)
at ChildProcess.<anonymous> (D:\Program Files\LM Studio\resources\app\.webpack\lib\mcpbridgeworker.js:1:796633)
at ChildProcess.emit (node:events:519:28)
at _0x4f9a1e.<computed> [as emit] (D:\Program Files\LM Studio\resources\app\.webpack\lib\mcpbridgeworker.js:1:279636)
at maybeClose (node:internal/child_process:1105:16)
at ChildProcess._handle.onexit (node:internal/child_process:305:5) {
code: -32000,
data: undefined
}
Additional context with "${workspaceFolder}" as standin for working directory shows
2025-07-20 22:27:14 [ERROR]
[Plugin(mcp/filesystem)] stderr: Error accessing directory ${workspaceFolder}: Error: ENOENT: no such file or directory, stat 'C:\Users\danda\.lmstudio\extensions\plugins\mcp\filesystem\${workspaceFolder}'
at async Object.stat (node:internal/fs/promises:1032:18)
at async file:///C:/Users/danda/AppData/Local/npm-cache/_npx/a3241bba59c344f5/node_modules/@modelcontextprotocol/server-filesystem/dist/index.js:48:23
at async Promise.all (index 0)
at async file:///C:/Users/danda/AppData/Local/npm-cache/_npx/a3241bba59c344f5/node_modules/@modelcontextprotocol/server-filesystem/dist/index.js:46:1 {
errno: -4058,
code: 'ENOENT',
syscall: 'stat',
path: 'C:\\Users\\danda\\.lmstudio\\extensions\\plugins\\mcp\\filesystem\\${workspaceFolder}'
}
2025-07-20 22:27:14 [ERROR]
[Plugin(mcp/filesystem)] stderr: Error in LM Studio MCP bridge process: _0x4143fb [McpError]: MCP error -32000: Connection closed
at _0x477d3a._onclose (D:\Program Files\LM Studio\resources\app\.webpack\lib\mcpbridgeworker.js:1:822761)
at <computed>.onclose (D:\Program Files\LM Studio\resources\app\.webpack\lib\mcpbridgeworker.js:1:821476)
at ChildProcess.<anonymous> (D:\Program Files\LM Studio\resources\app\.webpack\lib\mcpbridgeworker.js:1:796633)
at ChildProcess.emit (node:events:519:28)
at _0x4f9a1e.<computed> [as emit] (D:\Program Files\LM Studio\resources\app\.webpack\lib\mcpbridgeworker.js:1:279636)
at maybeClose (node:internal/child_process:1105:16)
at ChildProcess._handle.onexit (node:internal/child_process:305:5) {
code: -32000,
data: undefined
}
2025-07-20 22:27:14 [ERROR]
[Plugin(mcp/filesystem)] stderr: _0x4143fb [McpError]: MCP error -32000: Connection closed
at _0x477d3a._onclose (D:\Program Files\LM Studio\resources\app\.webpack\lib\mcpbridgeworker.js:1:822761)
at <computed>.onclose (D:\Program Files\LM Studio\resources\app\.webpack\lib\mcpbridgeworker.js:1:821476)
at ChildProcess.<anonymous> (D:\Program Files\LM Studio\resources\app\.webpack\lib\mcpbridgeworker.js:1:796633)
at ChildProcess.emit (node:events:519:28)
at _0x4f9a1e.<computed> [as emit] (D:\Program Files\LM Studio\resources\app\.webpack\lib\mcpbridgeworker.js:1:279636)
at maybeClose (node:internal/child_process:1105:16)
at ChildProcess._handle.onexit (node:internal/child_process:305:5) {
code: -32000,
data: undefined
}
Putting in working directory manually does not work also. AI tries to read from wrong directory
Thought for 3 minutes 7 seconds
read_multiple_files
({"paths":["index.html","script.js","style.css"]}…})
mcp/filesystem
Arguments
paths:
[
"index.html",
"script.js",
"style.css"
]
Result
[
{
"type": "text",
"text": "index.html: Error - Access denied - path outside allowed directories: C:\\Users\\danda\\.lmstudio\\extensions\\plugins\\mcp\\filesystem\\index.html not in C:\\Users\\danda\\.lmstudio\\working-directories\\1750330141933\n---\nscript.js: Error - Access denied - path outside allowed directories: C:\\Users\\danda\\.lmstudio\\extensions\\plugins\\mcp\\filesystem\\script.js not in C:\\Users\\danda\\.lmstudio\\working-directories\\1750330141933\n---\nstyle.css: Error - Access denied - path outside allowed directories: C:\\Users\\danda\\.lmstudio\\extensions\\plugins\\mcp\\filesystem\\style.css not in C:\\Users\\danda\\.lmstudio\\working-directories\\1750330141933"
}
]
bump, same issue
@claude could you help investigate this issue?
Claude finished @olaservo's task —— View job
Analysis Complete - LM Studio MCP Filesystem Integration Issue
I've analyzed the filesystem MCP server code and identified the root cause of the issue.
Investigation Progress
- [x] Read and analyze the filesystem server source code
- [x] Investigate directory argument parsing and validation
- [x] Check for workspace folder placeholder handling
- [x] Analyze the error messages and determine root cause
- [x] Provide recommendations for fixing the issue
Root Cause Analysis
The issue occurs because LM Studio doesn't properly handle MCP server directory requirements. Here's what's happening:
-
Missing Directory Arguments: The filesystem server (
index.ts:36-42) requires directory paths as command-line arguments. When no arguments are provided, it shows the usage error seen in the logs. -
Literal Placeholder Handling: When LM Studio uses
${workspaceFolder}, it's being passed literally as a string instead of being resolved to the actual workspace path. The server tries to accessC:\Users\danda\.lmstudio\extensions\plugins\mcp\filesystem\${workspaceFolder}instead of the intended workspace directory. -
Server Working Directory Issue: The filesystem server runs from its own directory (
C:\Users\danda\.lmstudio\extensions\plugins\mcp\filesystem\) rather than the intended workspace, causing path resolution problems.
Technical Details
The server has two methods for specifying allowed directories:
- Command-line arguments (what LM Studio should use)
- MCP Roots protocol (dynamic, client-driven)
LM Studio appears to be launching the server without proper directory arguments and without implementing the MCP Roots protocol to provide workspace directories dynamically.
Recommended Solutions
For LM Studio Users:
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"C:\\Users\\danda\\your-actual-workspace-path"
]
}
}
}
For LM Studio Developers:
- Implement MCP Roots protocol - This would allow dynamic workspace directory management
- Fix placeholder resolution -
${workspaceFolder}should resolve to actual paths before server launch - Set proper working directory - Launch the MCP server with the workspace as the working directory
The filesystem server code itself is working correctly - this is a client integration issue that needs to be addressed in LM Studio's MCP implementation.