Class: StimulusPlumbers::MCP::Plugins::ComponentTheme

Inherits:
Base
  • Object
show all
Defined in:
lib/stimulus_plumbers/mcp/plugins/component_theme.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_theme.rb', line 29

def dynamic_resource_templates
  [
    ::MCP::ResourceTemplate.new(
      uri_template: "component://{name}/theme",
      name:         "component-theme-interface",
      description:  "Method name, param signature, and return contract for implementing a component in a custom theme",
      mime_type:    "application/json"
    )
  ].freeze
end

.loaderObject



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

def loader = ComponentThemeLoader

.loader_keyObject



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

def loader_key = :component_theme

.read(uri, store) ⇒ Object



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

def read(uri, store)
  theme = store[:component_theme]

  case uri
  when "component://theme/base"
    text_resource(uri, "text/markdown", theme[:base_doc])
  when "component://theme"
    json_resource(uri, theme[:components].keys)
  when %r{\Acomponent://([^/]+)/theme\z}
    key = Regexp.last_match(1).to_sym
    json_resource(uri, theme[:components][key] || { error: "unknown component: #{key}" })
  end
end

.register_tools(server, store) ⇒ Object



54
55
56
57
58
59
# File 'lib/stimulus_plumbers/mcp/plugins/component_theme.rb', line 54

def register_tools(server, store)
  theme = store[:component_theme]

  register_list_component_themes(server, theme)
  register_get_component_theme(server, theme)
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_theme.rb', line 12

def static_resources
  [
    ::MCP::Resource.new(
      uri:         "component://theme/base",
      name:        "theme-base",
      description: "Guide for implementing a custom stimulus-plumbers theme: method convention, return format",
      mime_type:   "text/markdown"
    ),
    ::MCP::Resource.new(
      uri:         "component://theme",
      name:        "component-theme-index",
      description: "Index of all component keys that can be implemented in a custom theme",
      mime_type:   "application/json"
    )
  ].freeze
end