ToolSpec.fromJson constructor

ToolSpec.fromJson(
  1. Map<String, Object?> json
)

Reads the protocol's tool object, as tools/list sends it.

Implementation

factory ToolSpec.fromJson(Map<String, Object?> json) => ToolSpec(
  name: json['name']! as String,
  description: json['description'] as String?,
  inputSchema:
      _object(json['inputSchema']) ??
      const <String, Object?>{'type': 'object'},
  outputSchema: _object(json['outputSchema']),
  hints: switch (_object(json['annotations'])) {
    final Map<String, Object?> a => ToolHints.fromJson(a),
    null => ToolHints.writes,
  },
  meta: _object(json['_meta']) ?? const <String, Object?>{},
);