cuipengcx90 on #4382 (and nifengfanpan0853 on Discord): with cocoindex set
to direct, Claude and Pi start it in their own folder, but Codex on magpie
was still given `url = "http://127.0.0.1:3425/mcp/run/cocoindex"`. magpie's
/mcp/run (#3885) starts the command from home, so cocoindex answered "Run
`ccc init` in your project root". syncMCP now leaves a direct server out of
runVia, so Codex's entry is the server's command, args and env, as it is
for every other agent, with the hub on or off. runSpecOf, which serves
/mcp/run before a sync has recorded what it gave, no longer runs a direct
server either. A shared server is still run by magpie for Codex, as before.
No `cwd` is written: Codex's codex-mcp make_rmcp_client builds its
LocalStdioServerLauncher with the session's config.cwd as fallback_cwd,
used when the entry has no cwd (openai/codex 67f0994,
stdio_server_launcher.rs launch_server). RawMcpServerConfig takes command,
args, env, env_vars and cwd for stdio.
Siblings: runVia is the only place a command server becomes a URL
(runsFor needs fmtCodex). Every other format is given the command and
starts it itself; npxDirect (node in place of npx) and side (WSL image
server) keep it a command; magpie writes no cwd for any agent. Project
MCP files never went through runVia.
Run:
- TestRunDirectServerIsCodexsCommand (new): red on the old code with the
issue's exact entry, `url = "http://127.0.0.1:3425/mcp/run/cocoindex"`,
when the syncMCP guard was taken out by hand; red again with only the
runSpecOf guard taken out ("before a sync /mcp/run would start the
direct server true"); green with both.
- mote-run: go test -tags nogui ./internal/library (ok, at the rebased
head 1a2ce7b8e), ./internal/cli ok, ./internal/proc FAIL
TestNoCommandBypassesProc on internal/claudetui/child_unix.go, which is
#4491 (on main, not this change).
- gofmt -l clean; go vet ./..., GOOS=linux go vet -tags nogui ./...,
GOOS=windows go vet ./..., go build, GOOS=linux go build -tags nogui,
GOOS=windows go build: all ok on mote.
- Real Codex: codex-cli 0.165.0 on mote, a sandbox HOME and CODEX_HOME, a
config.toml entry shaped as magpie now writes it (command, args, env,
no cwd) for a tiny node stdio server that logs its cwd. Run from
~/elsewhere with `codex exec -C <proj>`: the server logged
cwd=<proj> K=v, the thread's folder, not Codex's own.
Not run: the full go test ./... (another session's full suite was on
mote; one per machine). No GUI change. Not tried: real cocoindex, Codex's
app-server (the desktop app) with a thread whose cwd differs from the
app-server's, and a real magpie sync writing the entry for a real wired
Codex (the unit test covers those bytes).