7
7
8
8
import static software .amazon .smithy .java .io .ByteBufferUtils .getBytes ;
9
9
10
- import java .io .BufferedReader ;
11
10
import java .io .IOException ;
12
- import java .io .InputStreamReader ;
13
11
import java .nio .charset .StandardCharsets ;
14
12
import java .nio .file .Files ;
15
13
import java .nio .file .Path ;
@@ -312,7 +310,7 @@ public static McpBundleConfig addMcpBundle(Config config, String id, Bundle bund
312
310
.build ());
313
311
case genericBundle -> {
314
312
GenericBundle genericBundle = bundle .getValue ();
315
- validate (genericBundle );
313
+ validate (genericBundle , id );
316
314
install (genericBundle .getInstall ());
317
315
builder .genericConfig (
318
316
GenericToolBundleConfig .builder ()
@@ -331,9 +329,9 @@ public static McpBundleConfig addMcpBundle(Config config, String id, Bundle bund
331
329
return mcpBundleConfig ;
332
330
}
333
331
334
- private static void validate (GenericBundle genericBundle ) {
332
+ private static void validate (GenericBundle genericBundle , String id ) {
335
333
if (!genericBundle .isExecuteDirectly () &&
336
- genericBundle .getRun ().getExecutable ().equals (genericBundle . getMetadata (). getId () )) {
334
+ genericBundle .getRun ().getExecutable ().equals (id )) {
337
335
throw new IllegalStateException (
338
336
"The generic MCP run command has the same value as id which isn't allowed." );
339
337
}
@@ -346,10 +344,10 @@ private static void install(List<ExecSpec> execSpecs) {
346
344
ProcessBuilder pb = new ProcessBuilder (execSpec .getExecutable ());
347
345
pb .command ().addAll (execSpec .getArgs ());
348
346
pb .redirectErrorStream (true );
347
+ pb .redirectOutput (ProcessBuilder .Redirect .INHERIT );
349
348
Process process = null ;
350
349
try {
351
350
process = pb .start ();
352
- String output = captureProcessOutput (process );
353
351
354
352
boolean finished = process .waitFor (5 , TimeUnit .MINUTES );
355
353
@@ -364,8 +362,7 @@ private static void install(List<ExecSpec> execSpecs) {
364
362
throw new RuntimeException (String .format (
365
363
"Installation failed with exit code %d. Command: %s. Output: %s" ,
366
364
exitCode ,
367
- String .join (" " , pb .command ()),
368
- output ));
365
+ String .join (" " , pb .command ())));
369
366
}
370
367
371
368
} catch (InterruptedException e ) {
@@ -388,13 +385,6 @@ private static void install(List<ExecSpec> execSpecs) {
388
385
}
389
386
}
390
387
391
- private static String captureProcessOutput (Process process ) throws IOException {
392
- try (BufferedReader in =
393
- new BufferedReader (new InputStreamReader (process .getInputStream (), StandardCharsets .UTF_8 ))) {
394
- return in .lines ().collect (Collectors .joining (System .lineSeparator ()));
395
- }
396
- }
397
-
398
388
public static void createWrapperScript (String id ) throws IOException {
399
389
Path scriptPath = SHIMS_DIR .resolve (id );
400
390
String scriptContent = createScriptContent (id );
0 commit comments