Class: Hitch::Generators::ToolGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Hitch::Generators::ToolGenerator
- Includes:
- GeneratorGuards
- Defined in:
- lib/generators/hitch/tool_generator.rb
Overview
Generates a working, registered MCP tool plus an integration test that proves it responds over real HTTP. --deny-default emits a hardened variant instead: unavailable, denying, and unimplemented until the host fills it in.
Usage:
bin/rails generate hitch:tool NAME
bin/rails destroy hitch:tool NAME
Constant Summary collapse
- NAME_SEGMENT_PATTERN =
/\A(?:[a-z][a-z0-9]*(?:[_-][a-z0-9]+)*|[A-Z][A-Za-z0-9]*)\z/- CANONICAL_SEGMENT_PATTERN =
/\A[a-z][a-z0-9]*(?:_[a-z0-9]+)*\z/- NAMESPACE_PATTERN =
/\A[A-Z][A-Za-z0-9]*(?:::[A-Z][A-Za-z0-9]*)*\z/
Constants included from GeneratorGuards
GeneratorGuards::REGISTRY_PATH
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.exit_on_failure? ⇒ Boolean
40 41 42 |
# File 'lib/generators/hitch/tool_generator.rb', line 40 def self.exit_on_failure? true end |
Instance Method Details
#generate_or_revoke ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/generators/hitch/tool_generator.rb', line 44 def generate_or_revoke prepare_identity! behavior == :revoke ? preflight_revoke! : preflight! # Behavior-aware Thor actions: create/inject in invoke, remove in # revoke. template "tool.rb.tt", @tool_path template "tool_test.rb.tt", @test_path inject_into_class REGISTRY_PATH, "McpToolRegistry", " #{@registration_line}\n" print_next_steps unless behavior == :revoke end |