Class: SwarmSDK::V3::MCP::SslHttpTransport
- Inherits:
-
Object
- Object
- SwarmSDK::V3::MCP::SslHttpTransport
- Defined in:
- lib/swarm_sdk/v3/mcp/ssl_http_transport.rb
Overview
HTTP transport for MCP with configurable SSL verification.
Uses Net::HTTP directly instead of Faraday to avoid the async-http adapter that Faraday selects when running inside Async. The async-http adapter ignores Faraday’s SSL settings and uses IO::Endpoint::SSLEndpoint which enforces CRL checking on OpenSSL 3.6+, breaking most HTTPS MCP connections with “certificate verify failed (unable to get certificate CRL)”.
Conforms to the MCP transport interface: responds to send_request(request:) returning a parsed Hash.
Instance Attribute Summary collapse
-
#url ⇒ String
readonly
HTTP endpoint URL.
Instance Method Summary collapse
-
#initialize(url:, headers: {}, ssl_verify: true) ⇒ SslHttpTransport
constructor
A new instance of SslHttpTransport.
-
#send_request(request:) ⇒ Hash
Send a JSON-RPC request to the MCP server.
Constructor Details
#initialize(url:, headers: {}, ssl_verify: true) ⇒ SslHttpTransport
Returns a new instance of SslHttpTransport.
29 30 31 32 33 34 |
# File 'lib/swarm_sdk/v3/mcp/ssl_http_transport.rb', line 29 def initialize(url:, headers: {}, ssl_verify: true) @url = url @headers = headers @ssl_verify = ssl_verify @uri = URI.parse(url) end |
Instance Attribute Details
#url ⇒ String (readonly)
Returns HTTP endpoint URL.
24 25 26 |
# File 'lib/swarm_sdk/v3/mcp/ssl_http_transport.rb', line 24 def url @url end |
Instance Method Details
#send_request(request:) ⇒ Hash
Send a JSON-RPC request to the MCP server.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/swarm_sdk/v3/mcp/ssl_http_transport.rb', line 41 def send_request(request:) http = build_http post = build_post(request) response = http.request(post) JSON.parse(response.body) rescue OpenSSL::SSL::SSLError => e raise ::MCP::Client::RequestHandlerError.new( "SSL error connecting to MCP server #{@uri.host}: #{e.}", extract_method_params(request), error_type: :internal_error, original_error: e, ) rescue Net::HTTPError, Net::OpenTimeout, Net::ReadTimeout, SocketError, Errno::ECONNREFUSED => e raise ::MCP::Client::RequestHandlerError.new( "Connection error to MCP server #{@uri.host}: #{e.}", extract_method_params(request), error_type: :internal_error, original_error: e, ) end |