pub struct McpClientConfig {
pub url: String,
pub headers: HashMap<String, String>,
pub connect_timeout: Option<Duration>,
pub read_timeout: Option<Duration>,
}Expand description
Configuration for MCP client connections
This struct provides a protocol-agnostic way to configure connections to MCP servers. It can be used with both SSE and Streamable HTTP transports.
§Example
use mcp_common::McpClientConfig;
use std::time::Duration;
let config = McpClientConfig::new("http://localhost:8080/mcp")
.with_header("Authorization", "Bearer token123")
.with_connect_timeout(Duration::from_secs(30));Fields§
§url: StringTarget URL for the MCP server
headers: HashMap<String, String>HTTP headers to include in requests
connect_timeout: Option<Duration>Connection timeout duration
read_timeout: Option<Duration>Read timeout duration
Implementations§
Source§impl McpClientConfig
impl McpClientConfig
Sourcepub fn new(url: impl Into<String>) -> McpClientConfig
pub fn new(url: impl Into<String>) -> McpClientConfig
Create a new configuration with the given URL
§Arguments
url- The MCP server URL (e.g., “http://localhost:8080/mcp”)
Sourcepub fn with_header(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> McpClientConfig
pub fn with_header( self, key: impl Into<String>, value: impl Into<String>, ) -> McpClientConfig
Sourcepub fn with_headers(self, headers: HashMap<String, String>) -> McpClientConfig
pub fn with_headers(self, headers: HashMap<String, String>) -> McpClientConfig
Add multiple headers from a HashMap
Sourcepub fn with_bearer_auth(self, token: impl Into<String>) -> McpClientConfig
pub fn with_bearer_auth(self, token: impl Into<String>) -> McpClientConfig
Set the Authorization header with a Bearer token
§Arguments
token- The bearer token (without “Bearer “ prefix)
Sourcepub fn with_connect_timeout(self, timeout: Duration) -> McpClientConfig
pub fn with_connect_timeout(self, timeout: Duration) -> McpClientConfig
Sourcepub fn with_read_timeout(self, timeout: Duration) -> McpClientConfig
pub fn with_read_timeout(self, timeout: Duration) -> McpClientConfig
Trait Implementations§
Source§impl Clone for McpClientConfig
impl Clone for McpClientConfig
Source§fn clone(&self) -> McpClientConfig
fn clone(&self) -> McpClientConfig
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 moreSource§impl Debug for McpClientConfig
impl Debug for McpClientConfig
Source§impl Default for McpClientConfig
impl Default for McpClientConfig
Source§fn default() -> McpClientConfig
fn default() -> McpClientConfig
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for McpClientConfig
impl RefUnwindSafe for McpClientConfig
impl Send for McpClientConfig
impl Sync for McpClientConfig
impl Unpin for McpClientConfig
impl UnwindSafe for McpClientConfig
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