pub struct McpServer {
pub name: String,
pub version: String,
/* private fields */
}Expand description
MCP server that reads JSON-RPC from stdin, writes responses to stdout. Holds Storage, HnswIndex, and GraphEngine for real tool dispatch.
Fields§
§name: String§version: StringImplementations§
Source§impl McpServer
impl McpServer
Sourcepub fn new(
storage: Box<dyn StorageBackend>,
vector: HnswIndex,
graph: GraphEngine,
embeddings: Option<Box<dyn EmbeddingProvider>>,
) -> Self
pub fn new( storage: Box<dyn StorageBackend>, vector: HnswIndex, graph: GraphEngine, embeddings: Option<Box<dyn EmbeddingProvider>>, ) -> Self
Create a server with storage, vector, graph, and optional embeddings backends.
Sourcepub fn from_db_path(db_path: &Path) -> Result<Self, CodememError>
pub fn from_db_path(db_path: &Path) -> Result<Self, CodememError>
Create a server from a database path, loading all backends.
Sourcepub fn for_testing() -> Self
pub fn for_testing() -> Self
Create a minimal server for testing (no backends wired).
pub fn lock_graph(&self) -> Result<MutexGuard<'_, GraphEngine>, CodememError>
Sourcepub fn storage(&self) -> &dyn StorageBackend
pub fn storage(&self) -> &dyn StorageBackend
Access the underlying storage backend.
Sourcepub fn graph(&self) -> &Mutex<GraphEngine>
pub fn graph(&self) -> &Mutex<GraphEngine>
Access the graph engine (mutex-protected).
Sourcepub fn embeddings(&self) -> Option<&Mutex<Box<dyn EmbeddingProvider>>>
pub fn embeddings(&self) -> Option<&Mutex<Box<dyn EmbeddingProvider>>>
Access the embedding provider (mutex-protected, optional).
Sourcepub fn reload_graph(&self) -> Result<(), CodememError>
pub fn reload_graph(&self) -> Result<(), CodememError>
Reload the in-memory graph from the database.
This is needed when the graph was modified by a separate process (e.g., MCP stdio indexing while the API server is running).
Sourcepub fn config(&self) -> &CodememConfig
pub fn config(&self) -> &CodememConfig
Access the loaded configuration.
Sourcepub fn metrics_collector(&self) -> &Arc<InMemoryMetrics>
pub fn metrics_collector(&self) -> &Arc<InMemoryMetrics>
Access the operational metrics collector.
Sourcepub fn save_index(&self)
pub fn save_index(&self)
Save the HNSW index to disk. The index file path is derived from
the database path with an .idx extension. No-op if db_path is None
(e.g., in-memory / testing mode).
Sourcepub fn run(&self) -> Result<()>
pub fn run(&self) -> Result<()>
Run the MCP server over stdio. Convenience method that creates a
StdioTransport and runs it. Blocks until stdin is closed.
pub fn handle_notification(&self, method: &str)
pub fn handle_request( &self, method: &str, params: Option<&Value>, id: Value, ) -> JsonRpcResponse
Auto Trait Implementations§
impl !Freeze for McpServer
impl !RefUnwindSafe for McpServer
impl Send for McpServer
impl Sync for McpServer
impl Unpin for McpServer
impl UnsafeUnpin for McpServer
impl !UnwindSafe for McpServer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more