pub trait ClientRequester: Send + Sync {
// Required methods
fn sample<'life0, 'async_trait>(
&'life0 self,
params: CreateMessageParams,
) -> Pin<Box<dyn Future<Output = Result<CreateMessageResult>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn elicit<'life0, 'async_trait>(
&'life0 self,
params: ElicitRequestParams,
) -> Pin<Box<dyn Future<Output = Result<ElicitResult>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided method
fn request<'life0, 'async_trait>(
&'life0 self,
method: String,
params: Value,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
}Expand description
Trait for sending requests from server to client
This enables bidirectional communication where the server can request actions from the client, such as sampling (LLM requests), elicitation (user input requests), and task polling (per SEP-1686).
Required Methods§
Sourcefn sample<'life0, 'async_trait>(
&'life0 self,
params: CreateMessageParams,
) -> Pin<Box<dyn Future<Output = Result<CreateMessageResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn sample<'life0, 'async_trait>(
&'life0 self,
params: CreateMessageParams,
) -> Pin<Box<dyn Future<Output = Result<CreateMessageResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Send a sampling request to the client
Returns the LLM completion result from the client.
Sourcefn elicit<'life0, 'async_trait>(
&'life0 self,
params: ElicitRequestParams,
) -> Pin<Box<dyn Future<Output = Result<ElicitResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn elicit<'life0, 'async_trait>(
&'life0 self,
params: ElicitRequestParams,
) -> Pin<Box<dyn Future<Output = Result<ElicitResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Send an elicitation request to the client
This requests user input from the client. The request can be either form-based (structured input) or URL-based (redirect to external URL).
Returns the elicitation result with the user’s action and any submitted data.
Provided Methods§
Sourcefn request<'life0, 'async_trait>(
&'life0 self,
method: String,
params: Value,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn request<'life0, 'async_trait>(
&'life0 self,
method: String,
params: Value,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Send a generic JSON-RPC request to the client.
Used by typed helpers (RequestContext::get_task_info etc.) to
dispatch arbitrary request methods. The default implementation returns
an error so existing custom implementations of this trait keep
compiling; they only need to override this if they want to support
methods beyond sample and elicit.