diff --git a/.github/workflows/dart_mcp_server.yaml b/.github/workflows/dart_mcp_server.yaml index 0cb3a64..e3c7e46 100644 --- a/.github/workflows/dart_mcp_server.yaml +++ b/.github/workflows/dart_mcp_server.yaml
@@ -36,12 +36,12 @@ steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 - name: Cache Pub hosted dependencies - uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf + uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 with: path: "~/.pub-cache/hosted" key: "pub-cache-hosted;${{ matrix.flutterSdk }};${{ matrix.os }}" - name: Cache Pub sdk git dependency - uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf + uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 with: path: "~/.pub-cache/git/sdk-b0838eac58308fc4e6654ca99eda75b30649c08f/" key: "pub-cache-git;${{ matrix.flutterSdk }};${{ matrix.os }}"
diff --git a/pkgs/dart_mcp_server/lib/arg_parser.dart b/pkgs/dart_mcp_server/lib/arg_parser.dart index ccb7844..cc03a91 100644 --- a/pkgs/dart_mcp_server/lib/arg_parser.dart +++ b/pkgs/dart_mcp_server/lib/arg_parser.dart
@@ -2,4 +2,4 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -export 'src/arg_parser.dart' show argParser; +export 'src/arg_parser.dart' show createArgParser;
diff --git a/pkgs/dart_mcp_server/lib/src/arg_parser.dart b/pkgs/dart_mcp_server/lib/src/arg_parser.dart index ac02e11..a58f8b5 100644 --- a/pkgs/dart_mcp_server/lib/src/arg_parser.dart +++ b/pkgs/dart_mcp_server/lib/src/arg_parser.dart
@@ -4,37 +4,54 @@ import 'package:args/args.dart'; -final argParser = ArgParser(allowTrailingOptions: false) - ..addOption( - dartSdkOption, - help: - 'The path to the root of the desired Dart SDK. Defaults to the ' - 'DART_SDK environment variable.', - ) - ..addOption( - flutterSdkOption, - help: - 'The path to the root of the desired Flutter SDK. Defaults to ' - 'the FLUTTER_SDK environment variable, then searching up from ' - 'the Dart SDK.', - ) - ..addFlag( - forceRootsFallbackFlag, - negatable: true, - defaultsTo: false, - help: - 'Forces a behavior for project roots which uses MCP tools ' - 'instead of the native MCP roots. This can be helpful for ' - 'clients like cursor which claim to have roots support but do ' - 'not actually support it.', - ) - ..addOption( - logFileOption, - help: - 'Path to a file to log all MPC protocol traffic to. File will be ' - 'overwritten if it exists.', - ) - ..addFlag(helpFlag, abbr: 'h', help: 'Show usage text'); +/// Creates an arg parser for th MCP server. +/// +/// The `--help` option is only included if [includeHelp] is `true`. +/// +/// Passing no options results in the default arg parser. +ArgParser createArgParser({ + bool includeHelp = true, + bool allowTrailingOptions = false, + int? usageLineLength, +}) { + final parser = + ArgParser( + allowTrailingOptions: allowTrailingOptions, + usageLineLength: usageLineLength, + ) + ..addOption( + dartSdkOption, + help: + 'The path to the root of the desired Dart SDK. Defaults to the ' + 'DART_SDK environment variable.', + ) + ..addOption( + flutterSdkOption, + help: + 'The path to the root of the desired Flutter SDK. Defaults to ' + 'the FLUTTER_SDK environment variable, then searching up from ' + 'the Dart SDK.', + ) + ..addFlag( + forceRootsFallbackFlag, + negatable: true, + defaultsTo: false, + help: + 'Forces a behavior for project roots which uses MCP tools ' + 'instead of the native MCP roots. This can be helpful for ' + 'clients like cursor which claim to have roots support but do ' + 'not actually support it.', + ) + ..addOption( + logFileOption, + help: + 'Path to a file to log all MPC protocol traffic to. File will be ' + 'overwritten if it exists.', + ); + + if (includeHelp) parser.addFlag(helpFlag, abbr: 'h', help: 'Show usage text'); + return parser; +} const dartSdkOption = 'dart-sdk'; const flutterSdkOption = 'flutter-sdk';
diff --git a/pkgs/dart_mcp_server/lib/src/server.dart b/pkgs/dart_mcp_server/lib/src/server.dart index e28645f..b874182 100644 --- a/pkgs/dart_mcp_server/lib/src/server.dart +++ b/pkgs/dart_mcp_server/lib/src/server.dart
@@ -144,6 +144,9 @@ } } + /// The default arg parser for the MCP Server. + static final argParser = createArgParser(); + @override final LocalProcessManager processManager;