Module: MCPClient::ServerSSE::JsonRpcTransport
- Includes:
- JsonRpcCommon
- Included in:
- MCPClient::ServerSSE
- Defined in:
- lib/mcp_client/server_sse/json_rpc_transport.rb
Overview
JSON-RPC request/notification plumbing for SSE transport
Instance Method Summary collapse
-
#rpc_notify(method, params = {}) ⇒ void
Send a JSON-RPC notification (no response expected).
-
#rpc_request(method, params = {}) ⇒ Object
Generic JSON-RPC request: send method with params and return result.
Methods included from JsonRpcCommon
#build_jsonrpc_notification, #build_jsonrpc_request, #initialization_params, #ping, #process_jsonrpc_response, #with_retry
Instance Method Details
#rpc_notify(method, params = {}) ⇒ void
This method returns an undefined value.
Send a JSON-RPC notification (no response expected)
33 34 35 36 37 38 39 |
# File 'lib/mcp_client/server_sse/json_rpc_transport.rb', line 33 def rpc_notify(method, params = {}) ensure_initialized notif = build_jsonrpc_notification(method, params) post_json_rpc_request(notif) rescue MCPClient::Errors::ServerError, MCPClient::Errors::ConnectionError, Faraday::ConnectionFailed => e raise MCPClient::Errors::TransportError, "Failed to send notification: #{e.}" end |
#rpc_request(method, params = {}) ⇒ Object
Generic JSON-RPC request: send method with params and return result
19 20 21 22 23 24 25 26 27 |
# File 'lib/mcp_client/server_sse/json_rpc_transport.rb', line 19 def rpc_request(method, params = {}) ensure_initialized with_retry do request_id = @mutex.synchronize { @request_id += 1 } request = build_jsonrpc_request(method, params, request_id) send_jsonrpc_request(request) end end |