INNER CODE UNIT · Rust

tool_handler

modelcontextprotocol/rust-sdk · crates/rmcp-macros/src/lib.rs:226

pub fn tool_handler(attr: TokenStream, input: TokenStream) -> TokenStream {
    tool_handler::tool_handler(attr.into(), input.into())
        .unwrap_or_else(|err| err.to_compile_error())
        .into()
}

/// # prompt
///
/// This macro is used to mark a function as a prompt handler.
///
/// This will generate a function that returns the attribute of this prompt, with type `rmcp::model::Prompt`.
///
/// ## Usage
///
/// | field             | type     | usage |
/// | :-                | :-       | :-    |
/// | `name`            | `String` | The name of the prompt. If not provided, it defaults to the function name. |
/// | `description`     | `Expr`   | A description of the prompt. A string literal or an expression that evaluates to a `&'static str`. The document of this function will be used if not provided. |

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…