Class: ActionModelContext::Tool
- Inherits:
-
Object
- Object
- ActionModelContext::Tool
- Includes:
- Primitive
- Defined in:
- lib/action_model_context/tool.rb
Overview
Base class of the tools. An application subclasses it through ApplicationTool, under app/mcp/tools.
Constant Summary collapse
- ARGUMENT_TYPES =
The types argument accepts.
%i[string integer number boolean array object].freeze
- SCHEMA_KEYWORDS =
JSON Schema 2020-12, the dialect MCP mandates (SEP-1613), minus type and required that argument sets itself.
%w[ $id $schema $ref $anchor $dynamicRef $dynamicAnchor $vocabulary $comment $defs prefixItems items contains additionalProperties properties patternProperties dependentSchemas propertyNames if then else allOf anyOf oneOf not unevaluatedItems unevaluatedProperties const enum multipleOf maximum exclusiveMaximum minimum exclusiveMinimum maxLength minLength pattern maxItems minItems uniqueItems maxContains minContains maxProperties minProperties dependentRequired title description default deprecated readOnly writeOnly examples format contentEncoding contentMediaType contentSchema ].freeze
Instance Attribute Summary
Attributes included from Primitive
Class Method Summary collapse
-
.annotations(**hints) ⇒ Hash?
Declares the annotations, or reads them.
-
.argument(name, type, **keywords) ⇒ void
Declares an argument of the input schema.
-
.arguments_from(properties, required: []) ⇒ void
Declares one argument per entry of a JSON Schema
propertieshash,type: [..., 'null']becomingnull: true. -
.tool_name(name = nil) ⇒ String?
Declares the name, or reads it.
Instance Method Summary collapse
-
#call ⇒ String, ...
Runs the tool.
-
#invoke(arguments) ⇒ Object
Wraps every call of the tool: override this private method and call
super, asprocess_actionin a controller.
Methods included from Primitive
Class Method Details
.annotations(**hints) ⇒ Hash?
Declares the annotations, or reads them.
.argument(name, type, **keywords) ⇒ void
This method returns an undefined value.
Declares an argument of the input schema.
.arguments_from(properties, required: []) ⇒ void
This method returns an undefined value.
Declares one argument per entry of a JSON Schema properties hash, type: [..., 'null'] becoming null: true.
.tool_name(name = nil) ⇒ String?
Declares the name, or reads it.
Instance Method Details
#call ⇒ String, ...
Runs the tool. A subclass defines it, with one keyword per argument it takes.
#invoke(arguments) ⇒ Object
Wraps every call of the tool: override this private method and call super, as process_action in a
controller. rescue_from covers it.