pub struct Proxy { /* private fields */ }Expand description
A fully constructed MCP proxy ready to serve or embed.
Implementations§
Source§impl Proxy
impl Proxy
Sourcepub async fn from_config(config: ProxyConfig) -> Result<Self>
pub async fn from_config(config: ProxyConfig) -> Result<Self>
Build a proxy from a ProxyConfig.
Connects to all backends, builds the middleware stack, and prepares
the axum router. Call serve() to run standalone or
into_router() to embed in an existing app.
Sourcepub fn session_handle(&self) -> &SessionHandle
pub fn session_handle(&self) -> &SessionHandle
Get a reference to the session handle for monitoring active sessions.
Sourcepub fn mcp_proxy(&self) -> &McpProxy
pub fn mcp_proxy(&self) -> &McpProxy
Get a reference to the underlying McpProxy for dynamic operations.
Use this to add backends dynamically via McpProxy::add_backend().
Sourcepub fn enable_hot_reload(&self, config_path: PathBuf)
pub fn enable_hot_reload(&self, config_path: PathBuf)
Enable hot reload by watching the given config file path.
New backends added to the config file will be connected dynamically without restarting the proxy.
Sourcepub fn into_router(self) -> (Router, SessionHandle)
pub fn into_router(self) -> (Router, SessionHandle)
Consume the proxy and return the axum Router and SessionHandle.
Use this to embed the proxy in an existing axum application:
ⓘ
let (proxy_router, session_handle) = proxy.into_router();
let app = Router::new()
.nest("/mcp", proxy_router)
.route("/health", get(|| async { "ok" }));Auto Trait Implementations§
impl Freeze for Proxy
impl !RefUnwindSafe for Proxy
impl Send for Proxy
impl Sync for Proxy
impl Unpin for Proxy
impl UnsafeUnpin for Proxy
impl !UnwindSafe for Proxy
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
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>
Converts
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>
Converts
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