pub trait McpSession: Send {
// Required methods
fn list_tools<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<Vec<McpToolInfo>, String>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn call_tool<'life0, 'life1, 'async_trait>(
&'life0 mut self,
name: &'life1 str,
arguments: Value,
) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn name(&self) -> &str;
// Provided method
fn call_tool_with_timeout<'life0, 'life1, 'async_trait>(
&'life0 mut self,
name: &'life1 str,
arguments: Value,
_timeout: Option<Duration>,
) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
}Expand description
Transport-agnostic MCP client session.
The stdio McpServer (subprocess transport) implements this
directly; the HTTP-streamable session in car-connectors (remote
connectors) implements it too. McpToolExecutor holds sessions
as dyn McpSession so it can route a tool call to either transport
without knowing which one backs a given server. This is the seam
that lets remote MCP connectors reuse the exact routing, fallback,
and registration machinery the stdio path already has.
Required Methods§
Sourcefn list_tools<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<Vec<McpToolInfo>, String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn list_tools<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<Vec<McpToolInfo>, String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Discover the tools this server exposes.
Provided Methods§
Sourcefn call_tool_with_timeout<'life0, 'life1, 'async_trait>(
&'life0 mut self,
name: &'life1 str,
arguments: Value,
_timeout: Option<Duration>,
) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn call_tool_with_timeout<'life0, 'life1, 'async_trait>(
&'life0 mut self,
name: &'life1 str,
arguments: Value,
_timeout: Option<Duration>,
) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Invoke a tool, bounding the response await by timeout (else the
session’s backstop). Default ignores timeout (back-compat for sessions
where calls are short); the stdio McpServer honors it so a
long-running run_command isn’t cut off mid-execution.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".