pub struct McpBackendClient { /* private fields */ }Expand description
Client for MCP backends, holding the bounded backend-session table.
Implementations§
Source§impl McpBackendClient
impl McpBackendClient
Sourcepub fn cached_sessions(&self) -> usize
pub fn cached_sessions(&self) -> usize
Number of cached backend sessions (for tests and metrics).
Sourcepub fn forget_agent_session(&self, agent_session: &str)
pub fn forget_agent_session(&self, agent_session: &str)
Forget every backend session opened for agent_session.
Sourcepub async fn initialize(
&self,
endpoint: &BackendEndpoint,
) -> Result<BackendSession, McpError>
pub async fn initialize( &self, endpoint: &BackendEndpoint, ) -> Result<BackendSession, McpError>
Run the initialize handshake against endpoint.
Sourcepub async fn session(
&self,
agent_session: &str,
backend: &str,
endpoint: &BackendEndpoint,
) -> Result<BackendSession, McpError>
pub async fn session( &self, agent_session: &str, backend: &str, endpoint: &BackendEndpoint, ) -> Result<BackendSession, McpError>
The cached session for (agent_session, backend), opening one on
first use. Concurrent callers share a single handshake.
Sourcepub async fn request(
&self,
agent_session: &str,
backend: &str,
endpoint: &BackendEndpoint,
body: &[u8],
request_id: &Value,
) -> Result<(u16, Vec<u8>, Option<String>), McpError>
pub async fn request( &self, agent_session: &str, backend: &str, endpoint: &BackendEndpoint, body: &[u8], request_id: &Value, ) -> Result<(u16, Vec<u8>, Option<String>), McpError>
Send one JSON-RPC request and return the matching JSON-RPC response
bytes. body is forwarded verbatim; request_id is its id.
Returns (http_status, response_bytes). A non-success HTTP status
other than a session-expiry 404 is returned as-is with the body
the backend sent, so the caller can record it.
Sourcepub async fn list_tools(
&self,
agent_session: &str,
backend: &str,
endpoint: &BackendEndpoint,
) -> Result<Vec<Value>, McpError>
pub async fn list_tools( &self, agent_session: &str, backend: &str, endpoint: &BackendEndpoint, ) -> Result<Vec<Value>, McpError>
Collect every tool a backend advertises through tools/list,
following nextCursor pagination within fixed bounds.
Auto Trait Implementations§
impl !Freeze for McpBackendClient
impl !RefUnwindSafe for McpBackendClient
impl Send for McpBackendClient
impl Sync for McpBackendClient
impl Unpin for McpBackendClient
impl UnsafeUnpin for McpBackendClient
impl !UnwindSafe for McpBackendClient
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<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§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