copyWith method

Tool copyWith({
  1. String? description,
  2. Map<String, Object?>? inputSchema,
  3. String? name,
  4. ToolAnnotations? annotations,
  5. Map<String, Object?>? meta,
  6. Map<String, Object?>? outputSchema,
  7. String? title,
  8. ToolExecution? execution,
  9. List<McpIcon>? icons,
})

A copy with the given properties replaced; everything else, unknown keys included, is kept.

Implementation

Tool copyWith({
  String? description,
  Map<String, Object?>? inputSchema,
  String? name,
  ToolAnnotations? annotations,
  Map<String, Object?>? meta,
  Map<String, Object?>? outputSchema,
  String? title,
  ToolExecution? execution,
  List<McpIcon>? icons,
}) =>
    Tool.fromJson({
      ...toJson(),
      if (description != null) 'description': $encode(description),
      if (inputSchema != null) 'inputSchema': $encode(inputSchema),
      if (name != null) 'name': $encode(name),
      if (annotations != null) 'annotations': $encode(annotations),
      if (meta != null) '_meta': $encode(meta),
      if (outputSchema != null) 'outputSchema': $encode(outputSchema),
      if (title != null) 'title': $encode(title),
      if (execution != null) 'execution': $encode(execution),
      if (icons != null) 'icons': $encode(icons),
    });