Class: RobotLab::MCP::Transports::Base Abstract
- Inherits:
-
Object
- Object
- RobotLab::MCP::Transports::Base
- Defined in:
- lib/robot_lab/mcp/transports/base.rb
Overview
This class is abstract.
Subclass and implement #connect, #send_request, #close
Base class for MCP transports
Direct Known Subclasses
Constant Summary collapse
- DEFAULT_TIMEOUT =
Default timeout for request operations (in seconds)
15
Instance Attribute Summary collapse
-
#config ⇒ Hash
readonly
The transport configuration.
-
#timeout ⇒ Object
readonly
Returns the value of attribute timeout.
Instance Method Summary collapse
-
#close ⇒ self
Close the connection.
-
#connect ⇒ self
Connect to the server.
-
#connected? ⇒ Boolean
Check if the transport is connected.
-
#initialize(config) ⇒ Base
constructor
Creates a new transport instance.
-
#send_request(message) ⇒ Hash
Send a JSON-RPC request.
Constructor Details
#initialize(config) ⇒ Base
Creates a new transport instance.
25 26 27 28 |
# File 'lib/robot_lab/mcp/transports/base.rb', line 25 def initialize(config) @config = config.transform_keys(&:to_sym) @timeout = @config.delete(:timeout) || DEFAULT_TIMEOUT end |
Instance Attribute Details
#config ⇒ Hash (readonly)
Returns the transport configuration.
18 19 20 |
# File 'lib/robot_lab/mcp/transports/base.rb', line 18 def config @config end |
#timeout ⇒ Object (readonly)
Returns the value of attribute timeout.
18 |
# File 'lib/robot_lab/mcp/transports/base.rb', line 18 attr_reader :config, :timeout |
Instance Method Details
#close ⇒ self
Close the connection
51 52 53 |
# File 'lib/robot_lab/mcp/transports/base.rb', line 51 def close raise NotImplementedError end |
#connect ⇒ self
Connect to the server
34 35 36 |
# File 'lib/robot_lab/mcp/transports/base.rb', line 34 def connect raise NotImplementedError end |
#connected? ⇒ Boolean
Check if the transport is connected.
58 59 60 |
# File 'lib/robot_lab/mcp/transports/base.rb', line 58 def connected? false end |
#send_request(message) ⇒ Hash
Send a JSON-RPC request
43 44 45 |
# File 'lib/robot_lab/mcp/transports/base.rb', line 43 def send_request() raise NotImplementedError end |