mcpr_integrations/lib.rs
1//! # mcpr-integrations
2//!
3//! External integrations and local persistence for the mcpr proxy.
4//!
5//! This crate connects mcpr to external services (cloud dashboard) and
6//! provides local request storage (SQLite) for CLI observability commands.
7//!
8//! ## Modules
9//!
10//! - [`cloud_client`]: HTTP client for the mcpr Cloud API. Handles
11//! authentication, project/server/endpoint CRUD, and token management.
12//! Used by the CLI setup wizard (`mcpr proxy setup`).
13//!
14//! - [`emitter`]: Cloud event sink that implements `EventSink` from mcpr-core.
15//! - `CloudSink` — batches proxy events and POSTs them to cloud.mcpr.app
16//! with retry and exponential backoff.
17//! - `CloudSinkConfig` — endpoint URL, token, server slug, batch/flush tuning.
18//!
19//! - [`store`]: SQLite-based request storage engine and query layer powering
20//! all CLI observability commands.
21//! - `Store` — background writer with async mpsc channel
22//! - `QueryEngine` — read-only queries (logs, slow, stats, sessions, clients,
23//! schema, session detail)
24//! - `FileStoreConfig` — `[store]` TOML config with `ModuleConfig` validation
25//!
26//! ## Module Structure
27//!
28//! ```text
29//! mcpr-integrations/src/
30//! +-- lib.rs # Crate root, re-exports
31//! +-- cloud_client.rs # Cloud API client (auth, CRUD, tokens)
32//! +-- emitter/
33//! | +-- mod.rs # Module root, re-exports
34//! | +-- cloud_sink.rs # CloudSink (batched HTTP POST with retry)
35//! +-- store/
36//! +-- mod.rs # Module root, re-exports
37//! +-- config.rs # FileStoreConfig, ModuleConfig impl
38//! +-- db.rs # SQLite connection, WAL setup, migrations
39//! +-- duration.rs # Human-friendly duration parsing (1h, 7d)
40//! +-- engine.rs # Store struct (open, record, shutdown)
41//! +-- event.rs # StoreEvent, RequestEvent, SessionEvent
42//! +-- path.rs # DB path resolution (config > env > platform)
43//! +-- schema.rs # SQL DDL, indexes, prepared statements
44//! +-- writer.rs # Background writer thread, batch flush
45//! +-- query/ # Read-only query engine
46//! +-- mod.rs # QueryEngine struct
47//! +-- logs.rs # Request log queries
48//! +-- slow.rs # Slow call queries
49//! +-- stats.rs # Per-tool aggregation with p95
50//! +-- sessions.rs # Session list with active filter
51//! +-- session_detail.rs # Single-session drill-down
52//! +-- clients.rs # Client aggregation
53//! +-- schema.rs # MCP schema queries
54//! +-- store_ops.rs# Store stats and vacuum
55//! ```
56
57pub mod cloud_client;
58pub mod emitter;
59pub mod store;
60
61pub use emitter::{CloudSink, CloudSinkConfig, SyncCallback, SyncStatus};