Class: Textus::Contract::Spec

Inherits:
Data
  • Object
show all
Defined in:
lib/textus/contract.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args

Returns:

  • (Object)

    the current value of args



29
30
31
# File 'lib/textus/contract.rb', line 29

def args
  @args
end

#responseObject (readonly)

Returns the value of attribute response

Returns:

  • (Object)

    the current value of response



29
30
31
# File 'lib/textus/contract.rb', line 29

def response
  @response
end

#summaryObject (readonly)

Returns the value of attribute summary

Returns:

  • (Object)

    the current value of summary



29
30
31
# File 'lib/textus/contract.rb', line 29

def summary
  @summary
end

#surfacesObject (readonly)

Returns the value of attribute surfaces

Returns:

  • (Object)

    the current value of surfaces



29
30
31
# File 'lib/textus/contract.rb', line 29

def surfaces
  @surfaces
end

#verbObject (readonly)

Returns the value of attribute verb

Returns:

  • (Object)

    the current value of verb



29
30
31
# File 'lib/textus/contract.rb', line 29

def verb
  @verb
end

Instance Method Details

#input_schemaObject

JSON-Schema object for MCP tools/list inputSchema. Outer keys (:type, :properties, :required) are symbols; inner property keys are strings — matches the MCP/JSON wire shape expected by clients.



37
38
39
40
41
42
43
44
# File 'lib/textus/contract.rb', line 37

def input_schema
  props = args.to_h do |a|
    h = { "type" => Contract.json_type(a.type) }
    h["description"] = a.description if a.description
    [a.wire.to_s, h]
  end
  { type: "object", properties: props, required: required_args.map { |a| a.wire.to_s } }
end

#mcp?Boolean

Returns:

  • (Boolean)


30
# File 'lib/textus/contract.rb', line 30

def mcp? = surfaces.include?(:mcp)

#required_argsObject



32
# File 'lib/textus/contract.rb', line 32

def required_args = args.select(&:required)