Class: RailsMcpEngine::PlaygroundController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- RailsMcpEngine::PlaygroundController
- Defined in:
- app/controllers/rails_mcp_engine/playground_controller.rb
Instance Method Summary collapse
Instance Method Details
#delete_tool ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/controllers/rails_mcp_engine/playground_controller.rb', line 43 def delete_tool tool_name = params[:tool_name].to_s schema = schemas.find { |s| s[:name] == tool_name } result = if schema.nil? { error: "Tool not found: #{tool_name}" } else delete_tool_from_registry(tool_name) end flash[:register_result] = result redirect_to playground_path end |
#register ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/controllers/rails_mcp_engine/playground_controller.rb', line 13 def register source = params[:source].to_s result = if source.strip.empty? { error: 'Tool source code is required' } else register_source(source) end flash[:register_result] = result redirect_to playground_path end |
#run ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/controllers/rails_mcp_engine/playground_controller.rb', line 26 def run tool_name = params[:tool_name].to_s parsed_arguments = parse_arguments(params[:arguments]) schema = schemas.find { |s| s[:name] == tool_name } result = if schema.nil? { error: "Tool not found: #{tool_name}" } elsif parsed_arguments.is_a?(String) { error: parsed_arguments } else invoke_tool(schema, parsed_arguments) end flash[:test_result] = result redirect_to playground_path end |
#show ⇒ Object
7 8 9 10 11 |
# File 'app/controllers/rails_mcp_engine/playground_controller.rb', line 7 def show @register_result = flash[:register_result] @test_result = flash[:test_result] @tools = schemas end |