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
-
#connect ⇒ Object
Called when transport should establish connection.
-
#connected? ⇒ Boolean
Check if transport is connected.
-
#disconnect ⇒ Object
Called when transport should close connection.
-
#on_connect(&block) ⇒ Object
Set callback for connection events.
-
#on_disconnect(&block) ⇒ Object
Set callback for disconnection events.
-
#on_error(&block) ⇒ Object
Set callback for errors.
-
#on_message(&block) ⇒ Object
Set callback for received messages.
-
#ready? ⇒ Boolean
Check if transport is ready to send/receive.
-
#send_message(message) ⇒ Object
Send a message through the transport.
Instance Method Details
#connect ⇒ Object
Called when transport should establish connection
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
28 29 30 |
# File 'lib/action_mcp/client/transport.rb', line 28 def connected? raise NotImplementedError, "#{self.class} must implement #connected?" end |
#disconnect ⇒ Object
Called when transport should close connection
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 (&block) @message_callback = block end |
#ready? ⇒ Boolean
Check if transport is ready to send/receive
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
18 19 20 |
# File 'lib/action_mcp/client/transport.rb', line 18 def () raise NotImplementedError, "#{self.class} must implement #send_message" end |