solo_api/lib.rs
1// SPDX-License-Identifier: Apache-2.0
2
3//! Solo transports: MCP server (rmcp) and HTTP/JSON (axum).
4//!
5//! - MCP stdio: [`mcp::SoloMcpServer`] + [`mcp::serve_stdio`].
6//! - HTTP/JSON: [`http::SoloHttpState`] + [`http::serve_http`].
7//! - Auth (v0.8.0 P3): [`auth::AuthConfig`] + [`auth::AuthenticatedPrincipal`].
8//! - LLM (v0.9.0 P2): [`llm::SamplingLlmClient`] backed by the connected
9//! MCP client's `sampling/createMessage` capability.
10
11pub mod auth;
12pub mod http;
13pub mod llm;
14pub mod mcp;
15// v0.10.2 P1: transport-agnostic JSON-RPC dispatcher shared by the new
16// HTTP `/mcp` route and (eventually) the stdio loop. See
17// `docs/dev-log/0129-v0.10.2-mcp-over-http-impl.md` for the refactor.
18pub mod mcp_dispatch;
19// v0.11.0 P1: `Mcp-Session-Id` session store + Axum middleware.
20// In-memory DashMap-backed, TTL-bounded (30 min inactivity / 4 hr
21// absolute). The middleware validates the header on every `/mcp`
22// request; the POST handler creates a new session on the first
23// request without the header and echoes the id back. See
24// `docs/dev-log/0133-v0.11.0-p1-impl.md`.
25pub mod mcp_session;
26// v0.11.0 P3: per-tool progress events. Wraps the session's broadcast
27// channel in a [`mcp_progress::ProgressReporter`] handle long-running
28// tool handlers call from sensible checkpoints (parse / embed / insert
29// for `memory_ingest_document`, etc). Spec-shape `notifications/progress`
30// envelope correlated by the client's `_meta.progressToken`. See
31// `docs/dev-log/0135-v0.11.0-p3-impl.md`.
32pub mod mcp_progress;
33// v0.11.0 P4: bridges per-tenant `InvalidateEvent` broadcasts into
34// MCP `notifications/message` events on each session's SSE stream.
35// Subscribes to the existing `TenantHandle::invalidate_sender()` (the
36// same channel powering `/v1/graph/stream`) and maps `InvalidateEvent`
37// kinds into spec-compliant MCP message envelopes. See
38// `docs/dev-log/0136-v0.11.0-p4-impl.md`.
39pub mod mcp_notify;
40
41#[cfg(any(test, feature = "test-support"))]
42pub mod test_support;
43
44pub use auth::{AuthConfig, AuthError, AuthenticatedPrincipal};
45pub use http::{SoloHttpState, openapi_spec, serve_http};
46pub use llm::{SamplingClient, SamplingError, SamplingLlmClient, build_sampling_steward};
47pub use mcp::{
48 ENV_MCP_PRINCIPAL_TOKEN, SoloMcpServer, resolve_mcp_principal, serve_stdio, tool_names,
49};
50pub use mcp_dispatch::{
51 JsonRpcErrorBody, JsonRpcErrorResponse, JsonRpcRequest, JsonRpcResponse, JsonRpcSuccess,
52 McpDispatcher,
53};
54pub use mcp_session::{
55 MCP_LAST_EVENT_ID_HEADER, MCP_SESSION_ABSOLUTE_TTL_MS, MCP_SESSION_EVENT_BUFFER_CAPACITY,
56 MCP_SESSION_EXPIRED_ERROR, MCP_SESSION_ID_HEADER, MCP_SESSION_INACTIVITY_TTL_MS,
57 MCP_SESSION_SWEEP_INTERVAL_SECS, MCP_STREAM_EVENT_HEARTBEAT_NAME,
58 MCP_STREAM_EVENT_INIT_NAME, MCP_STREAM_EVENT_LAGGED_NAME, MCP_STREAM_EVENT_MESSAGE_NAME,
59 MCP_STREAM_EVENT_PROGRESS_NAME, McpEventKind, McpStreamEvent, SessionId, SessionState,
60 SessionStore, mcp_session_middleware, set_session_id_header,
61};
62pub use mcp_progress::{
63 MCP_NOTIFICATION_PROGRESS_METHOD, MCP_REMEMBER_BATCH_PROGRESS_EMIT_EVERY,
64 MCP_REMEMBER_BATCH_PROGRESS_ITEM_THRESHOLD, MCP_SEARCH_DOCS_PROGRESS_TOP_K_THRESHOLD,
65 ProgressReporter, ProgressToken, report_if_some,
66};
67pub use mcp_notify::{
68 MCP_NOTIFICATION_DATA_CONSOLIDATION_UPDATED, MCP_NOTIFICATION_DATA_DOCUMENTS_UPDATED,
69 MCP_NOTIFICATION_DATA_GRAPH_UPDATED, MCP_NOTIFICATION_DATA_MEMORIES_UPDATED,
70 MCP_NOTIFICATION_DATA_MEMORY_UPDATED, MCP_NOTIFICATION_DATA_TENANT_UPDATED,
71 MCP_NOTIFICATION_MESSAGE_LEVEL, MCP_NOTIFICATION_MESSAGE_LOGGER,
72 MCP_NOTIFICATION_MESSAGE_METHOD, map_invalidate_to_message, spawn_invalidate_bridge,
73};