Skip to content

Commit 282e482

Browse files
committed
fix(tests): Failed to start process with command npx on Windows platform while running mvn test
1 parent e401e9e commit 282e482

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

mcp/src/test/java/io/modelcontextprotocol/client/StdioMcpAsyncClientTests.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ protected McpClientTransport createMcpTransport() {
2525
ServerParameters stdioParams = ServerParameters.builder("npx")
2626
.args("-y", "@modelcontextprotocol/server-everything", "dir")
2727
.build();
28-
return new StdioClientTransport(stdioParams);
28+
ServerParameters windowsStdioParams = ServerParameters.builder("cmd.exe")
29+
.args("/c", "npx.cmd", "-y", "@modelcontextprotocol/server-everything", "dir")
30+
.build();
31+
boolean isWindows = System.getProperty("os.name").toLowerCase().contains("win");
32+
return new StdioClientTransport(isWindows ? windowsStdioParams : stdioParams);
2933
}
3034

3135
protected Duration getInitializationTimeout() {

mcp/src/test/java/io/modelcontextprotocol/client/StdioMcpSyncClientTests.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,11 @@ protected McpClientTransport createMcpTransport() {
3333
ServerParameters stdioParams = ServerParameters.builder("npx")
3434
.args("-y", "@modelcontextprotocol/server-everything", "dir")
3535
.build();
36-
37-
return new StdioClientTransport(stdioParams);
36+
ServerParameters windowsStdioParams = ServerParameters.builder("cmd.exe")
37+
.args("/c", "npx.cmd", "-y", "@modelcontextprotocol/server-everything", "dir")
38+
.build();
39+
boolean isWindows = System.getProperty("os.name").toLowerCase().contains("win");
40+
return new StdioClientTransport(isWindows ? windowsStdioParams : stdioParams);
3841
}
3942

4043
@Test

0 commit comments

Comments
 (0)