Tool.fromJson constructor
Implementation
factory Tool.fromJson(Map<String, dynamic> json) {
return Tool(
name: json['name'] as String,
title: json['title'] as String?,
// `description` is OPTIONAL per the MCP spec (schema.ts
// `description?: string`) — a spec-conforming server may omit it. A
// non-null cast here made `tools/list` parsing throw `type 'Null' is
// not a subtype of type 'String'` against such servers; tolerate
// absence with an empty string (the field stays non-null).
description: json['description'] as String? ?? '',
inputSchema: json['inputSchema'] as Map<String, dynamic>,
outputSchema: json['outputSchema'] as Map<String, dynamic>?,
icons: (json['icons'] as List?)
?.map((e) => Map<String, dynamic>.from(e as Map))
.toList(),
meta: json['_meta'] as Map<String, dynamic>?,
supportsProgress: json['supportsProgress'] as bool?,
supportsCancellation: json['supportsCancellation'] as bool?,
metadata: json['metadata'] as Map<String, dynamic>?,
);
}