Skip to content

Commit 79ec5b5

Browse files
authored
fix(tests): Failed to start process with command npx on Windows (#85)
* fix(tests): Failed to start process with command npx on Windows platform while running mvn test
1 parent e401e9e commit 79ec5b5

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

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

+11-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,17 @@ class StdioMcpAsyncClientTests extends AbstractMcpAsyncClientTests {
2222

2323
@Override
2424
protected McpClientTransport createMcpTransport() {
25-
ServerParameters stdioParams = ServerParameters.builder("npx")
26-
.args("-y", "@modelcontextprotocol/server-everything", "dir")
27-
.build();
25+
ServerParameters stdioParams;
26+
if (System.getProperty("os.name").toLowerCase().contains("win")) {
27+
stdioParams = ServerParameters.builder("cmd.exe")
28+
.args("/c", "npx.cmd", "-y", "@modelcontextprotocol/server-everything", "dir")
29+
.build();
30+
}
31+
else {
32+
stdioParams = ServerParameters.builder("npx")
33+
.args("-y", "@modelcontextprotocol/server-everything", "dir")
34+
.build();
35+
}
2836
return new StdioClientTransport(stdioParams);
2937
}
3038

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

+11-4
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,17 @@ class StdioMcpSyncClientTests extends AbstractMcpSyncClientTests {
3030

3131
@Override
3232
protected McpClientTransport createMcpTransport() {
33-
ServerParameters stdioParams = ServerParameters.builder("npx")
34-
.args("-y", "@modelcontextprotocol/server-everything", "dir")
35-
.build();
36-
33+
ServerParameters stdioParams;
34+
if (System.getProperty("os.name").toLowerCase().contains("win")) {
35+
stdioParams = ServerParameters.builder("cmd.exe")
36+
.args("/c", "npx.cmd", "-y", "@modelcontextprotocol/server-everything", "dir")
37+
.build();
38+
}
39+
else {
40+
stdioParams = ServerParameters.builder("npx")
41+
.args("-y", "@modelcontextprotocol/server-everything", "dir")
42+
.build();
43+
}
3744
return new StdioClientTransport(stdioParams);
3845
}
3946

0 commit comments

Comments
 (0)