Skip to main content

CompletionHandler

Trait CompletionHandler 

Source
pub trait CompletionHandler: Send + Sync {
    // Required method
    fn complete(
        &self,
        request: &CompleteRequest,
        ctx: &Context<'_>,
    ) -> impl Future<Output = Result<CompleteResult, McpError>> + Send;
}
Expand description

Handler for completion suggestions (completion/complete).

Implement this trait to provide autocomplete suggestions for prompt arguments and resource-template variables. The full CompleteRequest is passed so a handler can dispatch on the ref, read the argument being typed, and use any previously-resolved context. Return a CompleteResult — build one from a Completion via .into() for the common case, or attach result-level _meta with CompleteResult::with_meta. The route layer caps values at MAX_COMPLETION_VALUES.

Required Methods§

Source

fn complete( &self, request: &CompleteRequest, ctx: &Context<'_>, ) -> impl Future<Output = Result<CompleteResult, McpError>> + Send

Produce completion suggestions for the request.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T: CompletionHandler> CompletionHandler for Arc<T>

Source§

fn complete( &self, request: &CompleteRequest, ctx: &Context<'_>, ) -> impl Future<Output = Result<CompleteResult, McpError>> + Send

Implementors§