Skip to main content

Elicit

Derive Macro Elicit 

Source
#[derive(Elicit)]
{
    // Attributes available to this derive:
    #[prompt]
    #[alts]
    #[skip]
}
Expand description

Derive the Elicit trait for enums (→ Select) or structs (→ Survey).

§Supported Attributes

  • #[prompt("...")] - Custom prompt text (applies to type or fields)
  • #[alts([...])] - Synonym mappings for enum variants (planned for v0.3.0)
  • #[skip] - Skip a struct field during elicitation

§Enum Derivation

For enums, generates implementations of:

  • Prompt - Provides prompt text
  • Select - Finite options pattern
  • Elicit - Calls elicit_select MCP tool, then elicits fields

Supports three variant types:

§Unit Variants

#[derive(Elicit)]
enum Role {
    System,
    User,
    Assistant,
}

§Tuple Variants

#[derive(Elicit)]
enum MediaSource {
    Url(String),
    Base64(String),
    Binary(Vec<u8>),
}

§Struct Variants

#[derive(Elicit)]
enum Input {
    Text(String),
    Image {
        mime: Option<String>,
        source: MediaSource,
    },
}

All three variant types can coexist in the same enum.

§Struct Derivation

For structs, generates implementations of:

  • Prompt - Provides prompt text
  • Survey - Multi-field elicitation pattern
  • Elicit - Sequential field elicitation

§Examples

use elicitation::Elicit;

#[derive(Elicit)]
enum Status {
    Active,
    Inactive,
}

#[derive(Elicit)]
#[prompt("Select your favorite color:")]
enum Color {
    Red,
    Green,
    Blue,
}