MCP::Shared::Protocol
Constants
Log = ::Log.for(self)
Constructors
new(options : ProtocolOptions | Nil = nil)
SourceInstance methods
close
Sourceconnect(transport : Transport)
Sourcefallback_notification_handler
Sourcefallback_notification_handler=(fallback_notification_handler : JSONRPCNotification -> | Nil)
Sourcefallback_request_handler
Sourcefallback_request_handler=(fallback_request_handler : JSONRPCRequest, RequestHandlerExtra -> Result | Nil | Nil)
Sourcenotification(notification : JSONRPCNotification)
Sourceon_close
Sourcerequest(request : JSONRPCRequest, options : RequestOptions | Nil = nil) : Result
ameba:disable Metrics/CyclomaticComplexity
request_async(request : JSONRPCRequest, options : RequestOptions | Nil = nil) : Channel(AsyncResult(Result))
Sourcerequest_handler_async(method : String, &block : RequestParams, RequestHandlerExtra -> Channel(AsyncResult(Result)))
Register an async request handler that returns a
Channel(AsyncResult(Result)). The protocol waits on the channel
(or the request's cancel channel) and sends the appropriate
JSON-RPC response.
protocol.request_handler_async("my/method") do |params, extra|
channel = Channel(AsyncResult(Result)).new(1)
spawn do
channel.send(AsyncResult(Result).new(value: some_result))
channel.close
end
channel
end
transport
Sourcetransport=(transport : Transport | Nil)
Source