Skip to main content

protocol_droid/application/server/
mod.rs

1//! The server API: what a handler is given, and what it is allowed to ask for.
2//!
3//! # What lives here
4//!
5//! [`context::RequestContext`] is the argument every tool, resource and prompt
6//! handler receives. It carries the request's identity — id, cancellation
7//! token, progress token — and holds the [`context::PeerSession`] that
8//! negotiated it. [`context::CallbackExchange`] and the frame sink are declared
9//! here, in the module that consumes them, rather than collected into a shared
10//! ports module.
11//!
12//! [`builder::Server`] is the value a user of this crate builds: a registry, a
13//! set of tool handlers, and a name. It binds nothing and runs nothing — the
14//! transports in T13 and T14 give it somewhere to run, and until then a test
15//! can drive it in-process.
16//!
17//! [`error::GatedError`] is what a handler gets when it asks for something this
18//! session did not negotiate.
19//!
20//! [`dispatch::Dispatcher`] is the method table: it turns a peer's method name
21//! into a call on [`builder::Server`], and is what a transport holds once the
22//! frames are decoded. It is separate from the builder because describing a
23//! server and routing a request against it are different jobs, and only the
24//! second one is I/O-shaped.
25//!
26//! # The boundary this module sits on
27//!
28//! The session engine below in [`super::session`] is protocol-neutral: it holds
29//! an opaque profile handle and never names a version, so an A2A or ACP session
30//! can use it unchanged. This module is the MCP-facing facade over that core,
31//! and it is allowed to speak MCP because a user of a library does not want to
32//! be handed an opaque handle when asking "can I elicit here?" is the question
33//! they actually have. The core stays neutral; the facade does not have to.
34
35pub mod builder;
36pub mod context;
37pub mod dispatch;
38pub mod error;
39pub mod live;
40pub mod log_gate;
41pub mod read;
42pub mod result;
43#[cfg(feature = "stdio")]
44pub mod serve;
45mod watch;
46
47pub use builder::{BoxFuture, DispatchError, Server, ServerBuilder, ToolHandler};
48pub use context::{
49    CallbackExchange, DynExchange, ExchangeError, PeerSession, RequestContext, StateMap,
50};
51pub use dispatch::Dispatcher;
52pub use error::GatedError;
53pub use live::{ListKind, ListSubscription, ServerHandle};
54pub use log_gate::LogGate;
55pub use result::OutcomeError;