Module: SwaggerMCPTool::Helpers::ToolRegister
- Included in:
 - Server, StdioServer
 
- Defined in:
 - lib/swagger_mcp_tool/helpers/tool_register.rb
 
Overview
Provides helper methods for registering and initializing tools using Swagger definitions. This module includes methods to set up the tool registry, generate tools from a Swagger URL, and handle dynamic tool registration. It is intended to be included in classes that require integration with the SwaggerMCPTool tool registry system.
Example usage:
include SwaggerMCPTool::Helpers::ToolRegister
  Instance Method Summary collapse
- 
  
    
      #generate_tools_from_swagger_url  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Generate tools from a Swagger URL.
 - #initialize_tools ⇒ Object
 - #setup_tool_registry ⇒ Object
 - #tool_registry ⇒ Object
 
Instance Method Details
#generate_tools_from_swagger_url ⇒ Object
Generate tools from a Swagger URL
      36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51  | 
    
      # File 'lib/swagger_mcp_tool/helpers/tool_register.rb', line 36 def generate_tools_from_swagger_url @config.logger.info "Generating tools from Swagger URL: #{@config.swagger_url}" # Create a Swagger client swagger_client = SwaggerClient.new(@config.swagger_url) # Create a tool generator tool_generator = ToolGenerator.new(swagger_client) # Generate tools tools = tool_generator.generate_tools # Register the tools dynamically (simplified) tool_registry.register_dynamic_tools(tools, swagger_client.base_url) rescue StandardError => e log_and_raise_error(e) end  | 
  
#initialize_tools ⇒ Object
      31 32 33  | 
    
      # File 'lib/swagger_mcp_tool/helpers/tool_register.rb', line 31 def initialize_tools generate_tools_from_swagger_url end  | 
  
#setup_tool_registry ⇒ Object
      24 25 26 27 28 29  | 
    
      # File 'lib/swagger_mcp_tool/helpers/tool_register.rb', line 24 def setup_tool_registry registry = tool_registry registry.setup(@config) # <-- This is where setup gets called @logger = @config.logger ('Tool registry setup complete') end  | 
  
#tool_registry ⇒ Object
      20 21 22  | 
    
      # File 'lib/swagger_mcp_tool/helpers/tool_register.rb', line 20 def tool_registry SwaggerMCPTool::ToolRegistry.instance end  |