Skip to main content

McpAuthProvider

Trait McpAuthProvider 

Source
pub trait McpAuthProvider:
    Send
    + Sync
    + 'static {
    // Required method
    fn token<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Option<String>, BoxError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Supplies the bearer token for each request of a URL-configured client (authProvider).

use strands::mcp::McpAuthProvider;

struct StaticToken(String);

#[strands::async_trait]
impl McpAuthProvider for StaticToken {
    async fn token(&self) -> Result<Option<String>, strands::BoxError> {
        Ok(Some(self.0.clone()))
    }
}

Required Methods§

Source

fn token<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Option<String>, BoxError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

The token to send as Authorization: Bearer <token>, or None to send none.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§