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;
40#[cfg(feature = "metrics")]
41pub mod metrics;
42pub mod mirror;
43pub mod outlier;
44#[cfg(feature = "oauth")]
45pub mod rbac;
46pub mod reload;
47pub mod retry;
48#[cfg(feature = "oauth")]
49pub mod token;
50pub mod validation;
51
52#[cfg(test)]
53mod test_util;
54
55mod proxy;
56
57pub use config::ProxyConfig;
58pub use proxy::Proxy;