Class: RubyLLM::MCP::Auth::Browser::CallbackServer

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_llm/mcp/auth/browser/callback_server.rb

Overview

Callback server wrapper for clean shutdown Manages server lifecycle and thread coordination

Instance Method Summary collapse

Constructor Details

#initialize(server, thread, stop_proc, start_proc = nil) ⇒ CallbackServer

Returns a new instance of CallbackServer.



10
11
12
13
14
15
# File 'lib/ruby_llm/mcp/auth/browser/callback_server.rb', line 10

def initialize(server, thread, stop_proc, start_proc = nil)
  @server = server
  @thread = thread
  @stop_proc = stop_proc
  @start_proc = start_proc || -> {}
end

Instance Method Details

#shutdownnil

Shutdown server and cleanup resources

Returns:

  • (nil)

    always returns nil



24
25
26
27
28
29
30
31
# File 'lib/ruby_llm/mcp/auth/browser/callback_server.rb', line 24

def shutdown
  @stop_proc.call
  @server.close unless @server.closed?
  @thread.join(5) # Wait max 5 seconds for thread to finish
rescue StandardError
  # Ignore shutdown errors
  nil
end

#startObject

Start callback processing loop



18
19
20
# File 'lib/ruby_llm/mcp/auth/browser/callback_server.rb', line 18

def start
  @start_proc.call
end