run method

  1. @override
bool run()
override

Runs this command.

The return value is wrapped in a Future if necessary and returned by CommandRunner.runCommand.

Implementation

@override
bool run() {
  const limits = McpLimits();
  // The repository tools are enabled only when a workspace is configured.
  final withRepo = argResults!['workspace'] != null;
  final info = <String, Object?>{
    'server': 'apollovm-mcp',
    'version': ApolloVM.VERSION,
    'protocol': ProtocolVersion.latestSupported.versionString,
    'transports': ['stdio', 'http-sse'],
    'tools': allToolNames,
    if (withRepo) 'repositoryTools': repoToolNames,
    'languages': mcpSupportedLanguages,
    'limits': {
      'timeoutMs': limits.timeoutMs,
      'maxOutputChars': limits.maxOutputChars,
      'maxSourceChars': limits.maxSourceChars,
      'isolateTools': limits.isolateTools.toList(),
    },
  };

  if (argResults!['json'] as bool) {
    print(_json.convert(info));
  } else {
    print('server:     ${info['server']} ${info['version']}');
    print('protocol:   ${info['protocol']}');
    print('transports: ${(info['transports'] as List).join(', ')}');
    print('tools:      ${(info['tools'] as List).join(', ')}');
    if (withRepo) {
      print('repo tools: ${(info['repositoryTools'] as List).join(', ')}');
    } else {
      print(
        'repo tools: ${repoToolNames.length} available with --workspace '
        '(fs/search/code/git)',
      );
    }
    print('languages:  ${(info['languages'] as List).join(', ')}');
    final l = info['limits'] as Map;
    print(
      'limits:     timeoutMs=${l['timeoutMs']} '
      'maxOutputChars=${l['maxOutputChars']} '
      'maxSourceChars=${l['maxSourceChars']} '
      'isolateTools=${(l['isolateTools'] as List).join(',')}',
    );
  }
  return true;
}