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



22
23
24
# File 'lib/textus/contract.rb', line 22

def args
  @args
end

#responseObject (readonly)

Returns the value of attribute response

Returns:

  • (Object)

    the current value of response



22
23
24
# File 'lib/textus/contract.rb', line 22

def response
  @response
end

#summaryObject (readonly)

Returns the value of attribute summary

Returns:

  • (Object)

    the current value of summary



22
23
24
# File 'lib/textus/contract.rb', line 22

def summary
  @summary
end

#surfacesObject (readonly)

Returns the value of attribute surfaces

Returns:

  • (Object)

    the current value of surfaces



22
23
24
# File 'lib/textus/contract.rb', line 22

def surfaces
  @surfaces
end

#verbObject (readonly)

Returns the value of attribute verb

Returns:

  • (Object)

    the current value of verb



22
23
24
# File 'lib/textus/contract.rb', line 22

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.



30
31
32
33
34
35
36
37
# File 'lib/textus/contract.rb', line 30

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

#mcp?Boolean

Returns:

  • (Boolean)


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

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

#required_argsObject



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

def required_args = args.select(&:required)