Add notification support

Co-authored-by: Kevin Fischer <kfischer_okarin@yahoo.co.jp>
This commit is contained in:
Riley Shott 2025-06-02 13:46:18 -07:00
commit 55b03fc7aa

View file

@ -43,10 +43,18 @@ module MCP
$stdout.flush
end
def send_response(message)
json_message = message.is_a?(String) ? message : JSON.generate(message)
$stdout.puts(json_message)
$stdout.flush
def send_notification(method, params = nil)
notification = {
jsonrpc: "2.0",
method: method,
}
notification[:params] = params if params
send_response(notification)
true
rescue => e
MCP.configuration.exception_reporter.call(e, { error: "Failed to send notification" })
false
end
end
end