Class: StimulusPlumbers::MCP::Plugins::Guide

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

Constant Summary collapse

GUIDE_NAMES =
%w[component controller tailwind theme].freeze

Class Method Summary collapse

Methods inherited from Base

json_resource, not_found, text_resource, text_tool

Class Method Details

.dynamic_resource_templatesObject



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/stimulus_plumbers/mcp/plugins/guide.rb', line 30

def dynamic_resource_templates
  [
    ::MCP::ResourceTemplate.new(
      uri_template: "guide://{name}",
      name:         "guide",
      description:  "Per-package usage guide: component (Rails forms/views), controller " \
                    "(plain-JS/non-Rails setup), tailwind (Tailwind install/theming), theme " \
                    "(custom theme integration contract)",
      mime_type:    "text/markdown"
    )
  ].freeze
end

.loaderObject



14
15
16
# File 'lib/stimulus_plumbers/mcp/plugins/guide.rb', line 14

def loader
  GuideLoader
end

.loader_keyObject



10
11
12
# File 'lib/stimulus_plumbers/mcp/plugins/guide.rb', line 10

def loader_key
  :guide
end

.read(uri, store) ⇒ Object



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

def read(uri, store)
  guide = store[:guide]

  case uri
  when "guide://overview"
    text_resource(uri, "text/markdown", guide[:overview])
  when %r{\Aguide://(#{GUIDE_NAMES.join("|")})\z}
    text_resource(uri, "text/markdown", guide[Regexp.last_match(1).to_sym])
  end
end

.register_tools(server, store) ⇒ Object



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

def register_tools(server, store)
  guide = store[:guide]

  register_list_guides(server)
  register_get_guide(server, guide)
end

.static_resourcesObject



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/stimulus_plumbers/mcp/plugins/guide.rb', line 18

def static_resources
  [
    ::MCP::Resource.new(
      uri:         "guide://overview",
      name:        "overview",
      description: "Start here — how to build views and forms with stimulus-plumbers, with pointers " \
                   "to every tool/resource",
      mime_type:   "text/markdown"
    )
  ].freeze
end