Skip to content

Commit bad1018

Browse files
author
Brandon Bennett
committed
fix: address Dale's PR review - direct schema.get assertions, remove ArrayTool
- Replace loose schema_str.contains(...) assertions with direct schema.get("type") equality checks in test_tool_builder_methods.rs and test_structured_output.rs - Remove redundant ArrayTool fixture and its round-trip serde_json::from_str test from tool_traits.rs since schema is already Arc<JsonObject> - Drop dead schema_str variable in test_structured_output.rs
1 parent 20f981f commit bad1018

3 files changed

Lines changed: 4 additions & 44 deletions

File tree

crates/rmcp/src/handler/server/router/tool/tool_traits.rs

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -340,43 +340,4 @@ mod tests {
340340
assert_eq!(result, ErrorData::invalid_params("invalid params", None));
341341
}
342342
}
343-
344-
struct ArrayTool;
345-
impl ToolBase for ArrayTool {
346-
type Parameter = AddParameter;
347-
type Output = Vec<AddOutput>;
348-
type Error = ErrorData;
349-
350-
fn name() -> Cow<'static, str> {
351-
"array-tool".into()
352-
}
353-
}
354-
impl SyncTool<TraitBasedToolServer> for ArrayTool {
355-
fn invoke(
356-
_service: &TraitBasedToolServer,
357-
_param: Self::Parameter,
358-
) -> Result<Self::Output, Self::Error> {
359-
Ok(vec![])
360-
}
361-
}
362-
impl AsyncTool<TraitBasedToolServer> for ArrayTool {
363-
async fn invoke(
364-
_service: &TraitBasedToolServer,
365-
_param: Self::Parameter,
366-
) -> Result<Self::Output, Self::Error> {
367-
Ok(vec![])
368-
}
369-
}
370-
371-
#[test]
372-
fn test_toolbase_output_schema_with_array_output() {
373-
let schema = ArrayTool::output_schema();
374-
assert!(schema.is_some());
375-
let schema = schema.unwrap();
376-
let schema_value: serde_json::Value = serde_json::from_str(
377-
&serde_json::to_string(&*schema).expect("failed to serialize schema"),
378-
)
379-
.expect("failed to parse schema JSON");
380-
assert_eq!(schema_value["type"], "array");
381-
}
382343
}

crates/rmcp/tests/test_structured_output.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,5 @@ async fn test_tool_with_primitive_output_schema() {
414414
let schema = get_count_tool.output_schema.as_ref().unwrap();
415415

416416
// Check that the schema contains integer type
417-
let schema_str = serde_json::to_string(schema).unwrap();
418-
assert!(schema_str.contains("integer"));
417+
assert_eq!(schema.get("type"), Some(&serde_json::json!("integer")));
419418
}

crates/rmcp/tests/test_tool_builder_methods.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ fn test_with_output_schema_primitive() {
6868

6969
assert!(tool.output_schema.is_some());
7070

71-
let schema_str = serde_json::to_string(tool.output_schema.as_ref().unwrap()).unwrap();
72-
assert!(schema_str.contains("\"type\":\"integer\""));
71+
let schema = tool.output_schema.as_ref().unwrap();
72+
assert_eq!(schema.get("type"), Some(&serde_json::json!("integer")));
7373
// title should be stripped from output schema
74-
assert!(!schema_str.contains("title"));
74+
assert!(schema.get("title").is_none());
7575
}
7676

7777
#[test]

0 commit comments

Comments
 (0)