Skip to main content

solo_api/
lib.rs

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