Skip to content

Commit 8b3c7d2

Browse files
committed
install node for integration tests
1 parent 5d69dc7 commit 8b3c7d2

File tree

3 files changed

+39
-6
lines changed

3 files changed

+39
-6
lines changed

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,21 @@ class StdioMcpAsyncClientTests extends AbstractMcpAsyncClientTests {
2323
@Override
2424
protected McpClientTransport createMcpTransport() {
2525
ServerParameters stdioParams;
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+
System.out.println("✅Using PATH: " + newPath);
30+
2631
if (System.getProperty("os.name").toLowerCase().contains("win")) {
27-
stdioParams = ServerParameters.builder("cmd.exe")
28-
.args("/c", "npx.cmd", "-y", "@modelcontextprotocol/server-everything", "stdio")
32+
stdioParams = ServerParameters.builder("./node/npx.cmd")
33+
.args("-y", "@modelcontextprotocol/server-everything", "stdio")
34+
.addEnvVar("PATH", newPath)
2935
.build();
3036
}
3137
else {
32-
stdioParams = ServerParameters.builder("npx")
38+
stdioParams = ServerParameters.builder("./node/npx")
3339
.args("-y", "@modelcontextprotocol/server-everything", "stdio")
40+
.addEnvVar("PATH", newPath)
3441
.build();
3542
}
3643
return new StdioClientTransport(stdioParams);

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,21 @@ class StdioMcpSyncClientTests extends AbstractMcpSyncClientTests {
3131
@Override
3232
protected McpClientTransport createMcpTransport() {
3333
ServerParameters stdioParams;
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+
System.out.println("✅Using PATH: " + newPath);
38+
3439
if (System.getProperty("os.name").toLowerCase().contains("win")) {
35-
stdioParams = ServerParameters.builder("cmd.exe")
36-
.args("/c", "npx.cmd", "-y", "@modelcontextprotocol/server-everything", "stdio")
40+
stdioParams = ServerParameters.builder("./node/npx.cmd")
41+
.args("-y", "@modelcontextprotocol/server-everything", "stdio")
42+
.addEnvVar("PATH", newPath)
3743
.build();
3844
}
3945
else {
40-
stdioParams = ServerParameters.builder("npx")
46+
stdioParams = ServerParameters.builder("./node/npx")
4147
.args("-y", "@modelcontextprotocol/server-everything", "stdio")
48+
.addEnvVar("PATH", newPath)
4249
.build();
4350
}
4451
return new StdioClientTransport(stdioParams);

pom.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
<maven-project-info-reports-plugin.version>3.4.5</maven-project-info-reports-plugin.version>
8888
<maven-jar-plugin.version>3.3.0</maven-jar-plugin.version>
8989
<spring-javaformat-maven-plugin.version>0.0.43</spring-javaformat-maven-plugin.version>
90+
<frontend-maven-plugin.version>1.15.1</frontend-maven-plugin.version>
9091
<org.maven.antora-version>1.0.0-alpha.4</org.maven.antora-version>
9192
<io.spring.maven.antora-version>0.0.4</io.spring.maven.antora-version>
9293
<asciidoctorj-pdf.version>1.6.2</asciidoctorj-pdf.version>
@@ -124,6 +125,24 @@
124125
</execution>
125126
</executions>
126127
</plugin>
128+
<plugin>
129+
<groupId>com.github.eirslett</groupId>
130+
<artifactId>frontend-maven-plugin</artifactId>
131+
<version>${frontend-maven-plugin.version}</version>
132+
<executions>
133+
<execution>
134+
<id>install node and npm</id>
135+
<goals>
136+
<goal>install-node-and-npm</goal>
137+
</goals>
138+
<phase>generate-test-resources</phase>
139+
<configuration>
140+
<nodeVersion>v18.19.0</nodeVersion>
141+
<npmVersion>10.2.4</npmVersion>
142+
</configuration>
143+
</execution>
144+
</executions>
145+
</plugin>
127146
<plugin>
128147
<groupId>org.apache.maven.plugins</groupId>
129148
<artifactId>maven-site-plugin</artifactId>

0 commit comments

Comments
 (0)