pub struct McpServer { /* private fields */ }Expand description
A running MCP server connection.
A background reader task owns stdout and demultiplexes responses by id
into per-request oneshot channels. send_request writes to stdin and then
awaits its channel — never read_line directly. So a request timeout (or any
cancellation of the caller’s future) only drops a receiver; the reader keeps
consuming the stream and discards the now-orphaned response. This makes the
transport cancel-safe by construction: there is no read to interrupt
mid-line, hence no desync and no poison/recovery dance.
Implementations§
Source§impl McpServer
impl McpServer
Sourcepub async fn start(config: McpServerConfig) -> Result<Self, String>
pub async fn start(config: McpServerConfig) -> Result<Self, String>
Start an MCP server and initialize the connection.
Sourcepub async fn list_tools(&mut self) -> Result<Vec<McpToolInfo>, String>
pub async fn list_tools(&mut self) -> Result<Vec<McpToolInfo>, String>
Discover tools from this MCP server.
Sourcepub async fn call_tool(
&mut self,
name: &str,
arguments: Value,
) -> Result<Value, String>
pub async fn call_tool( &mut self, name: &str, arguments: Value, ) -> Result<Value, String>
Call a tool on this MCP server.
Sourcepub async fn call_tool_with_timeout(
&mut self,
name: &str,
arguments: Value,
timeout: Option<Duration>,
) -> Result<Value, String>
pub async fn call_tool_with_timeout( &mut self, name: &str, arguments: Value, timeout: Option<Duration>, ) -> Result<Value, String>
Call a tool, bounding the response await by timeout (else the backstop).
Callers that know a tool can run long (e.g. the substrate’s run_command
carrying its own timeout) pass it here so CAR doesn’t abandon a call
that is still executing server-side.
Trait Implementations§
Source§impl McpSession for McpServer
impl McpSession for McpServer
Source§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 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,
Source§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 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,
Source§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,
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,
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.Auto Trait Implementations§
impl !RefUnwindSafe for McpServer
impl !UnwindSafe for McpServer
impl Freeze for McpServer
impl Send for McpServer
impl Sync for McpServer
impl Unpin for McpServer
impl UnsafeUnpin for McpServer
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
impl<T> ErasedDestructor for Twhere
T: 'static,
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> ⓘ
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> ⓘ
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 more