Add notification support
Co-authored-by: Kevin Fischer <kfischer_okarin@yahoo.co.jp>
This commit is contained in:
parent
8fbb2e86aa
commit
55b03fc7aa
1 changed files with 711 additions and 6 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue