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 project = ServerPodLocator.getProject();
if (project == null || !project.isValid) {
return {
'error': 'Not a valid ServerPod project',
'message': 'Could not detect a valid ServerPod project structure',
};
}
// Get ServerPod version from pubspec.yaml
final serverpodVersion = await _getServerpodVersion(project.serverPath!);
// Get database config
final dbConfig = await _getDatabaseConfig(project);
// Get all endpoints
final endpointFiles = project.endpointFiles;
final endpoints = <String, dynamic>{};
for (final file in endpointFiles) {
final methods = await _parseEndpointMethods(file);
// Extract endpoint name from file path
final name = _extractEndpointName(file);
endpoints[name] = {
'file': file,
'methods': methods,
};
}
// Get all models
final models = project.models;
final modelList = models.map((m) => {
'className': m.className,
'namespace': m.namespace,
'fields': m.fields.map((f) => {
'name': f.name,
'type': f.dartType,
}).toList(),
}).toList();
return {
'project': {
'root': project.rootPath,
'server': project.serverPath,
'client': project.clientPath,
'flutter': project.flutterPath,
'config': project.configPath,
'migrations': project.migrationsPath,
},
'versions': {
'dart': _getDartVersion(),
'serverpod': serverpodVersion,
},
'database': dbConfig,
'endpoints': endpoints,
'models': modelList,
'endpointCount': endpoints.length,
'modelCount': models.length,
};
}