Skip to main content

Module proxy

Module proxy 

Source
Expand description

§mcpr-proxy

Full MCP proxy engine: per-request pipeline (intake → request chain → router → transport → response chain → emit), upstream forwarding, SSE streaming, widget CSP rewriting, per-proxy health. Embed this crate and wire a frontend (axum, warp, anything) around build_default_pipeline + pipeline::driver::Pipeline::run.

§Module layout

proxy/
├── pipeline/       Per-request pipeline (parse → route → mw → emit)
├── proxy_state.rs  ProxyState — the runtime one proxy instance holds
├── forwarding.rs   UpstreamClient, forward_request, read_body_capped
├── sse.rs          SSE extract/wrap helpers
├── csp.rs          CspConfig, DirectivePolicy, WidgetScoped
├── rewrite.rs      RewriteConfig, rewrite_response (widget CSP)
└── health.rs       ProxyHealth, ConnectionStatus, SharedProxyHealth

Re-exports§

pub use csp::CspConfig;
pub use csp::Directive;
pub use csp::DirectivePolicy;
pub use csp::Mode;
pub use csp::WidgetScoped;
pub use csp::effective_domains;
pub use csp::glob_match;
pub use health::ConnectionStatus;
pub use health::ProxyHealth;
pub use health::SharedProxyHealth;
pub use health::lock_health;
pub use health::new_shared_health;
pub use intake::from_axum_parts;
pub use pipeline_builder::ProxyPipeline;
pub use pipeline_builder::build_default_pipeline;
pub use proxy_state::ProxyState;
pub use rewrite::RewriteConfig;
pub use rewrite::rewrite_response;
pub use router::ProxyRouter;
pub use transport::ProxyTransport;

Modules§

csp
CSP — Declarative Content Security Policy for widgets
emit
RequestEvent construction and emission.
forwarding
health
Per-proxy connection health and display state.
intake
Content-based classification of axum request parts into the Request sum type.
pipeline
Per-request proxy pipeline: a trait-driven middleware chain built on a small custom driver (see PIPELINE.md). The entrypoint is driver::Pipeline::run, constructed once at startup via crate::proxy::build_default_pipeline.
pipeline_builder
Default middleware chain construction for the pipeline.
proxy_state
ProxyState — everything one running proxy instance needs to serve traffic: upstream client, rewrite config, sessions, schema manager, per-proxy health, event bus handle. Request handlers take Arc<ProxyState>.
rewrite
Response rewriting for widget CSP
router
Pure (Request, Config) -> Route mapping. No I/O.
sse
transport
The single I/O layer for the pipeline.