Skip to main content

Crate mcp_proxy

Crate mcp_proxy 

Source
Expand description

MCP Proxy – config-driven reverse proxy with auth, rate limiting, and observability.

This crate can be used as a library to embed an MCP proxy in your application, or run standalone via the mcp-proxy CLI.

§Library Usage

Build a proxy from a ProxyConfig and embed it in an existing axum app:

use mcp_proxy::{Proxy, ProxyConfig};

let config = ProxyConfig::load("proxy.toml".as_ref())?;
let proxy = Proxy::from_config(config).await?;

// Embed in an existing axum app
let (router, session_handle) = proxy.into_router();

// Or serve standalone
// proxy.serve().await?;

§Hot Reload

Enable hot_reload = true in the config to watch the config file for new backends. The proxy will add them dynamically without restart.

Re-exports§

pub use config::ProxyConfig;

Modules§

admin
Admin API for proxy introspection.
admin_tools
MCP admin tools for proxy introspection.
alias
Tool aliasing middleware for the proxy.
cache
Response caching middleware for the proxy.
canary
Canary / weighted routing middleware.
coalesce
Request coalescing middleware for the proxy.
config
Proxy configuration types and TOML parsing.
filter
Capability filtering middleware for the proxy.
inject
Argument injection middleware for tool calls.
metrics
Prometheus metrics middleware for the proxy.
mirror
Traffic mirroring / shadowing middleware.
outlier
Passive health checks via outlier detection.
rbac
Role-based access control middleware for the proxy.
reload
Hot reload: watch the config file for changes and add new backends dynamically.
retry
Retry middleware for per-backend request retries with exponential backoff.
token
Token passthrough middleware for forwarding client credentials to backends.
validation
Request validation middleware for the proxy.

Structs§

Proxy
A fully constructed MCP proxy ready to serve or embed.