getPrompt method
Get a prompt from the server
Implementation
Future<GetPromptResult> getPrompt(
String name, [
Map<String, dynamic>? promptArguments,
]) async {
if (!_initialized) {
throw McpError('Client is not initialized');
}
if (_serverCapabilities?.prompts != true) {
throw McpError('Server does not support prompts');
}
// Create a new map to hold params to avoid direct modification
final Map<String, dynamic> params = {'name': name};
// Only add arguments if provided, and ensure it's a proper Map<String, dynamic>
if (promptArguments != null) {
params['arguments'] = Map<String, dynamic>.from(promptArguments);
}
final response = await _sendRequest('prompts/get', params);
return GetPromptResult.fromJson(response);
}