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//! ## Current Integrations
9//!
10//! - **Emitters** (`emitter` module): Structured event emission for MCP
11//! tool calls, sessions, heartbeats, and errors.
12//! - `CloudEmitter` — batched HTTPS POST to cloud.mcpr.app
13//! - `NoopEmitter` — disabled events
14//!
15//! - **Store** (`store` module): SQLite-based request storage engine and
16//! query layer powering all CLI observability commands.
17//! - `Store` — background writer with async mpsc channel
18//! - `QueryEngine` — read-only queries (logs, slow, stats, sessions, clients)
19//! - `FileStoreConfig` — `[store]` TOML config with `ModuleConfig` validation
20//!
21//! ## Module Structure
22//!
23//! ```text
24//! mcpr-integrations/src/
25//! +-- lib.rs # Crate root, re-exports
26//! +-- emitter/
27//! | +-- mod.rs # Module root, re-exports
28//! | +-- traits.rs # EventEmitter trait, NoopEmitter
29//! | +-- event.rs # McprEvent struct, EventType, EventStatus
30//! | +-- cloud.rs # CloudEmitter (batched HTTP POST)
31//! +-- store/
32//! +-- mod.rs # Module root, re-exports
33//! +-- config.rs # FileStoreConfig, ModuleConfig impl
34//! +-- db.rs # SQLite connection, WAL setup, migrations
35//! +-- duration.rs # Human-friendly duration parsing (1h, 7d)
36//! +-- engine.rs # Store struct (open, record, shutdown)
37//! +-- event.rs # StoreEvent, RequestEvent, SessionEvent
38//! +-- path.rs # DB path resolution (config > env > platform)
39//! +-- schema.rs # SQL DDL, indexes, prepared statements
40//! +-- writer.rs # Background writer thread, batch flush
41//! +-- query/ # Read-only query engine
42//! +-- mod.rs # QueryEngine struct
43//! +-- logs.rs # Request log queries
44//! +-- slow.rs # Slow call queries
45//! +-- stats.rs # Per-tool aggregation with p95
46//! +-- sessions.rs # Session list with active filter
47//! +-- clients.rs # Client aggregation
48//! +-- store_ops.rs# Store stats and vacuum
49//! ```
50
51pub mod emitter;
52pub mod store;
53
54pub use emitter::{CloudSink, CloudSinkConfig, SyncCallback, SyncStatus};