Skip to main content

Module store

Module store 

Source
Expand description

SQLite-based request storage engine and query layer for mcpr.

Every MCP request flowing through the proxy is recorded here, and all CLI observability commands (mcpr proxy logs, mcpr proxy slow, etc.) read from here.

This is a local event sink — the same pattern as crate::emitter, but writing to SQLite instead of an external service.

§Architecture

Proxy hot path ──► Store::record() ──► mpsc channel ──► Writer thread ──► SQLite (WAL)
                   (non-blocking)       (10k buffer)     (batch flush)

CLI commands   ──► QueryEngine ──► read-only SQLite connection

Re-exports§

pub use config::FileStoreConfig;
pub use duration::parse_duration;
pub use duration::since_to_cutoff_ms;
pub use engine::Store;
pub use engine::StoreConfig;
pub use engine::StoreError;
pub use event::RequestEvent;
pub use event::RequestStatus;
pub use event::SessionEvent;
pub use event::StoreEvent;
pub use query::QueryEngine;
pub use sqlite_sink::SqliteSink;

Modules§

config
Store configuration — TOML section and validation.
db
SQLite connection management, WAL setup, and schema migrations.
duration
Human-friendly duration parsing for --since and --before CLI flags.
engine
The Store — public API for the storage engine.
event
Event types sent from the proxy hot path to the background storage writer.
path
Database file path resolution.
query
Query engine — read-only access to the storage database.
schema
SQL schema definitions for the mcpr storage engine.
sqlite_sink
SQLite event sink — writes proxy events to the local SQLite store.
writer
Background storage writer — dedicated OS thread with batch flushing.