pub struct McpClientConfig { /* private fields */ }Expand description
Validated MCP client Toolset configuration.
Configuration construction does not connect or spawn a process; crate::Toolset::mcp
performs that work. Discovered names may be namespaced without exposing native routing.
§Examples
use tools_kit::mcp::{McpClientConfig, McpConnectionConfig};
let connection = McpConnectionConfig::StreamableHttp {
endpoint: "http://127.0.0.1:8000/mcp".parse().unwrap(),
headers: Default::default(),
};
let config = McpClientConfig::new(connection);
let value = serde_json::to_value(&config).unwrap();
assert_eq!(value["request_timeout_secs"], 30);
assert_eq!(value["form_interactions"], false);Implementations§
Source§impl McpClientConfig
impl McpClientConfig
Sourcepub fn new(connection: McpConnectionConfig) -> Self
pub fn new(connection: McpConnectionConfig) -> Self
Creates a client configuration with a 30-second request timeout.
See crate::mcp::McpClientConfig for a complete example.
Sourcepub fn with_namespace<N>(self, namespace: N) -> Result<Self, ToolError>
pub fn with_namespace<N>(self, namespace: N) -> Result<Self, ToolError>
Applies a caller-visible namespace to discovered names.
§Errors
Returns ToolError::InvalidConfiguration if the namespace is not a valid ToolName.
§Examples
use tools_kit::mcp::{McpClientConfig, McpConnectionConfig};
let connection = McpConnectionConfig::StreamableHttp {
endpoint: "http://127.0.0.1:8000/mcp".parse().unwrap(),
headers: Default::default(),
};
let config = McpClientConfig::new(connection);
let config = config.with_namespace("search")?;
assert_eq!(serde_json::to_value(config).unwrap()["namespace"], "search");
Sourcepub fn with_request_timeout(self, timeout: Duration) -> Result<Self, ToolError>
pub fn with_request_timeout(self, timeout: Duration) -> Result<Self, ToolError>
Sets the nonzero per-request timeout.
§Errors
Returns ToolError::InvalidConfiguration for zero. Positive subsecond values become one second; other values use whole seconds.
§Examples
use tools_kit::mcp::{McpClientConfig, McpConnectionConfig};
let connection = McpConnectionConfig::StreamableHttp {
endpoint: "http://127.0.0.1:8000/mcp".parse().unwrap(),
headers: Default::default(),
};
let config = McpClientConfig::new(connection);
assert!(config.clone().with_request_timeout(std::time::Duration::ZERO).is_err());
let config = config.with_request_timeout(std::time::Duration::from_secs(5))?;
assert_eq!(serde_json::to_value(config).unwrap()["request_timeout_secs"], 5);
Sourcepub fn with_form_validation(self, enabled: bool) -> Self
pub fn with_form_validation(self, enabled: bool) -> Self
Enables form interactions and selects response schema validation. Passing false still enables forms. Replies must remain JSON objects; only schema constraints are relaxed.
§Examples
use tools_kit::mcp::{McpClientConfig, McpConnectionConfig};
let connection = McpConnectionConfig::StreamableHttp {
endpoint: "http://127.0.0.1:8000/mcp".parse().unwrap(),
headers: Default::default(),
};
let config = McpClientConfig::new(connection);
let config = config.with_form_validation(false);
let value = serde_json::to_value(config).unwrap();
assert_eq!(value["form_interactions"], true);
assert_eq!(value["validate_forms"], false);Trait Implementations§
Source§impl Clone for McpClientConfig
impl Clone for McpClientConfig
Source§impl Debug for McpClientConfig
impl Debug for McpClientConfig
Source§impl<'de> Deserialize<'de> for McpClientConfig
impl<'de> Deserialize<'de> for McpClientConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for McpClientConfig
Source§impl PartialEq for McpClientConfig
impl PartialEq for McpClientConfig
Source§impl Serialize for McpClientConfig
impl Serialize for McpClientConfig
impl StructuralPartialEq for McpClientConfig
Auto Trait Implementations§
impl Freeze for McpClientConfig
impl RefUnwindSafe for McpClientConfig
impl Send for McpClientConfig
impl Sync for McpClientConfig
impl Unpin for McpClientConfig
impl UnsafeUnpin 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.