Class: FastMcp::Transports::BaseTransport
- Inherits:
-
Object
- Object
- FastMcp::Transports::BaseTransport
- Defined in:
- lib/mcp/transports/base_transport.rb
Overview
Base class for all MCP transports This defines the interface that all transports must implement
Direct Known Subclasses
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
Instance Method Summary collapse
-
#initialize(server, logger: nil) ⇒ BaseTransport
constructor
A new instance of BaseTransport.
-
#process_message(message, headers: {}) ⇒ Object
Process an incoming message This is a helper method that can be used by subclasses.
-
#send_message(message) ⇒ Object
Send a message to the client This method should be implemented by subclasses.
-
#start ⇒ Object
Start the transport This method should be implemented by subclasses.
-
#stop ⇒ Object
Stop the transport This method should be implemented by subclasses.
Constructor Details
#initialize(server, logger: nil) ⇒ BaseTransport
Returns a new instance of BaseTransport.
10 11 12 13 |
# File 'lib/mcp/transports/base_transport.rb', line 10 def initialize(server, logger: nil) @server = server @logger = logger || server.logger end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
8 9 10 |
# File 'lib/mcp/transports/base_transport.rb', line 8 def logger @logger end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
8 9 10 |
# File 'lib/mcp/transports/base_transport.rb', line 8 def server @server end |
Instance Method Details
#process_message(message, headers: {}) ⇒ Object
Process an incoming message This is a helper method that can be used by subclasses
35 36 37 |
# File 'lib/mcp/transports/base_transport.rb', line 35 def (, headers: {}) server.handle_request(, headers: headers) end |
#send_message(message) ⇒ Object
Send a message to the client This method should be implemented by subclasses
29 30 31 |
# File 'lib/mcp/transports/base_transport.rb', line 29 def () raise NotImplementedError, "#{self.class} must implement #send_message" end |
#start ⇒ Object
Start the transport This method should be implemented by subclasses
17 18 19 |
# File 'lib/mcp/transports/base_transport.rb', line 17 def start raise NotImplementedError, "#{self.class} must implement #start" end |
#stop ⇒ Object
Stop the transport This method should be implemented by subclasses
23 24 25 |
# File 'lib/mcp/transports/base_transport.rb', line 23 def stop raise NotImplementedError, "#{self.class} must implement #stop" end |