github / github/copilot-cli

Windows: v1.0.66 fails to start stdio MCP servers when command is a .bat/.cmd with args (regression from 1.0.65)

オープン
#3,958 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
area:mcp area:platform-windows
主要言語
Shell
スター
11.2k
フォーク
1.9k
平均マージ
14時間 16分
マージ済み PR(30日)
6

説明

## Summary

On Windows, **v1.0.66 fails to start any stdio MCP server whose `command` is a `.bat`/`.cmd` file and is registered with one or more `args`.** The child process dies immediately with cmd.exe's `The syntax of the command is incorrect.` and the client reports `connection closed: initialize response`. The exact same servers worked in **v1.0.65**.

This looks like a regression in how the Windows `.bat`/`.cmd` spawn path builds/quotes the command line (consistent with the post‑CVE‑2024‑27980 Node hardening for batch files).

## Environment

- Copilot CLI: **1.0.66-1** (broken) — worked on **1.0.65**
- OS: Windows 11 (`10.0.26200`), x64
- Install: WinGet (`GitHub.Copilot`)
- Bundled Node: `v24.16.0`

## What fails vs. what works

Given these MCP registrations:

| `command` | `args` | Result on 1.0.66 |
|---|---|---|
| `foo.bat` | `["serve"]` | ❌ fails: `The syntax of the command is incorrect.` |
| `foo.bat` | `[]` (no args) | ✅ works |
| `python.exe` (a real `.exe`) | `["-m","foo","serve"]` | ✅ works |
| http server | n/a | ✅ works |

So the failure is specific to **`.bat`/`.cmd` command + non-empty `args`**. Removing the argument (or pointing `command` at a real `.exe`) avoids it.

## Logs

```
[ERROR] Starting MCP client for dashpilot with command: d:\LRPBot\dashpilot.bat and args: serve
[ERROR] [mcp server dashpilot stderr] The syntax of the command is incorrect.
[ERROR] Failed to start MCP client for dashpilot: Error: failed to initialize MCP client: connection closed: initialize response
```

In the same session, every `.bat … serve` server failed identically (5 of them), while one `.bat` registered with empty args and all `http` servers started fine. On 1.0.65, all of the same `.bat … serve` servers started normally.

## Minimal reproduction

1. Create `C:\tmp\echo.bat`:
```bat
@echo off
echo got arg: %~1 1>&2
```
2. Register it with an argument:
```
copilot mcp add repro -- "C:\tmp\echo.bat" serve
```
3. Launch `copilot` → the `repro` server fails to start with `The syntax of the command is incorrect.`
4. Re-register **without** the argument and the spawn no longer errors:
```
copilot mcp remove repro
copilot mcp add repro -- "C:\tmp\echo.bat"
```

(For a server that actually completes MCP initialization, wrap any stdio MCP server in a `.bat` and register it `-- "wrapper.bat" serve` vs `-- "wrapper.bat"`.)

## Expected

A `.bat`/`.cmd` MCP `command` with `args` should be spawned with a correctly quoted command line (as it was in 1.0.65), so the server initializes normally.

## Workaround

Register the `.bat` with **no args** (have the batch file default to its serve subcommand), or point `command` directly at the underlying `.exe` (e.g. the venv `python.exe`) with the args.

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

まず、提供された echo.bat コマンドを使って MCP stdio サーバーの起動経路で障害を再現し、その後、バージョン 1.0.65 と 1.0.66 の動作を比較します。.bat および .cmd コマンドに空でない引数を指定した場合に Windows 上で MCP の初期化が開始されて完了し、既存の引数なしの場合と実行可能ファイルの場合も引き続き動作すれば、作業は完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
node.js, shell
領域
cli
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
静か
明瞭さ
明確に書かれている
初心者へのやさしさ
65/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。