Skip to content

Commit b749e3c

Browse files
authored
feat(SEP-973): following change Icon.sizes from string to string array (#479)
Ref: modelcontextprotocol/modelcontextprotocol#1531
1 parent aeeff75 commit b749e3c

File tree

6 files changed

+35
-20
lines changed

6 files changed

+35
-20
lines changed

crates/rmcp/src/model.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -713,9 +713,9 @@ pub struct Icon {
713713
/// Optional override if the server's MIME type is missing or generic
714714
#[serde(skip_serializing_if = "Option::is_none")]
715715
pub mime_type: Option<String>,
716-
/// Size specification (e.g., "48x48", "any" for SVG, or "48x48 96x96")
716+
/// Size specification, each string should be in WxH format (e.g., `\"48x48\"`, `\"96x96\"`) or `\"any\"` for scalable formats like SVG
717717
#[serde(skip_serializing_if = "Option::is_none")]
718-
pub sizes: Option<String>,
718+
pub sizes: Option<Vec<String>>,
719719
}
720720

721721
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
@@ -2060,13 +2060,13 @@ mod tests {
20602060
let icon = Icon {
20612061
src: "https://example.com/icon.png".to_string(),
20622062
mime_type: Some("image/png".to_string()),
2063-
sizes: Some("48x48".to_string()),
2063+
sizes: Some(vec!["48x48".to_string()]),
20642064
};
20652065

20662066
let json = serde_json::to_value(&icon).unwrap();
20672067
assert_eq!(json["src"], "https://example.com/icon.png");
20682068
assert_eq!(json["mimeType"], "image/png");
2069-
assert_eq!(json["sizes"], "48x48");
2069+
assert_eq!(json["sizes"][0], "48x48");
20702070

20712071
// Test deserialization
20722072
let deserialized: Icon = serde_json::from_value(json).unwrap();
@@ -2097,12 +2097,12 @@ mod tests {
20972097
Icon {
20982098
src: "https://example.com/icon.png".to_string(),
20992099
mime_type: Some("image/png".to_string()),
2100-
sizes: Some("48x48".to_string()),
2100+
sizes: Some(vec!["48x48".to_string()]),
21012101
},
21022102
Icon {
21032103
src: "https://example.com/icon.svg".to_string(),
21042104
mime_type: Some("image/svg+xml".to_string()),
2105-
sizes: Some("any".to_string()),
2105+
sizes: Some(vec!["any".to_string()]),
21062106
},
21072107
]),
21082108
website_url: Some("https://example.com".to_string()),
@@ -2113,7 +2113,9 @@ mod tests {
21132113
assert_eq!(json["websiteUrl"], "https://example.com");
21142114
assert!(json["icons"].is_array());
21152115
assert_eq!(json["icons"][0]["src"], "https://example.com/icon.png");
2116+
assert_eq!(json["icons"][0]["sizes"][0], "48x48");
21162117
assert_eq!(json["icons"][1]["mimeType"], "image/svg+xml");
2118+
assert_eq!(json["icons"][1]["sizes"][0], "any");
21172119
}
21182120

21192121
#[test]
@@ -2143,7 +2145,7 @@ mod tests {
21432145
icons: Some(vec![Icon {
21442146
src: "https://example.com/server.png".to_string(),
21452147
mime_type: Some("image/png".to_string()),
2146-
sizes: None,
2148+
sizes: Some(vec!["48x48".to_string()]),
21472149
}]),
21482150
website_url: Some("https://docs.example.com".to_string()),
21492151
},
@@ -2156,6 +2158,7 @@ mod tests {
21562158
json["serverInfo"]["icons"][0]["src"],
21572159
"https://example.com/server.png"
21582160
);
2161+
assert_eq!(json["serverInfo"]["icons"][0]["sizes"][0], "48x48");
21592162
assert_eq!(json["serverInfo"]["websiteUrl"], "https://docs.example.com");
21602163
}
21612164
}

crates/rmcp/tests/test_message_schema/client_json_rpc_message_schema.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -499,11 +499,14 @@
499499
]
500500
},
501501
"sizes": {
502-
"description": "Size specification (e.g., \"48x48\", \"any\" for SVG, or \"48x48 96x96\")",
502+
"description": "Size specification, each string should be in WxH format (e.g., `\\\"48x48\\\"`, `\\\"96x96\\\"`) or `\\\"any\\\"` for scalable formats like SVG",
503503
"type": [
504-
"string",
504+
"array",
505505
"null"
506-
]
506+
],
507+
"items": {
508+
"type": "string"
509+
}
507510
},
508511
"src": {
509512
"description": "A standard URI pointing to an icon resource",

crates/rmcp/tests/test_message_schema/client_json_rpc_message_schema_current.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -499,11 +499,14 @@
499499
]
500500
},
501501
"sizes": {
502-
"description": "Size specification (e.g., \"48x48\", \"any\" for SVG, or \"48x48 96x96\")",
502+
"description": "Size specification, each string should be in WxH format (e.g., `\\\"48x48\\\"`, `\\\"96x96\\\"`) or `\\\"any\\\"` for scalable formats like SVG",
503503
"type": [
504-
"string",
504+
"array",
505505
"null"
506-
]
506+
],
507+
"items": {
508+
"type": "string"
509+
}
507510
},
508511
"src": {
509512
"description": "A standard URI pointing to an icon resource",

crates/rmcp/tests/test_message_schema/server_json_rpc_message_schema.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -630,11 +630,14 @@
630630
]
631631
},
632632
"sizes": {
633-
"description": "Size specification (e.g., \"48x48\", \"any\" for SVG, or \"48x48 96x96\")",
633+
"description": "Size specification, each string should be in WxH format (e.g., `\\\"48x48\\\"`, `\\\"96x96\\\"`) or `\\\"any\\\"` for scalable formats like SVG",
634634
"type": [
635-
"string",
635+
"array",
636636
"null"
637-
]
637+
],
638+
"items": {
639+
"type": "string"
640+
}
638641
},
639642
"src": {
640643
"description": "A standard URI pointing to an icon resource",

crates/rmcp/tests/test_message_schema/server_json_rpc_message_schema_current.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -630,11 +630,14 @@
630630
]
631631
},
632632
"sizes": {
633-
"description": "Size specification (e.g., \"48x48\", \"any\" for SVG, or \"48x48 96x96\")",
633+
"description": "Size specification, each string should be in WxH format (e.g., `\\\"48x48\\\"`, `\\\"96x96\\\"`) or `\\\"any\\\"` for scalable formats like SVG",
634634
"type": [
635-
"string",
635+
"array",
636636
"null"
637-
]
637+
],
638+
"items": {
639+
"type": "string"
640+
}
638641
},
639642
"src": {
640643
"description": "A standard URI pointing to an icon resource",

examples/simple-chat-client/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ rmcp = { workspace = true, features = [
1919
"transport-child-process",
2020
"transport-sse-client-reqwest",
2121
"transport-streamable-http-client-reqwest"
22-
], no-default-features = true }
22+
] }
2323
clap = { version = "4.0", features = ["derive"] }

0 commit comments

Comments
 (0)