Skip to main content

prompt_handler

Attribute Macro prompt_handler 

Source
#[prompt_handler]
Expand description

§prompt_handler

This macro generates handler methods for get_prompt and list_prompts in the implementation block, using a PromptRouter. It also auto-generates get_info() with prompts capability enabled if not already provided.

§Usage

fieldtypeusage
routerExprThe expression to access the PromptRouter instance. Defaults to Self::prompt_router().
metaExprOptional metadata for ListPromptsResult.

§Example

#[prompt_handler]
impl ServerHandler for MyPromptHandler {
    // ...implement other handler methods
}

or using a custom router expression:

#[prompt_handler(router = self.prompt_router)]
impl ServerHandler for MyPromptHandler {
   // ...implement other handler methods
}