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



33
34
35
36
37
38
39
40
41
42
# File 'lib/stimulus_plumbers/mcp/plugins/component_theme.rb', line 33

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



12
13
14
# File 'lib/stimulus_plumbers/mcp/plugins/component_theme.rb', line 12

def loader
  ComponentThemeLoader
end

.loader_keyObject



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

def loader_key
  :component_theme
end

.read(uri, store) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/stimulus_plumbers/mcp/plugins/component_theme.rb', line 44

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



58
59
60
61
62
63
# File 'lib/stimulus_plumbers/mcp/plugins/component_theme.rb', line 58

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

  register_list_component_themes(server, theme)
  register_get_component_theme(server, theme)
end

.static_resourcesObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/stimulus_plumbers/mcp/plugins/component_theme.rb', line 16

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