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 filter = params['filter'] as String?;
  final project = ServerPodLocator.getProject();

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

  final models = project.models;
  final results = <Map<String, dynamic>>[];

  for (final model in models) {
    // Apply filter if provided
    if (filter != null && !model.className.toLowerCase().contains(filter.toLowerCase())) {
      continue;
    }

    results.add({
      'className': model.className,
      'namespace': model.namespace,
      'fieldCount': model.fields.length,
      'fields': model.fields.map((f) => {
        'name': f.name,
        'type': f.type,
        'dartType': f.dartType,
        'isOptional': f.isOptional,
      }).toList(),
      'sourceFile': model.filePath,
    });
  }

  return {
    'models': results,
    'count': results.length,
  };
}