You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Client#discover and #server_implementation raise TypeError when _meta is not an object #749
Both readers look up the io.modelcontextprotocol/serverInfo stamp with dig("_meta", ...). When a server sends _meta as something other than an object or null, such as false, a string, a number or an array, dig raises TypeError. discover then fails as a whole, and server_implementation never reaches the top-level serverInfo fallback that servers built against the SEP-2575 text send.
To Reproduce
Save as repro.rb in the repository root and run bundle exec ruby -Ilib repro.rb on main (2e07497):
A _meta that is not an object is ignored for the identity, so both readers return the top-level serverInfo ({"name" => "srv", "version" => "1.0"}), or nil when there is none.
Logs
_meta: false, discover: TypeError: FalseClass does not have #dig method
_meta: false, server_implementation: TypeError: FalseClass does not have #dig method
_meta: "meta", discover: TypeError: String does not have #dig method
_meta: "meta", server_implementation: TypeError: String does not have #dig method
_meta: 1, discover: TypeError: Integer does not have #dig method
_meta: 1, server_implementation: TypeError: Integer does not have #dig method
_meta: [], discover: TypeError: no implicit conversion of String into Integer
_meta: [], server_implementation: TypeError: no implicit conversion of String into Integer
Additional context
Ruby 4.0.10. Only a server that sends an invalid _meta triggers this. I have a fix with tests and will open a PR for it.
Activity