Skip to content

Commit 27a7459

Browse files
author
姚临倾
committed
Fix error location in document retrieval
1 parent dd72b63 commit 27a7459

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

crates/rmcp-macros/src/tool.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,22 @@ pub(crate) fn tool_impl_item(attr: TokenStream, mut input: ItemImpl) -> syn::Res
214214
let tool_impl_attr: ToolImplItemAttrs = syn::parse2(attr)?;
215215
let tool_box_ident = tool_impl_attr.tool_box;
216216
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+
};
217233
// get all tool function ident
218234
let mut tool_fn_idents = Vec::new();
219235
for item in &input.items {
@@ -305,22 +321,6 @@ pub(crate) fn tool_impl_item(attr: TokenStream, mut input: ItemImpl) -> syn::Res
305321

306322
if tool_impl_attr.default_build {
307323
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-
};
324324
let generic = &input.generics;
325325
let extend = quote! {
326326
impl #generic rmcp::handler::server::ServerHandler for #struct_name {

0 commit comments

Comments
 (0)