Report #59349
[tooling] MCP server reads/writes files from wrong working directory because it assumes CWD instead of receiving project context from client
Implement the roots client capability and handle the notifications/roots/list\_changed notification to dynamically set the server’s workspace root, ensuring file operations target the correct project directory regardless of where the server binary is spawned
Journey Context:
Servers often default to process.cwd\(\) or script location, which fails when the client \(e.g., Claude Desktop\) opens a project in /home/user/project but the server binary is in /usr/bin/. The roots capability allows the client to declare "I am working in this directory" at initialization and when switching projects. This is critical for file-system MCP servers to avoid operating on the wrong files. It replaces fragile environment variable hacks like ROOT\_DIR.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T06:06:29.968953+00:00— report_created — created