Module: ActionMCP::Client::Transport

Included in:
TransportBase
Defined in:
lib/action_mcp/client/transport.rb

Overview

Base transport interface for MCP client connections

Instance Method Summary collapse

Instance Method Details

#connectObject

Called when transport should establish connection

Raises:

  • (NotImplementedError)


8
9
10
# File 'lib/action_mcp/client/transport.rb', line 8

def connect
  raise NotImplementedError, "#{self.class} must implement #connect"
end

#connected?Boolean

Check if transport is connected

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


28
29
30
# File 'lib/action_mcp/client/transport.rb', line 28

def connected?
  raise NotImplementedError, "#{self.class} must implement #connected?"
end

#disconnectObject

Called when transport should close connection

Raises:

  • (NotImplementedError)


13
14
15
# File 'lib/action_mcp/client/transport.rb', line 13

def disconnect
  raise NotImplementedError, "#{self.class} must implement #disconnect"
end

#on_connect(&block) ⇒ Object

Set callback for connection events



43
44
45
# File 'lib/action_mcp/client/transport.rb', line 43

def on_connect(&block)
  @connect_callback = block
end

#on_disconnect(&block) ⇒ Object

Set callback for disconnection events



48
49
50
# File 'lib/action_mcp/client/transport.rb', line 48

def on_disconnect(&block)
  @disconnect_callback = block
end

#on_error(&block) ⇒ Object

Set callback for errors



38
39
40
# File 'lib/action_mcp/client/transport.rb', line 38

def on_error(&block)
  @error_callback = block
end

#on_message(&block) ⇒ Object

Set callback for received messages



33
34
35
# File 'lib/action_mcp/client/transport.rb', line 33

def on_message(&block)
  @message_callback = block
end

#ready?Boolean

Check if transport is ready to send/receive

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


23
24
25
# File 'lib/action_mcp/client/transport.rb', line 23

def ready?
  raise NotImplementedError, "#{self.class} must implement #ready?"
end

#send_message(message) ⇒ Object

Send a message through the transport

Raises:

  • (NotImplementedError)


18
19
20
# File 'lib/action_mcp/client/transport.rb', line 18

def send_message(message)
  raise NotImplementedError, "#{self.class} must implement #send_message"
end