run method
Runs this command.
The return value is wrapped in a Future if necessary and returned by
CommandRunner.runCommand.
Implementation
@override
Future<bool> run() async {
final limits = this.limits;
final repository = this.repository;
final repoConfig = this.repoConfig;
final httpPort = argResults!['http'] as String?;
if (httpPort != null) {
final port = int.tryParse(httpPort.trim());
if (port == null) {
throw StateError("Invalid port for --http: $httpPort");
}
final host = argResults!['host'] as String;
final transport = HttpSseTransport(
limits: limits,
repository: repository,
repoConfig: repoConfig,
);
await transport.start(port: port, host: host);
stderr.writeln(
'ApolloVM MCP server (HTTP/SSE) listening on http://$host:$port/sse',
);
await Completer<void>().future; // serve until terminated
return true;
}
final server = serveStdio(
limits: limits,
repository: repository,
repoConfig: repoConfig,
);
await server.done;
return true;
}