Fix JSON-RPC notification format in Streamable HTTP transport
Update send_notification method to properly construct JSON-RPC notification objects with jsonrpc version and method fields. This ensures notifications conform to the JSON-RPC 2.0 specification when sent over HTTP transport. https://www.jsonrpc.org/specification#notification Another goal is to standardise the `send_notification` interface. Before the revision, it was sufficient to pass the method and parameters in the case of stdio. However, in the case of Streamable, a hash based on the JSON-RPC specification must be passed.
This commit is contained in:
parent
eb6156c272
commit
e7fafddf94
1 changed files with 17 additions and 14 deletions
|
|
@ -34,7 +34,13 @@ module MCP
|
|||
end
|
||||
end
|
||||
|
||||
def send_notification(notification, session_id: nil)
|
||||
def send_notification(method, params = nil, session_id: nil)
|
||||
notification = {
|
||||
jsonrpc: "2.0",
|
||||
method:,
|
||||
}
|
||||
notification[:params] = params if params
|
||||
|
||||
@mutex.synchronize do
|
||||
if session_id
|
||||
# Send to specific session
|
||||
|
|
|
|||
Loading…
Reference in a new issue