According to the specification, `destructive_hint`, `idempotent_hint`, `open_world_hint`, and `read_only_hint` of `ToolAnnotations` are optional with default values: https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations This PR sets their default values in accordance with the specification. Additionally, for readability, the hints have been reordered to follow the specification.
27 lines
767 B
Ruby
27 lines
767 B
Ruby
# frozen_string_literal: true
|
|
|
|
module MCP
|
|
class Tool
|
|
class Annotations
|
|
attr_reader :destructive_hint, :idempotent_hint, :open_world_hint, :read_only_hint, :title
|
|
|
|
def initialize(destructive_hint: true, idempotent_hint: false, open_world_hint: true, read_only_hint: false, title: nil)
|
|
@title = title
|
|
@read_only_hint = read_only_hint
|
|
@destructive_hint = destructive_hint
|
|
@idempotent_hint = idempotent_hint
|
|
@open_world_hint = open_world_hint
|
|
end
|
|
|
|
def to_h
|
|
{
|
|
destructiveHint: destructive_hint,
|
|
idempotentHint: idempotent_hint,
|
|
openWorldHint: open_world_hint,
|
|
readOnlyHint: read_only_hint,
|
|
title:,
|
|
}.compact
|
|
end
|
|
end
|
|
end
|
|
end
|