Class: Tidewave::StreamableHttpTransport
- Inherits:
-
FastMcp::Transports::BaseTransport
- Object
- FastMcp::Transports::BaseTransport
- Tidewave::StreamableHttpTransport
- Defined in:
- lib/tidewave/streamable_http_transport.rb
Overview
Streamable HTTP transport for MCP (POST-only, no SSE) This transport implements a simplified version of the MCP Streamable HTTP protocol that only supports POST requests for JSON-RPC messages. Unlike the full protocol, it does not support Server-Sent Events (SSE) for streaming responses.
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, server, options = {}) ⇒ StreamableHttpTransport
constructor
A new instance of StreamableHttpTransport.
-
#send_message(message) ⇒ Object
Send a message - capture response for synchronous HTTP Required by FastMCP::Transports::BaseTransport interface.
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(app, server, options = {}) ⇒ StreamableHttpTransport
Returns a new instance of StreamableHttpTransport.
15 16 17 18 19 20 |
# File 'lib/tidewave/streamable_http_transport.rb', line 15 def initialize(app, server, = {}) super(server, logger: [:logger]) @app = app @path = [:path_prefix] || "/mcp" @running = false end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
13 14 15 |
# File 'lib/tidewave/streamable_http_transport.rb', line 13 def app @app end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
13 14 15 |
# File 'lib/tidewave/streamable_http_transport.rb', line 13 def path @path end |
Instance Method Details
#call(env) ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/tidewave/streamable_http_transport.rb', line 39 def call(env) request = Rack::Request.new(env) if request.path == @path @server.transport = self handle_mcp_request(request, env) else @app.call(env) end end |
#send_message(message) ⇒ Object
Send a message - capture response for synchronous HTTP Required by FastMCP::Transports::BaseTransport interface
34 35 36 37 |
# File 'lib/tidewave/streamable_http_transport.rb', line 34 def () @logger.debug("send_message called, capturing response: #{message.inspect}") @captured_response = end |
#start ⇒ Object
22 23 24 25 |
# File 'lib/tidewave/streamable_http_transport.rb', line 22 def start @logger.debug("Starting Streamable HTTP transport (POST-only) at path: #{@path}") @running = true end |
#stop ⇒ Object
27 28 29 30 |
# File 'lib/tidewave/streamable_http_transport.rb', line 27 def stop @logger.debug("Stopping Streamable HTTP transport") @running = false end |