class

MCP::Shared::Protocol

Inherits Reference < Object

Constants

Log = ::Log.for(self)

Constructors

new(options : ProtocolOptions | Nil = nil)
Source

Instance methods

assert_capability_for_method(method : String)
Source
assert_notification_capability(method : String)
Source
assert_request_handler_capability(method : String)
Source
close
Source
connect(transport : Transport)
Source
fallback_notification_handler
Source
fallback_notification_handler=(fallback_notification_handler : JSONRPCNotification -> | Nil)
Source
fallback_request_handler
Source
fallback_request_handler=(fallback_request_handler : JSONRPCRequest, RequestHandlerExtra -> Result | Nil | Nil)
Source
notification(notification : JSONRPCNotification)
Source
notification_handler(method : String, &block : MCP::Protocol::Notification | Nil -> )
Source
on_close
Source
on_error(error : Exception)
Source
remove_notification_handler(method : String)
Source
remove_request_handler(method : String)
Source
request(request : JSONRPCRequest, options : RequestOptions | Nil = nil) : Result

ameba:disable Metrics/CyclomaticComplexity

Source
request_async(request : JSONRPCRequest, options : RequestOptions | Nil = nil) : Channel(AsyncResult(Result))
Source
request_handler(method : String, &block : RequestParams, RequestHandlerExtra -> Result | Nil)
Source
request_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
Source
transport
Source
transport=(transport : Transport | Nil)
Source