Skip to content

Commit b482cfc

Browse files
authored
fix: generate simple {} schema for tools with no parameters (#425)
1 parent cb4abcb commit b482cfc

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

crates/rmcp-macros/src/tool.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,9 @@ pub fn tool(attr: TokenStream, input: TokenStream) -> syn::Result<TokenStream> {
186186
rmcp::handler::server::common::cached_schema_for_type::<#params_ty>()
187187
})?
188188
} else {
189-
// if not found, use the default EmptyObject schema
189+
// if not found, use a simple empty JSON object
190190
syn::parse2::<Expr>(quote! {
191-
rmcp::handler::server::common::cached_schema_for_type::<rmcp::model::EmptyObject>()
191+
std::sync::Arc::new(serde_json::Map::new())
192192
})?
193193
}
194194
};

crates/rmcp/tests/test_tool_macros.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ async fn test_tool_macros() {
110110
async fn test_tool_macros_with_empty_param() {
111111
let _attr = Server::empty_param_tool_attr();
112112
println!("{_attr:?}");
113-
assert_eq!(_attr.input_schema.get("type").unwrap(), "object");
113+
assert!(_attr.input_schema.get("type").is_none());
114114
assert!(_attr.input_schema.get("properties").is_none());
115115
}
116116

0 commit comments

Comments
 (0)