From 66609891efaf1a819084e584b078f5e7b26e5659 Mon Sep 17 00:00:00 2001 From: Iamsohungrynow <261225237+Iamsohungrynow@users.noreply.github.com> Date: Wed, 21 Oct 2026 22:51:40 +0800 Subject: [PATCH] fix(model): accept URL elicitation requests without elicitationId 2026-07-28 removed elicitationId from URL mode elicitation requests, so the spec's own URL example failed to parse and an input_required result carrying it fell through to CustomResult. A missing id now reads as empty and is still serialized, so clients from before 2026-07-28 keep getting it; the field stays a String so the public API is unchanged. --- crates/rmcp/src/model.rs | 13 +++++++++++++ .../server_json_rpc_message_schema.json | 6 +++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/crates/rmcp/src/model.rs b/crates/rmcp/src/model.rs index 9dd04564e..e2bd23d57 100644 --- a/crates/rmcp/src/model.rs +++ b/crates/rmcp/src/model.rs @@ -3934,6 +3934,7 @@ enum ElicitRequestParamsWire { meta: Option, message: String, url: String, + #[serde(default)] elicitation_id: String, }, #[serde(untagged, rename_all = "camelCase")] @@ -4043,6 +4044,7 @@ pub enum ElicitRequestParams { /// The client should direct the user to this URL to complete the elicitation. url: String, /// The unique identifier for this elicitation request. + /// Protocol `2026-07-28` removed this field: it is empty when absent. elicitation_id: String, }, } @@ -6138,6 +6140,17 @@ mod tests { assert_eq!(json_url, expected_url_json); } + #[test] + fn test_url_elicitation_without_elicitation_id() { + let params: ElicitRequestParams = serde_json::from_value(json!({ + "mode": "url", + "url": "https://mcp.example.com/ui/set_api_key", + "message": "Please provide your API key to continue." + })) + .expect("Deserialization failed"); + assert_eq!(serde_json::to_value(¶ms).unwrap()["elicitationId"], ""); + } + #[test] fn notification_without_params_should_deserialize_as_bare_jsonrpc_message() { let payload = b"{\"method\":\"notifications/initialized\",\"jsonrpc\":\"2.0\"}"; diff --git a/crates/rmcp/tests/test_message_schema/server_json_rpc_message_schema.json b/crates/rmcp/tests/test_message_schema/server_json_rpc_message_schema.json index cebb3ed37..46389b629 100644 --- a/crates/rmcp/tests/test_message_schema/server_json_rpc_message_schema.json +++ b/crates/rmcp/tests/test_message_schema/server_json_rpc_message_schema.json @@ -828,7 +828,8 @@ ] }, "elicitationId": { - "type": "string" + "type": "string", + "default": "" }, "message": { "type": "string" @@ -844,8 +845,7 @@ "required": [ "mode", "message", - "url", - "elicitationId" + "url" ] }, {