Class: RubyLLM::MCP::Native::Transport

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/ruby_llm/mcp/native/transport.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(transport_type, coordinator, config:) ⇒ Transport

Returns a new instance of Transport.



26
27
28
29
30
31
# File 'lib/ruby_llm/mcp/native/transport.rb', line 26

def initialize(transport_type, coordinator, config:)
  @transport_type = transport_type
  @coordinator = coordinator
  @config = config
  @pid = Process.pid
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



24
25
26
# File 'lib/ruby_llm/mcp/native/transport.rb', line 24

def config
  @config
end

#coordinatorObject (readonly)

Returns the value of attribute coordinator.



24
25
26
# File 'lib/ruby_llm/mcp/native/transport.rb', line 24

def coordinator
  @coordinator
end

#pidObject (readonly)

Returns the value of attribute pid.



24
25
26
# File 'lib/ruby_llm/mcp/native/transport.rb', line 24

def pid
  @pid
end

#transport_typeObject (readonly)

Returns the value of attribute transport_type.



24
25
26
# File 'lib/ruby_llm/mcp/native/transport.rb', line 24

def transport_type
  @transport_type
end

Class Method Details

.register_transport(transport_type, transport_class) ⇒ Object



12
13
14
# File 'lib/ruby_llm/mcp/native/transport.rb', line 12

def register_transport(transport_type, transport_class)
  transports[transport_type] = transport_class
end

.transportsObject



8
9
10
# File 'lib/ruby_llm/mcp/native/transport.rb', line 8

def transports
  @transports ||= {}
end

Instance Method Details

#transport_protocolObject



35
36
37
38
39
40
41
42
43
# File 'lib/ruby_llm/mcp/native/transport.rb', line 35

def transport_protocol
  if @pid != Process.pid
    @pid = Process.pid
    @transport_protocol = nil
    @transport_protocol = build_transport
  end

  @transport_protocol ||= build_transport
end