Expand description
§mcpr-proxy
Full MCP proxy engine: per-request pipeline (parse → route → middleware
→ forward → emit), upstream forwarding, SSE streaming, widget CSP
rewriting, widget bundle serving, per-proxy health. Embed this crate and
wire a frontend (axum, warp, anything) around [pipeline::run].
§Module layout
proxy/
├── pipeline/ Per-request pipeline (parse → route → mw → emit)
├── proxy_state.rs ProxyState — the runtime one proxy instance holds
├── widgets.rs Widget HTML bundle serving + discovery
├── 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, SharedProxyHealthRe-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::lock_health;pub use proxy_state::ProxyState;pub use rewrite::RewriteConfig;pub use rewrite::rewrite_response;pub use widgets::WidgetSource;
Modules§
- csp
- CSP — Declarative Content Security Policy for widgets
- forwarding
- health
- Per-proxy connection health and display state.
- pipeline
- Per-request proxy pipeline: parse → route → request middleware → handler
→ response middleware → emit. [
run] is the single entrypoint every HTTP request goes through. - 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 takeArc<ProxyState>.- rewrite
- Response rewriting for widget CSP
- sse
- widgets
- Widget HTML bundle serving + asset discovery.