fix(agents): use cmd /c npx on Windows for init-agents MCP config#39221
fix(agents): use cmd /c npx on Windows for init-agents MCP config#39221SeoJaeWan wants to merge 5 commits intomicrosoft:mainfrom
Conversation
|
@microsoft-github-policy-service agree |
|
Instead of a docs note, i'd prefer fixing our output - would you like to contribute a PR that fixes the |
58e7f6c to
9cbfb37
Compare
|
@Skn0tt Updated the PR to fix the Changes:
Verified the generated configs on Windows for all 4 generators. |
|
Thanks! Could you add tests to tests/mcp/init-agents.spec.ts? |
|
@Skn0tt Thanks for the review! Added tests in |
Skn0tt
left a comment
There was a problem hiding this comment.
we're getting there! it seems that not all targets have the distinction (copilot, opencode), so let's keep this change focused on those that do.
| asOpencodeTool(tools, tool); | ||
| } | ||
|
|
||
| const { command, args } = npxCommand(['playwright', 'run-test-mcp-server']); |
There was a problem hiding this comment.
opencode seems to spawn a shell, so we should also pick 'npx' here. maybe let's not use the abstraction?
tests/mcp/init-agents.spec.ts
Outdated
| await runInitAgents({ cwd: baseDir, args: ['--loop', 'claude'] }); | ||
|
|
||
| const mcpJson = JSON.parse(fs.readFileSync(path.join(baseDir, '.mcp.json'), 'utf-8')); | ||
| expect(mcpJson.mcpServers['playwright-test'].command).toBe(expectedCommand); |
There was a problem hiding this comment.
we usually have this structure in our test suite so that tests can be copied easily, let's match that.
| expect(mcpJson.mcpServers['playwright-test'].command).toBe(expectedCommand); | |
| if (process.platform === 'win32') | |
| expect(mcpJson.mcpServers['playwright-test'].command).toBe(expectedCommand); | |
| else | |
| expect(mcpJson.mcpServers['playwright-test'].command).toBe(expectedCommand); |
|
@Skn0tt Thank you so much for the thorough review. Sorry for the over-engineering — I didn’t realize opencode spawns a shell, so the cmd /c wrapping isn’t needed there. I’ve narrowed the scope to only the Claude and VSCode generators, removed the Appreciate the guidance — I’ve updated the PR with these changes. |
|
Cool, i'll quickly test this out myself on Windows. Could you do me a favor and revert those whitespace changes in the md file? |
|
@Skn0tt Done! Reverted the whitespace change in the md file. |
|
I could repro the bug with Claude and can see the fix works. But with VS Code, it already worked prior to the fix. Did you see this happen under VS Code as well? If not, let's trim down this PR to just the Claude fix. Taking a step back, I wonder if this should be fixed by Claude Code itself - if what we generate is platform-specific, it can't be comitted into repositories that need to work under different platforms. |
|
@Skn0tt Thanks for checking! Sorry for the noise — you’re right. I was able to reproduce the issue with Claude Code, but I haven’t been able to reproduce it in VS Code either (it seems to work there even before this change). I had already started trimming the PR, and I’ll update it to keep the fix scoped to the Claude generator only. |
|
I have a weird question to ask. Are you a human? You respond so quickly and so well-written that nowadays, I have to suspect you're OpenClaw! |
|
I’m a Korean developer, and I’m genuinely excited that I can contribute to open source for the first time. It’s 12:40 AM here in Korea, and I can’t fall asleep because I’m so focused on this PR. I’m just staying up and waiting for the review updates. |
|
@Skn0tt Updated — narrowed the scope to Claude generator only. VS Code confirmed working with plain |
|
@Skn0tt Your suspicion is understandable, and I realize I’ve made too many mistakes. I sincerely apologize for that. |
No worries! It's not the mistakes, it's the speed that got me suspicious :D Good to hear you're enjoying contributing to open source, it's a wonderful thing 👍 |
|
@Skn0tt It’s getting late here, so I think I should finally get some sleep. I’ll be able to respond again in about 5 hours. This PR has been one of the most nerve-wracking, thrilling, and exciting moments in my developer life — and I’m grateful for your patience and encouragement. Thank you! |
Test results for "tests 1"5 failed 1 flaky38553 passed, 843 skipped Merge workflow run. |
Test results for "MCP"5 failed 4787 passed, 135 skipped Merge workflow run. |

Summary
npxresolves tonpx.cmd(a batch file) which cannot be executed by MCP clients usingchild_process.spawn()withoutshell: truegenerateAgents.tsfor Claude generator to usecmd /c npxon Windows.cmdresolution internally, Copilot runs on GitHub cloud, Opencode spawns a shellChanges
ClaudeGenerator.init(): generates.mcp.jsonwithcmd /c npxon Windowstests/mcp/init-agents.spec.tsverifying MCP config output for claude generatorTest plan
npxon Windows (nocmd /cneeded)if/elseplatform branching, validated across CI environments (ubuntu, macos, windows)