@@ -1113,7 +1113,7 @@ impl schemars::JsonSchema for DiscoverRequestParams {
11131113pub type DiscoverRequest = Request < DiscoverRequestMethod , DiscoverRequestParams > ;
11141114
11151115/// The server's response to a [`DiscoverRequest`].
1116- #[ derive( Debug , Serialize , Deserialize , Clone , PartialEq ) ]
1116+ #[ derive( Debug , Serialize , Clone , PartialEq ) ]
11171117#[ serde( rename_all = "camelCase" ) ]
11181118#[ cfg_attr( feature = "schemars" , derive( schemars:: JsonSchema ) ) ]
11191119#[ non_exhaustive]
@@ -1124,7 +1124,8 @@ pub struct DiscoverResult {
11241124 pub supported_versions : Vec < ProtocolVersion > ,
11251125 /// Capabilities provided by this server.
11261126 pub capabilities : ServerCapabilities ,
1127- /// Information about the server implementation.
1127+ /// Information about the server implementation. Also accepted from
1128+ /// `_meta["io.modelcontextprotocol/serverInfo"]` during deserialization.
11281129 pub server_info : Implementation ,
11291130 /// Optional guidance for using the server.
11301131 #[ serde( skip_serializing_if = "Option::is_none" ) ]
@@ -1138,6 +1139,53 @@ pub struct DiscoverResult {
11381139 pub meta : Option < MetaObject > ,
11391140}
11401141
1142+ impl < ' de > Deserialize < ' de > for DiscoverResult {
1143+ fn deserialize < D > ( deserializer : D ) -> Result < Self , D :: Error >
1144+ where
1145+ D : serde:: Deserializer < ' de > ,
1146+ {
1147+ #[ derive( Deserialize ) ]
1148+ #[ serde( rename_all = "camelCase" ) ]
1149+ struct Helper {
1150+ result_type : ResultType ,
1151+ supported_versions : Vec < ProtocolVersion > ,
1152+ capabilities : ServerCapabilities ,
1153+ server_info : Option < Implementation > ,
1154+ instructions : Option < String > ,
1155+ ttl_ms : u64 ,
1156+ cache_scope : CacheScope ,
1157+ #[ serde( rename = "_meta" ) ]
1158+ meta : Option < MetaObject > ,
1159+ }
1160+
1161+ let helper = Helper :: deserialize ( deserializer) ?;
1162+ let server_info = match helper. server_info {
1163+ Some ( server_info) => server_info,
1164+ None => {
1165+ let metadata_server_info = helper
1166+ . meta
1167+ . as_ref ( )
1168+ . and_then ( |metadata| metadata. 0 . get ( "io.modelcontextprotocol/serverInfo" ) )
1169+ . ok_or_else ( || serde:: de:: Error :: missing_field ( "serverInfo" ) ) ?;
1170+
1171+ serde_json:: from_value ( metadata_server_info. clone ( ) )
1172+ . map_err ( serde:: de:: Error :: custom) ?
1173+ }
1174+ } ;
1175+
1176+ Ok ( Self {
1177+ result_type : helper. result_type ,
1178+ supported_versions : helper. supported_versions ,
1179+ capabilities : helper. capabilities ,
1180+ server_info,
1181+ instructions : helper. instructions ,
1182+ ttl_ms : helper. ttl_ms ,
1183+ cache_scope : helper. cache_scope ,
1184+ meta : helper. meta ,
1185+ } )
1186+ }
1187+ }
1188+
11411189impl DiscoverResult {
11421190 /// Create a non-cacheable private discovery result.
11431191 pub fn new (
0 commit comments