ctx setup opencode --write generates Unix-only MCP config on Windows
Problem
ctx setup opencode --write generates an MCP server entry that uses sh -c and exec env:
"ctx": {
"command": ["sh", "-c", "exec env CTX_DIR=\"$PWD/.context\" /path/to/ctx mcp serve"],
"enabled": true,
"type": "local"
}
This fails on Windows because sh, exec, and env don't exist. OpenCode interprets the failed subprocess as a connection close → MCP error -32000: Connection closed.
Steps to Reproduce
- Install ctx on Windows (via
go install or binary download)
- Run
ctx setup opencode --write from a workspace directory
- Launch OpenCode — ctx MCP server fails immediately
Expected Behavior
ctx setup opencode --write should detect the OS and generate a platform-appropriate MCP command:
Windows (cmd):
"command": ["cmd", "/c", "set CTX_DIR=%CD%\\.context && ctx mcp serve"]
Windows (PowerShell):
"command": ["powershell", "-Command", "$env:CTX_DIR=\"$PWD\\.context\"; ctx mcp serve"]
Additional Context
Separately, the generated .opencode/plugins/ctx.ts calls ctx system bootstrap on session.created, which requires a .git/ directory. When the workspace root isn't a git repo, this emits:
git working tree required: ctx bootstrap: .git/ not found
The .nothrow().quiet() should suppress this, but it may contribute to confusion when debugging the MCP connection failure above.
Environment
- OS: Windows 11
- ctx: v0.8.1
- OpenCode: latest
- Shell: CMD (Command Prompt)
ctx setup opencode --writegenerates Unix-only MCP config on WindowsProblem
ctx setup opencode --writegenerates an MCP server entry that usessh -candexec env:This fails on Windows because
sh,exec, andenvdon't exist. OpenCode interprets the failed subprocess as a connection close →MCP error -32000: Connection closed.Steps to Reproduce
go installor binary download)ctx setup opencode --writefrom a workspace directoryExpected Behavior
ctx setup opencode --writeshould detect the OS and generate a platform-appropriate MCP command:Windows (cmd):
Windows (PowerShell):
Additional Context
Separately, the generated
.opencode/plugins/ctx.tscallsctx system bootstraponsession.created, which requires a.git/directory. When the workspace root isn't a git repo, this emits:The
.nothrow().quiet()should suppress this, but it may contribute to confusion when debugging the MCP connection failure above.Environment