Class: LittleGhost::MCP::Definition
- Inherits:
-
Data
- Object
- Data
- LittleGhost::MCP::Definition
- Defined in:
- lib/little_ghost/mcp/types.rb,
lib/little_ghost/mcp/types.rb
Overview
Immutable server-advertised Tool metadata. source_name is always the
name sent back to the server; name is the initially generated
model-facing name and may later be customized on the generated Tool class.
Instance Attribute Summary collapse
-
#annotations ⇒ Object
readonly
Returns the value of attribute annotations.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#input_schema ⇒ Object
readonly
Returns the value of attribute input_schema.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#output_schema ⇒ Object
readonly
Returns the value of attribute output_schema.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
-
#source_name ⇒ Object
readonly
Returns the value of attribute source_name.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #dig ⇒ Object
- #fetch ⇒ Object
-
#initialize(source_name:, name:, description:, input_schema:, raw:, output_schema: nil, annotations: {}, title: nil, metadata: {}) ⇒ Definition
constructor
A new instance of Definition.
- #key?(key) ⇒ Boolean
Constructor Details
#initialize(source_name:, name:, description:, input_schema:, raw:, output_schema: nil, annotations: {}, title: nil, metadata: {}) ⇒ Definition
Returns a new instance of Definition.
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/little_ghost/mcp/types.rb', line 60 def initialize(source_name:, name:, description:, input_schema:, raw:, output_schema: nil, annotations: {}, title: nil, metadata: {}) source_name = String(source_name) name = String(name) raise ProtocolError, "MCP tool definition must include a name" if source_name.empty? raise ConfigurationError, "MCP tool name cannot be empty" if name.empty? super( source_name: source_name.freeze, name: name.freeze, description: String(description).freeze, input_schema: ImmutableValue.mapping(input_schema, field: "tool inputSchema"), output_schema: ImmutableValue.optional_mapping(output_schema, field: "tool outputSchema"), annotations: ImmutableValue.mapping(annotations, field: "tool annotations"), title: title.nil? ? nil : String(title).freeze, metadata: ImmutableValue.mapping(, field: "tool _meta"), raw: ImmutableValue.mapping(raw, field: "tool definition") ) rescue TypeError raise ProtocolError, "MCP tool definition is invalid" end |
Instance Attribute Details
#annotations ⇒ Object (readonly)
Returns the value of attribute annotations
49 50 51 |
# File 'lib/little_ghost/mcp/types.rb', line 49 def annotations @annotations end |
#description ⇒ Object (readonly)
Returns the value of attribute description
49 50 51 |
# File 'lib/little_ghost/mcp/types.rb', line 49 def description @description end |
#input_schema ⇒ Object (readonly)
Returns the value of attribute input_schema
49 50 51 |
# File 'lib/little_ghost/mcp/types.rb', line 49 def input_schema @input_schema end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata
49 50 51 |
# File 'lib/little_ghost/mcp/types.rb', line 49 def @metadata end |
#name ⇒ Object (readonly)
Returns the value of attribute name
49 50 51 |
# File 'lib/little_ghost/mcp/types.rb', line 49 def name @name end |
#output_schema ⇒ Object (readonly)
Returns the value of attribute output_schema
49 50 51 |
# File 'lib/little_ghost/mcp/types.rb', line 49 def output_schema @output_schema end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw
49 50 51 |
# File 'lib/little_ghost/mcp/types.rb', line 49 def raw @raw end |
#source_name ⇒ Object (readonly)
Returns the value of attribute source_name
49 50 51 |
# File 'lib/little_ghost/mcp/types.rb', line 49 def source_name @source_name end |
#title ⇒ Object (readonly)
Returns the value of attribute title
49 50 51 |
# File 'lib/little_ghost/mcp/types.rb', line 49 def title @title end |
Instance Method Details
#[](key) ⇒ Object
82 |
# File 'lib/little_ghost/mcp/types.rb', line 82 def [](key) = raw[key] |
#dig ⇒ Object
84 |
# File 'lib/little_ghost/mcp/types.rb', line 84 def dig(...) = raw.dig(...) |
#fetch ⇒ Object
83 |
# File 'lib/little_ghost/mcp/types.rb', line 83 def fetch(...) = raw.fetch(...) |
#key?(key) ⇒ Boolean
85 |
# File 'lib/little_ghost/mcp/types.rb', line 85 def key?(key) = raw.key?(key) |