pub struct McpServerConfig { /* private fields */ }Expand description
Validated independent MCP server configuration.
Available with the mcp-server feature. Constructing this value does not bind a socket.
§Examples
use tools_kit::mcp::McpServerConfig;
let config = McpServerConfig::new("127.0.0.1:8000".parse().unwrap(), "/mcp", "page")?;
assert!(serde_json::to_value(&config).unwrap().is_object());
Implementations§
Source§impl McpServerConfig
impl McpServerConfig
Sourcepub fn new(
bind: SocketAddr,
endpoint_path: impl Into<String>,
cursor_prefix: impl Into<String>,
) -> Result<Self, ToolError>
pub fn new( bind: SocketAddr, endpoint_path: impl Into<String>, cursor_prefix: impl Into<String>, ) -> Result<Self, ToolError>
Creates a validated loopback server configuration.
§Errors
Returns ToolError::InvalidConfiguration unless the address is loopback with a nonzero port, the endpoint starts with / and contains no query or fragment, and the cursor prefix is nonblank.
§Examples
use tools_kit::mcp::McpServerConfig;
let config = McpServerConfig::new("127.0.0.1:8000".parse().unwrap(), "/mcp", "page")?;
let value = serde_json::to_value(&config).unwrap();
assert_eq!(value["shutdown_timeout_secs"], 5);
assert_eq!(value["interaction_policy"], "reject_with_tool_error");
Sourcepub fn with_interaction_policy(self, policy: McpServerInteractionPolicy) -> Self
pub fn with_interaction_policy(self, policy: McpServerInteractionPolicy) -> Self
Selects how the server handles tool-requested caller interactions.
§Examples
use tools_kit::mcp::McpServerConfig;
let config = McpServerConfig::new("127.0.0.1:8000".parse().unwrap(), "/mcp", "page")?;
let config = config.with_interaction_policy(tools_kit::mcp::McpServerInteractionPolicy::ElicitFormIfClientSupports);
let value = serde_json::to_value(&config).unwrap();
assert_eq!(value["shutdown_timeout_secs"], 5);
assert_eq!(value["interaction_policy"], "elicit_form_if_client_supports");
Sourcepub fn with_shutdown_timeout(self, timeout: Duration) -> Result<Self, ToolError>
pub fn with_shutdown_timeout(self, timeout: Duration) -> Result<Self, ToolError>
Sets the nonzero deadline for joining server shutdown.
§Errors
Returns ToolError::InvalidConfiguration for zero. Positive subsecond values become one second; other values use whole seconds. This bounds observation and never discards retained cleanup.
§Examples
use tools_kit::mcp::McpServerConfig;
let config = McpServerConfig::new("127.0.0.1:8000".parse().unwrap(), "/mcp", "page")?;
assert!(config.clone().with_shutdown_timeout(std::time::Duration::ZERO).is_err());
let config = config.with_shutdown_timeout(std::time::Duration::from_secs(10))?;
let value = serde_json::to_value(&config).unwrap();
assert_eq!(value["shutdown_timeout_secs"], 10);
assert_eq!(value["interaction_policy"], "reject_with_tool_error");
Trait Implementations§
Source§impl Clone for McpServerConfig
impl Clone for McpServerConfig
Source§impl Debug for McpServerConfig
impl Debug for McpServerConfig
Source§impl<'de> Deserialize<'de> for McpServerConfig
impl<'de> Deserialize<'de> for McpServerConfig
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>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for McpServerConfig
Source§impl PartialEq for McpServerConfig
impl PartialEq for McpServerConfig
Source§impl Serialize for McpServerConfig
impl Serialize for McpServerConfig
impl StructuralPartialEq for McpServerConfig
Auto Trait Implementations§
impl Freeze for McpServerConfig
impl RefUnwindSafe for McpServerConfig
impl Send for McpServerConfig
impl Sync for McpServerConfig
impl Unpin for McpServerConfig
impl UnsafeUnpin for McpServerConfig
impl UnwindSafe for McpServerConfig
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
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
Compare self to
key and return true if they are equal.