executeImpl method

  1. @override
Future executeImpl(
  1. Map<String, dynamic> params
)
override

Implement the actual tool logic

params are the validated parameters (never null here) Returns the result data to send in the response

Implementation

@override
Future<dynamic> executeImpl(Map<String, dynamic> params) async {
  final tableFilter = params['table_filter'] as String?;
  final project = ServerPodLocator.getProject();

  if (project == null || !project.isValid) {
    return {'error': 'Not a valid ServerPod project'};
  }

  final migrationFiles = project.migrationFiles;
  final tables = <String, Map<String, dynamic>>{};

  for (final file in migrationFiles) {
    final content = await file.readAsString();
    _parseMigrationFile(content, tables);
  }

  // Apply filter if provided
  var filteredTables = tables;
  if (tableFilter != null) {
    filteredTables = Map.fromEntries(
      tables.entries.where((e) =>
        e.key.toLowerCase().contains(tableFilter.toLowerCase())
      ),
    );
  }

  return {
    'tables': filteredTables.entries.map((e) => {
      'name': e.key,
      ...e.value,
    }).toList(),
    'tableCount': filteredTables.length,
    'migrationCount': migrationFiles.length,
  };
}