Class: TalkToYourApp::Generators::CustomToolGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Defined in:
lib/generators/talk_to_your_app/custom_tool/custom_tool_generator.rb

Overview

‘rails g talk_to_your_app:custom_tool MakeAdmin` — scaffolds a custom MCP tool in app/talk_to_your_app/custom_tools/. Enable `config.plugin :custom_tools` and the tool is exposed automatically as `custom.<name>`.

Constant Summary collapse

TOOLS_DIR =
File.join(TalkToYourApp::APP_DIR, "custom_tools")

Instance Method Summary collapse

Instance Method Details

#create_toolObject



19
20
21
# File 'lib/generators/talk_to_your_app/custom_tool/custom_tool_generator.rb', line 19

def create_tool
  template "tool.rb.tt", File.join(TOOLS_DIR, class_path, "#{file_name}.rb")
end

#show_next_stepsObject



23
24
25
26
27
28
29
# File 'lib/generators/talk_to_your_app/custom_tool/custom_tool_generator.rb', line 23

def show_next_steps
  say ""
  say "Created #{File.join(TOOLS_DIR, class_path, "#{file_name}.rb")} — exposed as MCP tool #{tool_name.inspect}.", :green
  say "Make sure config/initializers/talk_to_your_app.rb enables it:"
  say "  config.plugin :custom_tools"
  say "Files here are loaded with require (not Zeitwerk-reloaded) — restart the server to pick up new or edited tools."
end