Skip to content

Commit 4b9bea7

Browse files
authored
Revert "feat!: relax tool result structuredContent type (modelcontextprotocol#919)" (modelcontextprotocol#932)
This reverts commit b8a936c.
1 parent b8a936c commit 4b9bea7

6 files changed

Lines changed: 30 additions & 38 deletions

File tree

crates/rmcp/src/model/content.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
// ToolUseContent/ToolResultContent are SEP-2577-deprecated; internal references are expected.
1111
#![expect(deprecated)]
1212
use serde::{Deserialize, Serialize};
13-
use serde_json::{Value, json};
13+
use serde_json::json;
1414

1515
use super::{Annotations, Meta, resource::ResourceContents};
1616

@@ -207,7 +207,7 @@ pub struct ToolResultContent {
207207
pub tool_use_id: String,
208208
pub content: Vec<ContentBlock>,
209209
#[serde(skip_serializing_if = "Option::is_none")]
210-
pub structured_content: Option<Value>,
210+
pub structured_content: Option<super::JsonObject>,
211211
#[serde(skip_serializing_if = "Option::is_none")]
212212
pub is_error: Option<bool>,
213213
}

crates/rmcp/tests/test_message_schema/client_json_rpc_message_schema.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2352,7 +2352,13 @@
23522352
"null"
23532353
]
23542354
},
2355-
"structuredContent": true,
2355+
"structuredContent": {
2356+
"type": [
2357+
"object",
2358+
"null"
2359+
],
2360+
"additionalProperties": true
2361+
},
23562362
"toolUseId": {
23572363
"type": "string"
23582364
}

crates/rmcp/tests/test_message_schema/client_json_rpc_message_schema_current.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2352,7 +2352,13 @@
23522352
"null"
23532353
]
23542354
},
2355-
"structuredContent": true,
2355+
"structuredContent": {
2356+
"type": [
2357+
"object",
2358+
"null"
2359+
],
2360+
"additionalProperties": true
2361+
},
23562362
"toolUseId": {
23572363
"type": "string"
23582364
}

crates/rmcp/tests/test_message_schema/server_json_rpc_message_schema.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3454,7 +3454,13 @@
34543454
"null"
34553455
]
34563456
},
3457-
"structuredContent": true,
3457+
"structuredContent": {
3458+
"type": [
3459+
"object",
3460+
"null"
3461+
],
3462+
"additionalProperties": true
3463+
},
34583464
"toolUseId": {
34593465
"type": "string"
34603466
}

crates/rmcp/tests/test_message_schema/server_json_rpc_message_schema_current.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3454,7 +3454,13 @@
34543454
"null"
34553455
]
34563456
},
3457-
"structuredContent": true,
3457+
"structuredContent": {
3458+
"type": [
3459+
"object",
3460+
"null"
3461+
],
3462+
"additionalProperties": true
3463+
},
34583464
"toolUseId": {
34593465
"type": "string"
34603466
}

crates/rmcp/tests/test_sampling.rs

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -370,38 +370,6 @@ fn test_tool_result_content_requires_content() {
370370
assert!(err.to_string().contains("missing field `content`"));
371371
}
372372

373-
#[tokio::test]
374-
async fn test_tool_result_content_with_array_structured_content() -> Result<()> {
375-
let structured =
376-
serde_json::json!([{ "city": "SF", "temp": 72 }, { "city": "NY", "temp": 65 }]);
377-
let mut tool_result = ToolResultContent::new("call_123", vec![ContentBlock::text("forecast")]);
378-
tool_result.structured_content = Some(structured);
379-
380-
let json = serde_json::to_string(&tool_result)?;
381-
let deserialized: ToolResultContent = serde_json::from_str(&json)?;
382-
assert_eq!(tool_result, deserialized);
383-
assert!(deserialized.structured_content.unwrap().is_array());
384-
385-
Ok(())
386-
}
387-
388-
#[tokio::test]
389-
async fn test_tool_result_content_with_primitive_structured_content() -> Result<()> {
390-
let structured = serde_json::json!(42);
391-
let mut tool_result = ToolResultContent::new("call_123", vec![ContentBlock::text("count")]);
392-
tool_result.structured_content = Some(structured);
393-
394-
let json = serde_json::to_string(&tool_result)?;
395-
let deserialized: ToolResultContent = serde_json::from_str(&json)?;
396-
assert_eq!(tool_result, deserialized);
397-
assert!(matches!(
398-
deserialized.structured_content,
399-
Some(serde_json::Value::Number(_))
400-
));
401-
402-
Ok(())
403-
}
404-
405373
#[tokio::test]
406374
async fn test_sampling_message_with_tool_use() -> Result<()> {
407375
let message = SamplingMessage::assistant_tool_use(

0 commit comments

Comments
 (0)