Struct McpServer
pub struct McpServer { /* private fields */ }Expand description
A live connection to one MCP server (any transport).
Implementations§
Source§impl McpServer
impl McpServer
Sourcepub async fn connect(config: McpServerConfig) -> Result<McpServer, Error>
pub async fn connect(config: McpServerConfig) -> Result<McpServer, Error>
Connect to the server, perform the initialize handshake, and fetch the tool list.
Sourcepub async fn tools(&self) -> Vec<McpToolDef>
pub async fn tools(&self) -> Vec<McpToolDef>
Tools advertised by this server.
Sourcepub async fn capabilities(&self) -> McpServerCapabilities
pub async fn capabilities(&self) -> McpServerCapabilities
Server-advertised capabilities captured at handshake.
Sourcepub fn health_check(&self) -> bool
pub fn health_check(&self) -> bool
Health-check the underlying transport without sending a real request.
Returns true when the transport is alive, false otherwise.
Uses try_lock instead of blocking_lock because this method may be
called from async contexts (e.g. health_check_all during heartbeat
retries inside an async test or the tokio-based heartbeat worker).
Sourcepub fn ptr_eq(&self, other: &McpServer) -> bool
pub fn ptr_eq(&self, other: &McpServer) -> bool
Identity comparison on the underlying transport handle. Two
McpServer values share the same connection iff ptr_eq
returns true — i.e. their inner Arc<Mutex<McpServerInner>>
points to the same allocation. Cheap Arc-level comparison, no
async, no lock.
Used by the daemon’s reconciliation layer to verify that a
“preserved” healthy server’s live connection survives a
recovery tick without being silently disconnected and
respawned (the additive merge contract: a healthy handle
covers its name and is reused verbatim via Arc::clone).
Sourcepub async fn call_tool(
&self,
tool_name: &str,
arguments: Value,
) -> Result<Value, Error>
pub async fn call_tool( &self, tool_name: &str, arguments: Value, ) -> Result<Value, Error>
Call a tool on this server. Returns the raw JSON result.
Sourcepub async fn list_resources(
&self,
cursor: Option<String>,
) -> Result<McpResourcesListResult, Error>
pub async fn list_resources( &self, cursor: Option<String>, ) -> Result<McpResourcesListResult, Error>
resources/list — capability-gated.
Sourcepub async fn read_resource(
&self,
uri: &str,
) -> Result<McpResourceContents, Error>
pub async fn read_resource( &self, uri: &str, ) -> Result<McpResourceContents, Error>
resources/read — capability-gated.
Sourcepub async fn list_prompts(
&self,
cursor: Option<String>,
) -> Result<McpPromptsListResult, Error>
pub async fn list_prompts( &self, cursor: Option<String>, ) -> Result<McpPromptsListResult, Error>
prompts/list — capability-gated.
Sourcepub async fn get_prompt(
&self,
name: &str,
arguments: Value,
) -> Result<McpGetPromptResult, Error>
pub async fn get_prompt( &self, name: &str, arguments: Value, ) -> Result<McpGetPromptResult, Error>
prompts/get — capability-gated.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for McpServer
impl !RefUnwindSafe for McpServer
impl Send for McpServer
impl Sync for McpServer
impl Unpin for McpServer
impl UnsafeUnpin for McpServer
impl !UnwindSafe 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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