Repository navigation
Description
Bug
In remote/client mode, project-local .mcp.json is not loaded for a client session even when the file exists in that session's project root.
The TUI header shows the correct client working directory, but MCP status remains:
mcp: (none)
Reproduction
- Create or use a project with a valid
.mcp.jsonat the project root. - Configure stdio MCP servers using Claude-compatible
mcpServers, for example:
{
"mcpServers": {
"example-server": {
"command": "npx",
"args": ["-y", "some-mcp-server"]
}
}
}- Start a remote/client session with that project as the session working directory.
- Observe the header shows
mcp: (none).
Evidence
Runtime logs show the client session working directory is set, but MCP registration completes with no configured servers:
mcp_register=0ms
mcp_servers=0
The same .mcp.json shape is valid for jcode's loader because it uses mcpServers and stdio-compatible command entries.
Suspected root cause
The remote subscribe path calls MCP registration without passing the session working directory.
register_mcp_tools creates an McpManager, whose constructors call:
McpConfig::load()McpConfig::load() reads project-local config relative to the server process cwd, not the subscribed client session working directory.
So the UI/session can show the correct project cwd while MCP discovery happens relative to the shared server's cwd.
Expected behavior
For remote/client sessions, MCP config loading should resolve project-local config from the session working directory, including:
.mcp.json.jcode/mcp.json- legacy
.claude/mcp.json
The server process cwd should not determine project-local MCP config for subscribed client sessions.
Possible fix
Thread the session working directory through MCP registration, for example:
- add
McpConfig::load_for_dir(path) - add
McpManager::{new_for_dir, with_shared_pool_for_dir} - pass the subscribe/session working directory into
register_mcp_tools - keep current
McpConfig::load()as the default for local/headless paths
Add a regression test for remote subscribe with a session working dir containing .mcp.json.
Activity
fix: load project-local MCP config from session working dir, not serv…
1jehuang commentedon Jul 3, 2026
Fixed on master in a0a4b87.
Root cause confirmed as suspected: the remote subscribe path called
register_mcp_tools->McpManager::with_shared_pool->McpConfig::load(), which resolved.mcp.json/.jcode/mcp.json/.claude/mcp.json(and the per-project entries in~/.claude.json) against the long-lived server's process cwd, not the session working directory.The fix threads the session working dir all the way through:
McpConfig::load_for_dir(dir)resolves project-local config against an explicit directory;load()keeps cwd behavior for local/headless use.McpManager::with_shared_pool_for_dirstores the project dir, andreload()reuses it so/mcp reloadstays session-scoped too.Registry::register_mcp_tools_for_dirpasses the session working dir at every server call site: subscribe (prefers the subscribe request's dir, falls back to the agent's stored session dir), both resume paths, headless session creation, and startup recovery.Regression tests cover resolution against an explicit dir (not cwd) and the
.jcode->.mcp->.claudemerge order. Thanks for the precise diagnosis, it pointed at exactly the right seams.Fix resume deadlock when live-attach target agent is busy
fix: load project-local MCP config from session working dir, not serv…
Fix resume deadlock when live-attach target agent is busy
fix: load project-local MCP config from session working dir, not serv…
Fix resume deadlock when live-attach target agent is busy