Phantom.Elicit (phantom_mcp v0.3.2)

View Source

The Model Context Protocol (MCP) provides a standardized way for servers to request additional information from users through the client during interactions. This flow allows clients to maintain control over user interactions and data sharing while enabling servers to gather necessary information dynamically. Servers request structured data from users with JSON schemas to validate responses.

Error

Note: this is not yet tested

https://modelcontextprotocol.io/specification/2025-06-18/client/elicitation

sequenceDiagram
    participant User
    participant Client
    participant Server

    Note over Server,Client: Server initiates elicitation
    Server->>Client: elicitation/create

    Note over Client,User: Human interaction
    Client->>User: Present elicitation UI
    User-->>Client: Provide requested information

    Note over Server,Client: Complete request
    Client-->>Server: Return user response

    Note over Server: Continue processing with new information

Summary

Types

boolean_property()

@type boolean_property() :: %{
  name: String.t(),
  required: boolean(),
  type: :boolean,
  title: String.t(),
  description: String.t(),
  default: boolean()
}

enum_property()

@type enum_property() :: %{
  name: String.t(),
  required: boolean(),
  type: :string,
  title: String.t(),
  description: String.t(),
  enum: [{value :: String.t(), name :: String.t()}]
}

json()

@type json() :: %{
  message: String.t(),
  requestedSchema: %{
    type: String.t(),
    required: [String.t()],
    properties: %{required(String.t()) => map()}
  }
}

number_property()

@type number_property() :: %{
  name: String.t(),
  required: boolean(),
  type: :number | :integer,
  title: String.t(),
  description: String.t(),
  minimum: pos_integer(),
  maximum: pos_integer()
}

string_property()

@type string_property() :: %{
  name: String.t(),
  required: boolean(),
  type: :string,
  title: String.t(),
  description: String.t(),
  min_length: pos_integer(),
  max_length: pos_integer(),
  pattern: String.t() | Regex.t(),
  format: :email | :uri | :date | :datetime
}

t()

@type t() :: %Phantom.Elicit{
  message: String.t(),
  requested_schema: [
    number_property() | boolean_property() | enum_property() | string_property()
  ]
}

Functions

build(attrs)

@spec build(%{
  message: String.t(),
  requested_schema: [
    number_property() | boolean_property() | enum_property() | string_property()
  ]
}) :: t()

to_json(elicit)