ReadResourceResult.toMCP constructor

ReadResourceResult.toMCP(
  1. Map<String, Object?> map
)

Implementation

factory ReadResourceResult.toMCP(Map<String, Object?> map) {
  return ReadResourceResult(
    $meta: map['_meta'] != null
        ? ResultMetaObject.toMCP(map['_meta'] as Map<String, Object?>)
        : null,
    resultType: map['resultType'] as String? ?? 'complete',
    contents: (map['contents'] as List<dynamic>)
        .map((e) => ResourceContents.toMCP(e as Map<String, Object?>))
        .toList(),
    ttlMs: map['ttlMs'] as num,
    cacheScope: CacheScope.to(map['cacheScope'] as String),
    additionalData: Map.from(map)
      ..removeWhere(
        (key, _) =>
            key == '_meta' ||
            key == 'resultType' ||
            key == 'contents' ||
            key == 'ttlMs' ||
            key == 'cacheScope',
      ),
  );
}