Skip to content

dcd mcp install can't find code or claude on Windows (.cmd shims) #281

Open

Description

@finalerock44

dcd mcp install vscode reports that code isn't on PATH on Windows, even when code works in the user's terminal. dcd mcp install claude-code fails the same way. This affects at least the npm-installed CLI running under Node.

Found by the review bot on #280 (commit e83ae64). The code is the same on dev.

Cause

runTool in src/commands/mcp.ts calls spawnSync without a shell:

/** Run another tool's CLI without a shell. Undefined when it isn't installed. */
function runTool(command: string, args: string[]): { ok: boolean; output: string } | undefined {
const result = spawnSync(command, args, { encoding: 'utf8' });
if ((result.error as NodeJS.ErrnoException | undefined)?.code === 'ENOENT') return undefined;
return { ok: result.status === 0, output: `${result.stdout ?? ''}${result.stderr ?? ''}`.trim() };
}

On Windows, VS Code's command line exists only as ...\Microsoft VS Code\bin\code.cmd. Without a shell, Node's spawnSync searches PATH for .com and .exe files and skips .cmd. So spawnSync('code', ...) fails with ENOENT, runTool returns undefined, and the user sees "The code command isn't on PATH".

Recent Node versions also refuse to spawn a .cmd file unless you pass shell: true (CVE-2024-27980), so finding the file isn't enough on its own.

npm installs Claude Code as claude.cmd, so the claude mcp remove / claude mcp add calls hit the same problem:

const removed = runTool('claude', ['mcp', 'remove', '--scope', 'user', SERVER_NAME]);
if (!removed) {
throw new CliError(`The claude command isn't on PATH. Run this where it is:\n ${shellLine('claude', add)}`);
}
const added = runTool('claude', add)!;

Scope

  • Affected: anyone who installed dcd with npm on Windows.
  • Not checked yet: whether the bun-compiled binary (install.ps1) resolves .cmd differently.

Windows is a supported platform: there's install.ps1, and src/utils/mcp-install.ts handles win32 when it builds config paths.

Possible fixes

  1. On win32, try code.cmd / claude.cmd. Because of the CVE change this probably still needs a shell to launch them.
  2. On win32, spawn with shell: true (through cmd.exe). If we do this, quote the JSON argument from vscodeAddArgs carefully, because cmd will reparse it.

Done when

  • dcd mcp install vscode and dcd mcp install claude-code work on Windows with an npm-installed CLI.
  • The bun-compiled binary is checked as well.
  • The JSON argument passed to code --add-mcp reaches VS Code unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions