Skip to main content

CompletionHandler

Trait CompletionHandler 

Source
pub trait CompletionHandler: Send + Sync {
    // Required method
    fn complete<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        reference: &'life1 CompletionReference,
        argument: &'life2 CompletionArgument,
        context: Option<&'life3 CompletionContext>,
    ) -> Pin<Box<dyn Future<Output = McpResult<Vec<String>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
}
Expand description

Trait for handling completion requests

Implement Trait to provide smart autocompletion for prompts, tools, and resources in your MCP server.

Required Methods§

Source

fn complete<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, reference: &'life1 CompletionReference, argument: &'life2 CompletionArgument, context: Option<&'life3 CompletionContext>, ) -> Pin<Box<dyn Future<Output = McpResult<Vec<String>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Generate completion suggestions

Method is called when a client requests autocompletion for an argument value. The implementation should analyze the context and return relevant completion suggestions.

§Arguments
  • reference - The item being completed (prompt, tool, or resource)
  • argument - The argument being completed with current value
  • context - Optional additional context for completion
§Returns

List of completion suggestions

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§