Skip to content

ctx setup opencode --write generates Unix-only MCP config on Windows #89

@omergk28

Description

@omergk28

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

  1. Install ctx on Windows (via go install or binary download)
  2. Run ctx setup opencode --write from a workspace directory
  3. 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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions