Class: McpToolkit::Authority::Tools::List

Inherits:
Base
  • Object
show all
Defined in:
lib/mcp_toolkit/authority/tools/list.rb

Overview

Authority-path tool: fetch a paginated list of records from a registered resource, scoped to the caller's resolved account. Gates a superuser-only resource, the resource's required scope, and requires a selected account before reading. Standard filters, per-attribute equality/operator filters, resource custom filters, pagination, and sparse fieldsets are all handled by the reused McpToolkit::ListExecutor.

Constant Summary collapse

BARE_VALUE_GRAMMAR =

The bare-value grammar bullet, per config.bare_filter_value_semantics: the served description must state the semantics the host ACTUALLY configured — advertising comma/"null" tokenization to clients of a :literal host would send them filters that silently match nothing. The :tokenized text is the exact bullet embedded in the static description below (spec-pinned), so .description_text can swap it by plain substring substitution; both use <<- (no dedent) to carry the description's rendered 2-space indentation.

{
  tokenized: "- A bare value matches by equality. A comma-separated string or an array of scalars\n  matches ANY of the values (IN), e.g. { \"status\": \"booked,canceled\" } or\n  { \"status\": [\"booked\", \"canceled\"] }. The string \"null\" (or a JSON null) matches\n  records where the value is NULL.\n  TEXT\n  literal: <<-TEXT.rstrip\n- A bare value matches by equality, LITERALLY: a comma-separated string is a single\n  value and the string \"null\" is the literal string. A JSON null matches records\n  where the value is NULL. An array of scalars matches ANY of its values (IN).\n  TEXT\n}.freeze\n".rstrip,

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.description_text(config) ⇒ Object

Swaps the bare-value bullet for the host's configured semantics; the rest of the description is mode-independent.



33
34
35
36
37
# File 'lib/mcp_toolkit/authority/tools/list.rb', line 33

def self.description_text(config)
  return _description unless config && config.bare_filter_value_semantics == :literal

  _description.sub(BARE_VALUE_GRAMMAR[:tokenized], BARE_VALUE_GRAMMAR[:literal])
end

Instance Method Details

#call(context:, resource: nil, **params) ⇒ Object



122
123
124
125
126
127
128
129
130
131
# File 'lib/mcp_toolkit/authority/tools/list.rb', line 122

def call(context:, resource: nil, **params)
  descriptor = resolve_descriptor(resource)
  ensure_resource_accessible!(descriptor, context)
  ensure_scope!(descriptor, context)
  ensure_account!(context)

  run_executor do
    McpToolkit::ListExecutor.call(resource: descriptor, scope_root: context., params:)
  end
end