Class: Sxn::MCP::Tools::Templates::ListTemplates

Inherits:
MCP::Tool
  • Object
show all
Defined in:
lib/sxn/mcp/tools/templates.rb

Overview

List available templates

Class Method Summary collapse

Class Method Details

.call(server_context:) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/sxn/mcp/tools/templates.rb', line 18

def call(server_context:)
  BaseTool.ensure_initialized!(server_context)

  BaseTool::ErrorMapping.wrap do
    template_manager = server_context[:template_manager]
    templates = template_manager.list_templates

    if templates.empty?
      BaseTool.text_response(
        "No templates defined. Templates can be created in .sxn/templates.yml"
      )
    else
      formatted = templates.map do |t|
        desc = t[:description] ? " - #{t[:description]}" : ""
        "- #{t[:name]} (#{t[:project_count]} projects)#{desc}"
      end.join("\n")

      BaseTool.text_response("Available templates:\n#{formatted}")
    end
  end
end