Skip to main content

atd_server_http/
lib.rs

1//! Streamable-HTTP transport for ATD — sibling of `atd-server`.
2//!
3//! This crate implements the SP-streamable-http design
4//! (`docs/superpowers/specs/2026-05-11-sp-streamable-http-design.md`):
5//! a one-endpoint MCP JSON-RPC 2.0 listener that delegates every
6//! `tools/call` to the **same** `atd-runtime::dispatch::run_tool` the
7//! Unix-socket transport uses. Browser PWAs, Cursor, Claude.ai, OpenAI
8//! Functions over HTTP — anything that speaks MCP Streamable HTTP — can
9//! reach an ATD-registered tool through this transport without any
10//! bespoke ATD wire knowledge.
11//!
12//! Composition (SP-streamable-http §4.5):
13//!
14//! ```rust,ignore
15//! let registry: atd_runtime::Registry = my_tools();
16//! let cfg = atd_server_http::HttpServerConfig::default();
17//! let (router, server) = atd_server_http::Server::builder(registry)
18//!     .config(cfg)
19//!     .build();
20//! // Adopters may extend the router with their own routes here.
21//! server.serve(router).await?;
22//! ```
23//!
24//! What is **not** in this crate (deferred to future SPs — SP §9):
25//! - SSE for `tools/call` (single response per request — adopter routes
26//!   layer SSE on top of the returned `Router`).
27//! - `Mcp-Session-Id` sessions / resumability / `Last-Event-ID`.
28//! - TLS termination (operators front with nginx / Caddy / Tauri).
29//! - OAuth 2.1 token issuance (bearer validated, not minted).
30
31pub mod bearer;
32pub mod config;
33pub mod error;
34pub mod mcp;
35pub mod origin;
36pub mod server;
37pub mod sse_refresh;
38
39pub use config::HttpServerConfig;
40pub use error::HttpServerError;
41pub use server::{Server, ServerBuilder};
42pub use sse_refresh::{
43    AuthLostReason, DEFAULT_REFRESH_CADENCE, RefreshEvent, spawn_bearer_refresh,
44};