Merge pull request #448 from koic/handle_non_object_json_rpc_messages

Handle non-object JSON-RPC messages without raising
This commit is contained in:
Koichi ITO 2026-07-12 02:12:46 +09:00 • committed by GitHub
commit 3d442d0a65
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -259,7 +259,9 @@ module MCP
parsed = JSON.parse(line.strip)
next unless parsed.key?("id")
# A JSON-RPC message is an object; skip a non-object frame (array or scalar)
# the same way as a frame without an id.
next unless parsed.is_a?(Hash) && parsed.key?("id")
return parsed if parsed["id"] == request_id
end