fix: strip and validate tool outputSchema and inputSchema (#860)

* fix: remove unnecessary fields from tools' outputSchema

* fix: validate input schema root type per MCP spec
This commit is contained in:
Dale Seo 2026-06-02 12:01:33 -04:00 • committed by GitHub
commit 254f04a764
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -250,7 +250,9 @@ where
attr: Tool::new(
name.into(),
"",
schema_for_input::<crate::model::JsonObject>(),
schema_for_input::<crate::model::JsonObject>().unwrap_or_else(|e| {
panic!("Invalid input schema for JsonObject: {e}");
}),
),
call: self,
_marker: std::marker::PhantomData,
@ -287,7 +289,12 @@ where
self
}
pub fn parameters<T: JsonSchema + 'static>(mut self) -> Self {
self.attr.input_schema = schema_for_input::<T>();
self.attr.input_schema = schema_for_input::<T>().unwrap_or_else(|e| {
panic!(
"Invalid input schema for `{}`: {e}",
std::any::type_name::<T>()
)
});
self
}
pub fn parameters_value(mut self, schema: serde_json::Value) -> Self {