From d3f580aad0ac2fefc41d2e5c466e2351a1a074d2 Mon Sep 17 00:00:00 2001 From: Jake Macdonald Date: Wed, 30 Jul 2025 15:01:35 +0000 Subject: [PATCH 1/3] only run in shell when on windows and running a .bat file --- pkgs/dart_mcp_server/lib/src/utils/cli_utils.dart | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkgs/dart_mcp_server/lib/src/utils/cli_utils.dart b/pkgs/dart_mcp_server/lib/src/utils/cli_utils.dart index 524f0e3d..c66fdb16 100644 --- a/pkgs/dart_mcp_server/lib/src/utils/cli_utils.dart +++ b/pkgs/dart_mcp_server/lib/src/utils/cli_utils.dart @@ -3,6 +3,7 @@ // BSD-style license that can be found in the LICENSE file. import 'dart:async'; +import 'dart:io' as io; import 'package:collection/collection.dart'; import 'package:dart_mcp/server.dart'; @@ -224,7 +225,10 @@ Future runCommandInRoot( final result = await processManager.run( commandWithPaths, workingDirectory: workingDir.path, - runInShell: true, + runInShell: + // Required when running .bat files on windows, but otherwise should + // be avoided. + io.Platform.isWindows && commandWithPaths.first.endsWith('.bat'), ); final output = (result.stdout as String).trim(); From ab0cddb5e4795c139686da697b406fe844738f81 Mon Sep 17 00:00:00 2001 From: Jake Macdonald Date: Wed, 30 Jul 2025 15:03:29 +0000 Subject: [PATCH 2/3] update changelog --- pkgs/dart_mcp/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/dart_mcp/CHANGELOG.md b/pkgs/dart_mcp/CHANGELOG.md index e85f132e..6b84accd 100644 --- a/pkgs/dart_mcp/CHANGELOG.md +++ b/pkgs/dart_mcp/CHANGELOG.md @@ -8,6 +8,7 @@ - The old `reject` enum value was replaced with a static constant equal exactly to `decline`, so switches are not affected. - Add `title` parameter to `Prompt` constructor. +- Only execute sub-processes in a shell if they are `.bat` files. ## 0.3.2 From 9c42e5dbcca16882571c0c5d2ae86b44fcbcc187 Mon Sep 17 00:00:00 2001 From: Jacob MacDonald Date: Wed, 30 Jul 2025 12:34:28 -0700 Subject: [PATCH 3/3] Apply suggestion from @jakemac53 --- pkgs/dart_mcp_server/lib/src/utils/cli_utils.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/dart_mcp_server/lib/src/utils/cli_utils.dart b/pkgs/dart_mcp_server/lib/src/utils/cli_utils.dart index c66fdb16..9b595e39 100644 --- a/pkgs/dart_mcp_server/lib/src/utils/cli_utils.dart +++ b/pkgs/dart_mcp_server/lib/src/utils/cli_utils.dart @@ -227,7 +227,7 @@ Future runCommandInRoot( workingDirectory: workingDir.path, runInShell: // Required when running .bat files on windows, but otherwise should - // be avoided. + // be avoided due to escaping behavior. io.Platform.isWindows && commandWithPaths.first.endsWith('.bat'), );