[BUG] Claude Code desktop app launches MCP servers with cwd set to $HOME instead of the session's project directory
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
The Claude Code desktop app (v1.17377.2, Linux) starts stdio MCP servers with cwd=/home/<user> regardless of the project directory opened in the session. It also does not pass roots in the MCP initialize request. This breaks workspace-aware MCP servers like gopls mcp, which rely on cwd or roots to discover go.mod and index the project.
Tools that depend on the workspace root (go_workspace, go_search, go_vulncheck) fail, while tools that accept absolute file paths (go_file_context, go_symbol_references) work fine.
The cwd field in claude_desktop_config.json is also ignored.
What Should Happen?
The desktop app should either:
- Launch MCP servers with
cwdset to the current session's project directory, or - Pass the project directory as
rootsin the MCPinitialize request, or - Support the
cwdfield inclaude_desktop_config.json
Error Messages/Logs
go_workspace response when launched from wrong cwd:
This is not a Go workspace. To work on Go code, open a directory inside a Go module.
go_vulncheck response:
govulncheck: no go.mod file
govulncheck only works with Go modules. Try navigating to your module directory.
Environment variables captured from inside the MCP server process confirm PWD=/home/<user>:
PWD=/home/<user>
HOME=/home/<user>
Steps to Reproduce
- Add
goplsMCP to~/.config/Claude/claude_desktop_config.json:
{
"mcpServers": {
"gopls": {
"command": "gopls",
"args": ["mcp"]
}
}
}
- Open a session in a Go project directory (e.g.
/home/user/myprojectwithgo.mod) - Call
go_workspace→ returns "This is not a Go workspace" - Call
go_searchwith any query → returns "No symbols found" - Call
go_vulncheck→ fails with "no go.mod file"
Workaround: Use a wrapper script that does cd before launching gopls:
#!/bin/bash
cd "$(dirname "$(readlink -f "$0")")/.."
exec gopls mcp "$@"
Place it in <project>/.claude/gopls-mcp.sh and point the config to it.
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
1.17377.2.
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
Other
Additional Information
Claude Code desktop app version: 1.17377.2 (Linux)
gopls version: v0.22.0
Go version: 1.26.4
Verified that gopls works correctly when launched from the project directory (cwd = project root)
Verified that cwd field in claude_desktop_config.json is ignored
Verified that roots in MCP initialize is not sent by the desktop app (env dump shows no project-related variables)
The Claude Code CLI (claude in terminal) does not have this issue — it launches MCP servers from the project directory