Skip to main content

mcpr_core/protocol/schema_manager/
mod.rs

1//! Schema manager: the top-level per-upstream view of an MCP server.
2//!
3//! `SchemaManager` owns the canonical picture of what an upstream MCP
4//! server exposes — its capabilities, tools, resources, prompts — and
5//! how that picture changes over time. Other subsystems (sessions,
6//! tool hiding, custom tools, audit, cloud sync) read from it.
7//!
8//! This module consists of:
9//!
10//! - [`SchemaVersion`] / [`SchemaVersionId`]: immutable, content-hashed
11//!   snapshot of one method's merged payload.
12//! - [`SchemaStore`] / [`MemorySchemaStore`]: pluggable persistence
13//!   with a bounded in-memory default.
14//! - [`SchemaManager`]: ingest + query + stale tracking. Calls existing
15//!   `crate::protocol::schema` helpers for pagination and diffing.
16//! - [`SchemaScanner`]: trait for active discovery (`Standalone` or
17//!   `Attached` mode). No concrete implementation in this step.
18//! - [`ScanTrigger`]: enumerates the reasons a scan is initiated.
19
20mod manager;
21mod scanner;
22mod store;
23mod version;
24
25pub use manager::SchemaManager;
26pub use scanner::{ScanError, ScanMode, ScanResult, SchemaScanner};
27pub use store::{MemorySchemaStore, SchemaStore};
28pub use version::{SchemaVersion, SchemaVersionId};
29
30use serde::Serialize;
31
32/// Why a scan was started.
33#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
34#[serde(rename_all = "snake_case")]
35pub enum ScanTrigger {
36    /// Proxy startup — initial discovery run.
37    ProxyStart,
38    /// TTL on the current version elapsed.
39    TtlElapsed,
40    /// `initialize` response saw a different `serverInfo`.
41    ServerIdentityChanged,
42    /// `notifications/tools/list_changed` received.
43    ListChangedNotification,
44    /// Operator-triggered manual rescan.
45    Manual,
46}