pub struct ProxyConfig {
pub proxy: ProxySettings,
pub backends: Vec<BackendConfig>,
pub auth: Option<AuthConfig>,
pub performance: PerformanceConfig,
pub security: SecurityConfig,
pub observability: ObservabilityConfig,
}Expand description
Top-level proxy configuration, typically loaded from a TOML file.
Fields§
§proxy: ProxySettingsCore proxy settings (name, version, listen address).
backends: Vec<BackendConfig>Backend MCP servers to proxy.
auth: Option<AuthConfig>Inbound authentication configuration.
performance: PerformanceConfigPerformance tuning options.
security: SecurityConfigSecurity policies.
observability: ObservabilityConfigLogging, metrics, and tracing configuration.
Implementations§
Source§impl ProxyConfig
impl ProxyConfig
Sourcepub fn load(path: &Path) -> Result<Self>
pub fn load(path: &Path) -> Result<Self>
Load and validate a config from a file path.
Examples found in repository?
examples/library-mode.rs (line 37)
29async fn main() -> Result<()> {
30 tracing_subscriber::fmt()
31 .with_env_filter("tower_mcp=info,mcp_proxy=info")
32 .init();
33
34 let cli = Cli::parse();
35
36 // Load and resolve config
37 let mut config = mcp_proxy::ProxyConfig::load(&cli.config)?;
38 config.resolve_env_vars();
39
40 let addr = format!("{}:{}", config.proxy.listen.host, config.proxy.listen.port);
41
42 // Build the proxy
43 let proxy = mcp_proxy::Proxy::from_config(config).await?;
44
45 // Extract the router (includes MCP transport + admin API)
46 let (proxy_router, _session_handle) = proxy.into_router();
47
48 // Build custom application routes
49 let app_routes = Router::new().route("/app/status", get(app_status));
50
51 // Merge proxy router with custom routes
52 let app = proxy_router.merge(app_routes);
53
54 tracing::info!(listen = %addr, "Library mode example ready");
55
56 let listener = tokio::net::TcpListener::bind(&addr).await?;
57 axum::serve(listener, app).await?;
58
59 Ok(())
60}Sourcepub fn parse(toml: &str) -> Result<Self>
pub fn parse(toml: &str) -> Result<Self>
Parse and validate a config from a TOML string.
§Examples
use mcp_proxy::ProxyConfig;
let config = ProxyConfig::parse(r#"
[proxy]
name = "my-proxy"
[proxy.listen]
[[backends]]
name = "echo"
transport = "stdio"
command = "echo"
"#).unwrap();
assert_eq!(config.proxy.name, "my-proxy");
assert_eq!(config.backends.len(), 1);Sourcepub fn resolve_env_vars(&mut self)
pub fn resolve_env_vars(&mut self)
Resolve environment variable references in config values.
Replaces ${VAR_NAME} with the value of the environment variable.
Examples found in repository?
examples/library-mode.rs (line 38)
29async fn main() -> Result<()> {
30 tracing_subscriber::fmt()
31 .with_env_filter("tower_mcp=info,mcp_proxy=info")
32 .init();
33
34 let cli = Cli::parse();
35
36 // Load and resolve config
37 let mut config = mcp_proxy::ProxyConfig::load(&cli.config)?;
38 config.resolve_env_vars();
39
40 let addr = format!("{}:{}", config.proxy.listen.host, config.proxy.listen.port);
41
42 // Build the proxy
43 let proxy = mcp_proxy::Proxy::from_config(config).await?;
44
45 // Extract the router (includes MCP transport + admin API)
46 let (proxy_router, _session_handle) = proxy.into_router();
47
48 // Build custom application routes
49 let app_routes = Router::new().route("/app/status", get(app_status));
50
51 // Merge proxy router with custom routes
52 let app = proxy_router.merge(app_routes);
53
54 tracing::info!(listen = %addr, "Library mode example ready");
55
56 let listener = tokio::net::TcpListener::bind(&addr).await?;
57 axum::serve(listener, app).await?;
58
59 Ok(())
60}Trait Implementations§
Source§impl Debug for ProxyConfig
impl Debug for ProxyConfig
Source§impl<'de> Deserialize<'de> for ProxyConfig
impl<'de> Deserialize<'de> for ProxyConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for ProxyConfig
impl RefUnwindSafe for ProxyConfig
impl Send for ProxyConfig
impl Sync for ProxyConfig
impl Unpin for ProxyConfig
impl UnsafeUnpin for ProxyConfig
impl UnwindSafe for ProxyConfig
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