McpResponse.fromJson constructor

McpResponse.fromJson(
  1. Map<String, dynamic> json
)

Create response from JSON map

Implementation

factory McpResponse.fromJson(Map<String, dynamic> json) {
  final id = json['id'] as String;
  final errorJson = json['error'] as Map<String, dynamic>?;

  if (errorJson != null) {
    return McpResponse(
      id: id,
      error: McpError.fromJson(errorJson),
    );
  }

  return McpResponse(
    id: id,
    result: json['result'],
  );
}