Skip to main content

mcp_proxy/
lib.rs

1//! MCP Proxy -- config-driven reverse proxy with auth, rate limiting, and observability.
2//!
3//! This crate can be used as a library to embed an MCP proxy in your application,
4//! or run standalone via the `mcp-proxy` CLI.
5//!
6//! # Library Usage
7//!
8//! Build a proxy from a [`ProxyConfig`] and embed it in an existing axum app:
9//!
10//! ```rust,no_run
11//! use mcp_proxy::{Proxy, ProxyConfig};
12//!
13//! # async fn example() -> anyhow::Result<()> {
14//! let config = ProxyConfig::load("proxy.toml".as_ref())?;
15//! let proxy = Proxy::from_config(config).await?;
16//!
17//! // Embed in an existing axum app
18//! let (router, session_handle) = proxy.into_router();
19//!
20//! // Or serve standalone
21//! // proxy.serve().await?;
22//! # Ok(())
23//! # }
24//! ```
25//!
26//! # Hot Reload
27//!
28//! Enable `hot_reload = true` in the config to watch the config file for new
29//! backends. The proxy will add them dynamically without restart.
30
31pub mod admin;
32pub mod admin_tools;
33pub mod alias;
34pub mod cache;
35pub mod canary;
36pub mod coalesce;
37pub mod config;
38pub mod filter;
39pub mod inject;
40pub mod metrics;
41pub mod mirror;
42pub mod outlier;
43pub mod rbac;
44pub mod reload;
45pub mod retry;
46pub mod token;
47pub mod validation;
48
49#[cfg(test)]
50mod test_util;
51
52mod proxy;
53
54pub use config::ProxyConfig;
55pub use proxy::Proxy;