objectiveai_mcp_proxy/lib.rs
1//! ObjectiveAI MCP proxy library.
2//!
3//! Other crates can `use objectiveai_mcp_proxy::{ConfigBuilder, run}` and
4//! spawn the proxy in-process; the binary at `main.rs` is a thin wrapper
5//! that reads `Config` from the environment and calls [`run`].
6
7mod logging;
8mod mcp;
9mod queue_delegate;
10mod reverse_channel;
11mod run;
12mod session;
13mod session_manager;
14mod upstream;
15
16use std::sync::Arc;
17
18use objectiveai_sdk::mcp::Client;
19
20use crate::session_manager::SessionManager;
21
22/// Shared state every axum handler reaches via `State<AppState>`.
23#[derive(Clone)]
24pub struct AppState {
25 pub sessions: Arc<SessionManager>,
26 pub client: Arc<Client>,
27 /// Optional in-process queue-read delegate. `Some` when an
28 /// embedder (the API) plugged one in at [`setup`] time;
29 /// `None` for the CLI's standalone proxy — tool calls then
30 /// never invoke the delegate seam.
31 pub queue_delegate: Option<Arc<dyn QueueDelegate>>,
32 /// Optional reverse channel for `ws://` upstreams. `Some` when an
33 /// embedder (the API) hands the proxy its request's reverse-attach
34 /// WS at [`setup`] time; `None` for the standalone proxy, which then
35 /// serves HTTP upstreams only (a `ws://` upstream errors at connect).
36 pub reverse_channel: Option<ReverseChannel>,
37}
38
39pub use queue_delegate::{QueueDelegate, QueueRead};
40pub use reverse_channel::ReverseChannel;
41pub use run::*;
42pub use session_manager::parse_key_env;