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 <jakemac@google.com> Commit-Queue: Kenzie Davisson <kenzieschmoll@google.com> Auto-Submit: Jake Macdonald <jakemac@google.com> Reviewed-by: Kenzie Davisson <kenzieschmoll@google.com>
This commit is contained in:
committed by
Commit Queue
parent
4fe15314df
commit
f856d0bb58
@@ -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<int> 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,
|
||||
|
||||
@@ -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,
|
||||
);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user