Skip to content

Commit aacafbf

Browse files
Mrunal Patiladwsingh
authored andcommitted
add workingDirectory to StdioProxy
1 parent ffee5d0 commit aacafbf

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

  • mcp/mcp-server/src/main/java/software/amazon/smithy/java/mcp/server

mcp/mcp-server/src/main/java/software/amazon/smithy/java/mcp/server/StdioProxy.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import java.io.BufferedReader;
1111
import java.io.BufferedWriter;
12+
import java.io.File;
1213
import java.io.IOException;
1314
import java.io.InputStreamReader;
1415
import java.io.OutputStreamWriter;
@@ -53,6 +54,11 @@ private StdioProxy(Builder builder) {
5354
processBuilder.environment().putAll(builder.environmentVariables);
5455
}
5556

57+
// Set working directory if provided
58+
if (builder.workingDirectory != null) {
59+
processBuilder.directory(builder.workingDirectory);
60+
}
61+
5662
this.name = builder.name;
5763

5864
processBuilder.redirectErrorStream(false); // Keep stderr separate
@@ -63,6 +69,7 @@ public static class Builder {
6369
private String name;
6470
private List<String> arguments;
6571
private Map<String, String> environmentVariables;
72+
private File workingDirectory;
6673

6774
public Builder name(String name) {
6875
this.name = name;
@@ -84,6 +91,11 @@ public Builder environmentVariables(Map<String, String> environmentVariables) {
8491
return this;
8592
}
8693

94+
public Builder workingDirectory(File workingDirectory) {
95+
this.workingDirectory = workingDirectory;
96+
return this;
97+
}
98+
8799
public StdioProxy build() {
88100
if (command == null || command.isEmpty()) {
89101
throw new IllegalArgumentException("Command must be provided");

0 commit comments

Comments
 (0)