Skip to content

Commit 90f6f78

Browse files
committed
add npx installation, adjust stdio unittests that use npx to work; add Jenkinsfile for builds
1 parent 991aa4a commit 90f6f78

File tree

4 files changed

+55
-15
lines changed

4 files changed

+55
-15
lines changed

Jenkinsfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
sproutMultiModuleBuild {
2+
moduleToBuild = 'mcp-parent'
3+
nodeLabel = 'ephemeral'
4+
tribes = ['global']
5+
notifySlackGroupsOnFailure = ['@kevin']
6+
jdk = 17
7+
deployRCBranches = true
8+
}

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

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,21 @@ class StdioMcpAsyncClientTests extends AbstractMcpAsyncClientTests {
2323
@Override
2424
protected McpClientTransport createMcpTransport() {
2525
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", "stdio")
29-
.build();
30-
}
26+
String currentPath = System.getenv("PATH");
27+
String nodePath = System.getProperty("user.dir") + "/node";
28+
String newPath = nodePath + (currentPath != null ? System.getProperty("path.separator") + currentPath : "");
29+
30+
if (System.getProperty("os.name").toLowerCase().contains("win")) {
31+
stdioParams = ServerParameters.builder("./node/npx.cmd")
32+
.args("-y", "@modelcontextprotocol/server-everything", "stdio")
33+
.addEnvVar("PATH", newPath)
34+
.build();
35+
}
3136
else {
32-
stdioParams = ServerParameters.builder("npx")
33-
.args("-y", "@modelcontextprotocol/server-everything", "stdio")
34-
.build();
37+
stdioParams = ServerParameters.builder("./node/npx")
38+
.args("-y", "@modelcontextprotocol/server-everything", "stdio")
39+
.addEnvVar("PATH", newPath)
40+
.build();
3541
}
3642
return new StdioClientTransport(stdioParams);
3743
}

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,21 @@ class StdioMcpSyncClientTests extends AbstractMcpSyncClientTests {
3131
@Override
3232
protected McpClientTransport createMcpTransport() {
3333
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", "stdio")
34+
String currentPath = System.getenv("PATH");
35+
String nodePath = System.getProperty("user.dir") + "/node";
36+
String newPath = nodePath + (currentPath != null ? System.getProperty("path.separator") + currentPath : "");
37+
38+
if (System.getProperty("os.name").toLowerCase().contains("win")) {
39+
stdioParams = ServerParameters.builder("./node/npx.cmd")
40+
.args("-y", "@modelcontextprotocol/server-everything", "stdio")
41+
.addEnvVar("PATH", newPath)
3742
.build();
3843
}
3944
else {
40-
stdioParams = ServerParameters.builder("npx")
41-
.args("-y", "@modelcontextprotocol/server-everything", "stdio")
42-
.build();
45+
stdioParams = ServerParameters.builder("./node/npx")
46+
.args("-y", "@modelcontextprotocol/server-everything", "stdio")
47+
.addEnvVar("PATH", newPath)
48+
.build();
4349
}
4450
return new StdioClientTransport(stdioParams);
4551
}

pom.xml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
<bnd-maven-plugin.version>7.1.0</bnd-maven-plugin.version>
9898
<json-unit-assertj.version>4.1.0</json-unit-assertj.version>
9999
<json-schema-validator.version>1.5.7</json-schema-validator.version>
100+
<frontend-maven-plugin.version>1.15.1</frontend-maven-plugin.version>
100101

101102
</properties>
102103

@@ -259,7 +260,26 @@
259260
<artifactId>maven-deploy-plugin</artifactId>
260261
<version>${maven-deploy-plugin.version}</version>
261262
</plugin>
262-
</plugins>
263+
<plugin>
264+
<groupId>com.github.eirslett</groupId>
265+
<artifactId>frontend-maven-plugin</artifactId>
266+
<version>${frontend-maven-plugin.version}</version>
267+
<executions>
268+
<execution>
269+
<id>install node and npm</id>
270+
<goals>
271+
<goal>install-node-and-npm</goal>
272+
</goals>
273+
<phase>generate-test-resources</phase>
274+
<configuration>
275+
<nodeVersion>v18.19.0</nodeVersion>
276+
<npmVersion>10.2.4</npmVersion>
277+
</configuration>
278+
</execution>
279+
</executions>
280+
</plugin>
281+
282+
</plugins>
263283
</build>
264284

265285
<profiles>

0 commit comments

Comments
 (0)