Class: RubyLLM::MCP::Adapters::MCPTransports::CoordinatorStub

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_llm/mcp/adapters/mcp_transports/coordinator_stub.rb

Overview

Minimal coordinator stub for MCP transports The native transports expect a coordinator object, but for the MCP SDK adapter we don't need to process results (just pass them through) as MCP SDK adapter doesn't methods that requires responsing to the MCP server as of yet.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(protocol_version:, notification_callback: nil) ⇒ CoordinatorStub

Returns a new instance of CoordinatorStub.



12
13
14
15
16
17
# File 'lib/ruby_llm/mcp/adapters/mcp_transports/coordinator_stub.rb', line 12

def initialize(protocol_version:, notification_callback: nil)
  @name = "MCP-SDK-Adapter"
  @protocol_version = protocol_version
  @transport = nil
  @notification_callback = notification_callback
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



9
10
11
# File 'lib/ruby_llm/mcp/adapters/mcp_transports/coordinator_stub.rb', line 9

def name
  @name
end

#protocol_versionObject (readonly)

Returns the value of attribute protocol_version.



9
10
11
# File 'lib/ruby_llm/mcp/adapters/mcp_transports/coordinator_stub.rb', line 9

def protocol_version
  @protocol_version
end

#transportObject

Returns the value of attribute transport.



10
11
12
# File 'lib/ruby_llm/mcp/adapters/mcp_transports/coordinator_stub.rb', line 10

def transport
  @transport
end

Instance Method Details

#client_capabilitiesObject



30
31
32
# File 'lib/ruby_llm/mcp/adapters/mcp_transports/coordinator_stub.rb', line 30

def client_capabilities
  {} # MCP SDK doesn't provide client capabilities
end

#process_result(result) ⇒ Object



19
20
21
22
23
24
25
26
27
28
# File 'lib/ruby_llm/mcp/adapters/mcp_transports/coordinator_stub.rb', line 19

def process_result(result)
  if result&.notification?
    @notification_callback&.call(result.notification)
    return nil
  end

  return nil if result&.request?

  result
end

#request(body, **options) ⇒ Object



34
35
36
37
38
39
# File 'lib/ruby_llm/mcp/adapters/mcp_transports/coordinator_stub.rb', line 34

def request(body, **options)
  # For notifications (cancelled, etc), we need to send them through the transport
  return nil unless @transport

  @transport.request(body, **options)
end