Class: StimulusPlumbers::MCP::Plugins::ComponentSchema

Inherits:
Base
  • Object
show all
Defined in:
lib/stimulus_plumbers/mcp/plugins/component_schema.rb

Class Method Summary collapse

Methods inherited from Base

json_resource, not_found, text_resource, text_tool

Class Method Details

.dynamic_resource_templatesObject



29
30
31
32
33
34
35
36
37
38
# File 'lib/stimulus_plumbers/mcp/plugins/component_schema.rb', line 29

def dynamic_resource_templates
  [
    ::MCP::ResourceTemplate.new(
      uri_template: "component://{name}/schema",
      name:         "component-schema",
      description:  "Params, valid values, defaults, and required controllers for a component",
      mime_type:    "application/json"
    )
  ].freeze
end

.loaderObject



10
# File 'lib/stimulus_plumbers/mcp/plugins/component_schema.rb', line 10

def loader = ComponentSchemaLoader

.loader_keyObject



8
# File 'lib/stimulus_plumbers/mcp/plugins/component_schema.rb', line 8

def loader_key = :component_schema

.read(uri, store) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/stimulus_plumbers/mcp/plugins/component_schema.rb', line 40

def read(uri, store)
  schema = store[:component_schema]

  case uri
  when "component://index"
    json_resource(uri, schema[:components].keys)
  when "component://integration"
    json_resource(uri, schema[:controllers])
  when %r{\Acomponent://([^/]+)/schema\z}
    key = Regexp.last_match(1).to_sym
    json_resource(uri, component_data(schema, key) || { error: "unknown component: #{key}" })
  end
end

.register_tools(server, store) ⇒ Object



54
55
56
57
58
59
60
61
62
# File 'lib/stimulus_plumbers/mcp/plugins/component_schema.rb', line 54

def register_tools(server, store)
  schema = store[:component_schema]
  data_by_component = component_data_map(schema)

  register_list_components(server, schema)
  register_get_component_schema(server, data_by_component)
  register_get_field_as_values(server, schema)
  register_get_field_as_controller(server, schema)
end

.static_resourcesObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/stimulus_plumbers/mcp/plugins/component_schema.rb', line 12

def static_resources
  [
    ::MCP::Resource.new(
      uri:         "component://index",
      name:        "components-index",
      description: "Index of all stimulus-plumbers component theme keys",
      mime_type:   "application/json"
    ),
    ::MCP::Resource.new(
      uri:         "component://integration",
      name:        "component-integration",
      description: "Mapping from Rails component name to the Stimulus controller identifiers it requires",
      mime_type:   "application/json"
    )
  ].freeze
end