@@ -214,6 +214,22 @@ pub(crate) fn tool_impl_item(attr: TokenStream, mut input: ItemImpl) -> syn::Res
214
214
let tool_impl_attr: ToolImplItemAttrs = syn:: parse2 ( attr) ?;
215
215
let tool_box_ident = tool_impl_attr. tool_box ;
216
216
let mut extend_quote = None ;
217
+ let description = if let Some ( expr) = tool_impl_attr. description {
218
+ // Use explicitly provided description if available
219
+ expr
220
+ } else {
221
+ // Try to extract documentation comments
222
+ let doc_content = input
223
+ . attrs
224
+ . iter ( )
225
+ . filter_map ( extract_doc_line)
226
+ . collect :: < Vec < _ > > ( )
227
+ . join ( "\n " ) ;
228
+
229
+ parse_quote ! {
230
+ #doc_content. trim( ) . to_string( )
231
+ }
232
+ } ;
217
233
// get all tool function ident
218
234
let mut tool_fn_idents = Vec :: new ( ) ;
219
235
for item in & input. items {
@@ -305,22 +321,6 @@ pub(crate) fn tool_impl_item(attr: TokenStream, mut input: ItemImpl) -> syn::Res
305
321
306
322
if tool_impl_attr. default_build {
307
323
let struct_name = input. self_ty . clone ( ) ;
308
- let description = if let Some ( expr) = tool_impl_attr. description {
309
- // Use explicitly provided description if available
310
- expr
311
- } else {
312
- // Try to extract documentation comments
313
- let doc_content = input
314
- . attrs
315
- . iter ( )
316
- . filter_map ( extract_doc_line)
317
- . collect :: < Vec < _ > > ( )
318
- . join ( "\n " ) ;
319
-
320
- parse_quote ! {
321
- #doc_content. trim( ) . to_string( )
322
- }
323
- } ;
324
324
let generic = & input. generics ;
325
325
let extend = quote ! {
326
326
impl #generic rmcp:: handler:: server:: ServerHandler for #struct_name {
0 commit comments