executeImpl method
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 modelName = params['model_name'] as String;
final project = ServerPodLocator.getProject();
if (project == null || !project.isValid) {
return {'error': 'Not a valid ServerPod project'};
}
// Find the model
final models = project.models;
SpyYamlModel? targetModel;
for (final model in models) {
if (model.className == modelName) {
targetModel = model;
break;
}
}
if (targetModel == null) {
return {
'error': 'Model not found',
'model_name': modelName,
'available_models': models.map((m) => m.className).toList(),
};
}
return {
'className': targetModel.className,
'namespace': targetModel.namespace,
'sourceFile': targetModel.filePath,
'fieldCount': targetModel.fields.length,
'fields': targetModel.fields.map((f) => {
'name': f.name,
'type': f.type,
'dartType': f.dartType,
'isOptional': f.isOptional,
'isScalar': _isScalarType(f.type),
'isRelation': _isRelationType(f.type),
}).toList(),
};
}