pub struct McpHttpClientBuilder { /* private fields */ }Available on crate feature
tools only.Expand description
Builder for HTTP-based MCP connections.
This builder creates connections to remote MCP servers using the streamable HTTP transport (SEP-1686 compliant).
§Example
ⓘ
use adk_tool::mcp::{McpHttpClientBuilder, McpAuth, OAuth2Config};
// Simple connection
let toolset = McpHttpClientBuilder::new("https://mcp.example.com/v1")
.connect()
.await?;
// With OAuth2 authentication
let toolset = McpHttpClientBuilder::new("https://mcp.example.com/v1")
.with_auth(McpAuth::oauth2(
OAuth2Config::new("client-id", "https://auth.example.com/token")
.with_secret("client-secret")
.with_scopes(vec!["mcp:read".into()])
))
.timeout(Duration::from_secs(60))
.connect()
.await?;Implementations§
Source§impl McpHttpClientBuilder
impl McpHttpClientBuilder
Sourcepub fn new(endpoint: impl Into<String>) -> McpHttpClientBuilder
pub fn new(endpoint: impl Into<String>) -> McpHttpClientBuilder
Create a new HTTP client builder for the given endpoint.
§Arguments
endpoint- The MCP server URL (e.g.,https://mcp.example.com/v1)
Sourcepub fn with_auth(self, auth: McpAuth) -> McpHttpClientBuilder
pub fn with_auth(self, auth: McpAuth) -> McpHttpClientBuilder
Sourcepub fn timeout(self, timeout: Duration) -> McpHttpClientBuilder
pub fn timeout(self, timeout: Duration) -> McpHttpClientBuilder
Set the request timeout.
Default is 30 seconds.
Sourcepub fn header(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> McpHttpClientBuilder
pub fn header( self, key: impl Into<String>, value: impl Into<String>, ) -> McpHttpClientBuilder
Add a custom header to all requests.
Sourcepub fn with_elicitation_handler(
self,
handler: Arc<dyn ElicitationHandler>,
) -> McpHttpClientBuilder
pub fn with_elicitation_handler( self, handler: Arc<dyn ElicitationHandler>, ) -> McpHttpClientBuilder
Configure an elicitation handler for the HTTP connection.
When set, use connect_with_elicitation
to create a toolset that advertises elicitation capabilities.
Sourcepub fn get_timeout(&self) -> Duration
pub fn get_timeout(&self) -> Duration
Get the configured timeout.
Sourcepub async fn connect(self) -> Result<(), AdkError>
Available on non-crate feature http-transport only.
pub async fn connect(self) -> Result<(), AdkError>
http-transport only.Connect to the MCP server (stub when http-transport feature is disabled).
Sourcepub async fn connect_with_elicitation(self) -> Result<(), AdkError>
Available on non-crate feature http-transport only.
pub async fn connect_with_elicitation(self) -> Result<(), AdkError>
http-transport only.Connect with elicitation support (stub when http-transport feature is disabled).
Trait Implementations§
Source§impl Clone for McpHttpClientBuilder
impl Clone for McpHttpClientBuilder
Source§fn clone(&self) -> McpHttpClientBuilder
fn clone(&self) -> McpHttpClientBuilder
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for McpHttpClientBuilder
impl !RefUnwindSafe for McpHttpClientBuilder
impl Send for McpHttpClientBuilder
impl Sync for McpHttpClientBuilder
impl Unpin for McpHttpClientBuilder
impl UnsafeUnpin for McpHttpClientBuilder
impl !UnwindSafe for McpHttpClientBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::RequestCreates a shared type from an unshared type.