From b482cfc4bb072c4ea3ad146f881c62b08aacfddd Mon Sep 17 00:00:00 2001 From: Dale Seo <5466341+DaleSeo@users.noreply.github.com> Date: Mon, 8 Sep 2025 02:40:02 -0400 Subject: [PATCH] fix: generate simple {} schema for tools with no parameters (#425) --- crates/rmcp-macros/src/tool.rs | 4 ++-- crates/rmcp/tests/test_tool_macros.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/rmcp-macros/src/tool.rs b/crates/rmcp-macros/src/tool.rs index a9c6e0d..f50ba93 100644 --- a/crates/rmcp-macros/src/tool.rs +++ b/crates/rmcp-macros/src/tool.rs @@ -186,9 +186,9 @@ pub fn tool(attr: TokenStream, input: TokenStream) -> syn::Result { rmcp::handler::server::common::cached_schema_for_type::<#params_ty>() })? } else { - // if not found, use the default EmptyObject schema + // if not found, use a simple empty JSON object syn::parse2::(quote! { - rmcp::handler::server::common::cached_schema_for_type::() + std::sync::Arc::new(serde_json::Map::new()) })? } }; diff --git a/crates/rmcp/tests/test_tool_macros.rs b/crates/rmcp/tests/test_tool_macros.rs index e30d31c..8825f12 100644 --- a/crates/rmcp/tests/test_tool_macros.rs +++ b/crates/rmcp/tests/test_tool_macros.rs @@ -110,7 +110,7 @@ async fn test_tool_macros() { async fn test_tool_macros_with_empty_param() { let _attr = Server::empty_param_tool_attr(); println!("{_attr:?}"); - assert_eq!(_attr.input_schema.get("type").unwrap(), "object"); + assert!(_attr.input_schema.get("type").is_none()); assert!(_attr.input_schema.get("properties").is_none()); }