From f856d0bb58fedf2235724cae2cba691c12a2c5af Mon Sep 17 00:00:00 2001 From: Jake Macdonald Date: Mon, 30 Jun 2025 14:20:42 -0700 Subject: [PATCH] remove the need for the experimental flag for the dart MCP server Closes https://github.com/dart-lang/ai/issues/167 Change-Id: Ib3555f3ef9a89704f9b3a501e909fbb3e6dc3f0d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/437820 Commit-Queue: Jake Macdonald Commit-Queue: Kenzie Davisson Auto-Submit: Jake Macdonald Reviewed-by: Kenzie Davisson --- .../lib/src/commands/dart_mcp_server.dart | 11 ++-- .../test/commands/mcp_server_test.dart | 51 +++++++++---------- 2 files changed, 29 insertions(+), 33 deletions(-) diff --git a/pkg/dartdev/lib/src/commands/dart_mcp_server.dart b/pkg/dartdev/lib/src/commands/dart_mcp_server.dart index f61229b7436..12083237176 100644 --- a/pkg/dartdev/lib/src/commands/dart_mcp_server.dart +++ b/pkg/dartdev/lib/src/commands/dart_mcp_server.dart @@ -12,9 +12,7 @@ class DartMCPServerCommand extends DartdevCommand { static const String cmdName = 'mcp-server'; static const String cmdDescription = ''' -A stdio based Model Context Protocol (MCP) server to aid in Dart and Flutter development. - -EXPERIMENTAL: This tool may change dramatically or disappear at any time.'''; +A stdio based Model Context Protocol (MCP) server to aid in Dart and Flutter development.'''; static const _forceRootsFallbackFlag = 'force-roots-fallback'; static const _experimentFlag = 'experimental-mcp-server'; @@ -33,6 +31,9 @@ EXPERIMENTAL: This tool may change dramatically or disappear at any time.'''; 'support it.', ) ..addFlag(_experimentFlag, + // This flag is no longer required but we are leaving it in for + // backwards compatibility. + hide: true, defaultsTo: false, help: 'A required flag in order to use this command. Passing this ' 'flag is an acknowledgement that you understand it is an ' @@ -45,10 +46,6 @@ EXPERIMENTAL: This tool may change dramatically or disappear at any time.'''; @override Future run() async { final args = argResults!; - if (!args.flag(_experimentFlag)) { - log.stderr('Missing required flag --$_experimentFlag\n\n$usage'); - return 64; - } try { VmInteropHandler.run( sdk.dartAotRuntime, diff --git a/pkg/dartdev/test/commands/mcp_server_test.dart b/pkg/dartdev/test/commands/mcp_server_test.dart index 071fc622636..4e189389bce 100644 --- a/pkg/dartdev/test/commands/mcp_server_test.dart +++ b/pkg/dartdev/test/commands/mcp_server_test.dart @@ -9,34 +9,33 @@ import 'package:test/test.dart'; void main() { group('dart mcp-server', () { - test('can be connected with a client', () async { - final client = TestMCPClient(); - addTearDown(client.shutdown); - final serverConnection = await client.connectStdioServer( - Platform.resolvedExecutable, - ['mcp-server', '--experimental-mcp-server']); - final initializeResult = await serverConnection.initialize( - InitializeRequest( - protocolVersion: ProtocolVersion.latestSupported, - capabilities: client.capabilities, - clientInfo: client.implementation)); + for (var withExperiment in const [true, false]) { + test( + 'can be connected with a client with${withExperiment ? '' : 'out'} the experiment flag', + () async { + final client = TestMCPClient(); + addTearDown(client.shutdown); + final serverConnection = + await client.connectStdioServer(Platform.resolvedExecutable, [ + 'mcp-server', + if (withExperiment) '--experimental-mcp-server', + ]); + final initializeResult = await serverConnection.initialize( + InitializeRequest( + protocolVersion: ProtocolVersion.latestSupported, + capabilities: client.capabilities, + clientInfo: client.implementation)); - expect(initializeResult.protocolVersion, ProtocolVersion.latestSupported); - serverConnection.notifyInitialized(); + expect( + initializeResult.protocolVersion, ProtocolVersion.latestSupported); + serverConnection.notifyInitialized(); - expect( - await serverConnection.listTools(ListToolsRequest()), - isNotEmpty, - ); - }); - - test('requires the --experimental-mcp-server flag', () async { - final processResult = - await Process.run(Platform.resolvedExecutable, ['mcp-server']); - expect(processResult.exitCode, isNot(0)); - expect(processResult.stderr, - contains('Missing required flag --experimental-mcp-server')); - }); + expect( + await serverConnection.listTools(ListToolsRequest()), + isNotEmpty, + ); + }); + } }); }