Class: SwaggerMCPTool::StdioServer
- Inherits:
-
Object
- Object
- SwaggerMCPTool::StdioServer
- Includes:
- Helpers::ToolRegister, Logging
- Defined in:
- lib/swagger_mcp_tool/stdio_server.rb
Overview
This module provides the StdioServer for handling MCP tool operations via standard IO. StdioServer handles MCP tool operations via standard IO. It initializes the server, sets up configuration and logging, registers available tools, and starts the server using standard IO transport.
Instance Method Summary collapse
-
#initialize ⇒ StdioServer
constructor
A new instance of StdioServer.
- #start_stdio_server(context = {}) ⇒ Object
Methods included from Helpers::ToolRegister
#generate_tools_from_swagger_url, #initialize_tools, #setup_tool_registry, #tool_registry
Methods included from Logging
#log_and_raise_error, #log_message, #log_request_details, #log_request_execution, #log_server_initialization
Constructor Details
#initialize ⇒ StdioServer
Returns a new instance of StdioServer.
28 29 30 31 32 33 34 |
# File 'lib/swagger_mcp_tool/stdio_server.rb', line 28 def initialize @config = Config.instance @logger = @config.logger || Logger.new($stdout) log_server_initialization setup_tool_registry initialize_tools end |
Instance Method Details
#start_stdio_server(context = {}) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/swagger_mcp_tool/stdio_server.rb', line 36 def start_stdio_server(context = {}) user_details = context configuration = MCP::Configuration.new(protocol_version: @config.protocol_version) # Create MCP server with our tools and prompts mcp = MCP::Server.new( name: @config.mcp_name, tools: tool_registry.dynamic_tools, prompts: @config.prompts, server_context: user_details, configuration: configuration ) transport = MCP::Server::Transports::StdioTransport.new(mcp) transport.open end |