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 dropper;
8mod logging;
9mod mcp;
10mod queue_delegate;
11mod reverse_channel;
12mod run;
13mod session;
14mod session_manager;
15mod upstream;
16
17use std::sync::Arc;
18
19use objectiveai_sdk::mcp::Client;
20
21use crate::session_manager::SessionManager;
22
23/// Shared state every axum handler reaches via `State<AppState>`.
24#[derive(Clone)]
25pub struct AppState {
26 pub sessions: Arc<SessionManager>,
27 pub client: Arc<Client>,
28 /// Optional in-process queue-read delegate. `Some` when an
29 /// embedder (the API) plugged one in at [`setup`] time;
30 /// `None` for the CLI's standalone proxy — tool calls then
31 /// never invoke the delegate seam.
32 pub queue_delegate: Option<Arc<dyn QueueDelegate>>,
33 /// Optional reverse channel for `ws://` upstreams. `Some` when an
34 /// embedder (the API) hands the proxy its request's reverse-attach
35 /// WS at [`setup`] time; `None` for the standalone proxy, which then
36 /// serves HTTP upstreams only (a `ws://` upstream errors at connect).
37 pub reverse_channel: Option<ReverseChannel>,
38 /// Optional dropper. `Some` when an embedder wires one in at
39 /// [`setup`] time; `handle_initialize` then checks its banned set so
40 /// a dropped response id is never (re)admitted. `None` → no banning.
41 pub dropper: Option<Dropper>,
42}
43
44pub use dropper::Dropper;
45pub use queue_delegate::{QueueDelegate, QueueRead};
46pub use reverse_channel::ReverseChannel;
47pub use run::*;
48pub use session_manager::parse_key_env;