Class: McpToolkit::ResourceSchema
- Inherits:
-
Object
- Object
- McpToolkit::ResourceSchema
- Defined in:
- lib/mcp_toolkit/resource_schema.rb
Overview
Builds a machine-readable schema for a single registered resource: its
serialized attributes (the response shape) with column types, and its
relationships (the links shape). Powers the resource_schema discovery tool
so an MCP client can learn a resource's shape without trial and error.
Read-only with standard filters (ids/updated_since/limit/offset) plus the resource's declared equality filters.
Constant Summary collapse
- TYPE_FORMATS =
{ datetime: "ISO 8601", date: "ISO 8601", decimal: "number", float: "number", integer: "integer", boolean: "true/false", string: "string", text: "string" }.freeze
- COMPUTED_TYPE =
"computed"- STANDARD_FILTERS =
%w[ids updated_since limit offset].freeze
Class Method Summary collapse
-
.call(resource, registry: McpToolkit.registry) ⇒ Object
registryis used to resolve each relationship to the registered resource it points at (see #relationships).
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(resource, registry: McpToolkit.registry) ⇒ ResourceSchema
constructor
A new instance of ResourceSchema.
Constructor Details
#initialize(resource, registry: McpToolkit.registry) ⇒ ResourceSchema
Returns a new instance of ResourceSchema.
31 32 33 34 35 |
# File 'lib/mcp_toolkit/resource_schema.rb', line 31 def initialize(resource, registry: McpToolkit.registry) @resource = resource @model = resource.model @registry = registry end |
Class Method Details
.call(resource, registry: McpToolkit.registry) ⇒ Object
registry is used to resolve each relationship to the registered resource it
points at (see #relationships). Defaults to the process-wide registry; the
resource_schema tool passes the active config's registry explicitly.
27 28 29 |
# File 'lib/mcp_toolkit/resource_schema.rb', line 27 def self.call(resource, registry: McpToolkit.registry) new(resource, registry:).call end |
Instance Method Details
#call ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/mcp_toolkit/resource_schema.rb', line 37 def call { name: resource.name, description: resource.description, attributes:, relationships:, standard_filters: STANDARD_FILTERS, filters: } end |