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 endpointName = params['endpoint_name'] as String;
final project = ServerPodLocator.getProject();
if (project == null || !project.isValid) {
return {'error': 'Not a valid ServerPod project'};
}
// Find the endpoint file
String? endpointFile;
for (final file in project.endpointFiles) {
final name = _extractEndpointName(file);
if (name == endpointName) {
endpointFile = file;
break;
}
}
if (endpointFile == null) {
return {
'error': 'Endpoint not found',
'endpoint_name': endpointName,
'available_endpoints': project.endpointFiles.map(_extractEndpointName).toList(),
};
}
final methods = MethodParser.parseFile(endpointFile);
return {
'endpoint': endpointName,
'file': endpointFile,
'methods': methods.map((m) => {
'name': m.name,
'returnType': m.returnType,
'signature': m.signature,
'parameters': m.parameters.map((p) => {
'type': p.type,
'name': p.name,
'isSession': p.isSession,
}).toList(),
'userParameters': m.userParameters.map((p) => {
'type': p.type,
'name': p.name,
}).toList(),
}).toList(),
'methodCount': methods.length,
};
}