Skip to main content

prompt

Attribute Macro prompt 

Source
#[prompt]
Expand description

Marks a plain fn returning a Prompt as a prompt the server offers.

This attribute generates nothing on its own, for the same reason [tool] generates nothing: it expands inside the impl block, where Rust forbids declaring a struct or a function. [server] reads the mark and emits the registration.

§The shape

fn name() -> Prompt

A plain fn, for the same reason a [resource] is one: a prompt is registered once, while the server is being built, so there is nothing to await.

§Arguments

Declared in the body through Prompt::with_argument, not through the attribute. A prompt’s arguments are an ordered list of named, required-or-not entries, and a comma-separated attribute list cannot express “required” without a second parallel spelling of every argument’s name.

§Examples

A worked example lives in crates/protocol-droid/tests/macros.rs, where every macro shape is exercised against the real Resource and Prompt types and the listings are read back through the dispatcher. A doctest here would be a strict subset of that coverage and would also require this crate to depend on protocol-droid for compilation, which is the cycle the docstring in Cargo.toml says it does not create.