pub trait McpServerRepository: Send + Sync {
// Required methods
fn insert<'life0, 'async_trait>(
&'life0 self,
server: NewMcpServer,
) -> Pin<Box<dyn Future<Output = Result<McpServer, McpRepositoryError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn get_by_id<'life0, 'async_trait>(
&'life0 self,
id: i64,
) -> Pin<Box<dyn Future<Output = Result<McpServer, McpRepositoryError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn get_by_name<'life0, 'life1, 'async_trait>(
&'life0 self,
name: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<McpServer, McpRepositoryError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn list<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<McpServer>, McpRepositoryError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn update<'life0, 'life1, 'async_trait>(
&'life0 self,
server: &'life1 McpServer,
) -> Pin<Box<dyn Future<Output = Result<(), McpRepositoryError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn delete<'life0, 'async_trait>(
&'life0 self,
id: i64,
) -> Pin<Box<dyn Future<Output = Result<(), McpRepositoryError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn update_last_connected<'life0, 'async_trait>(
&'life0 self,
id: i64,
) -> Pin<Box<dyn Future<Output = Result<(), McpRepositoryError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
Repository trait for MCP server persistence.
This trait defines the interface for storing and retrieving MCP server configurations. Implementations handle all persistence details internally.
§Design Rules
- Environment variables are embedded in
McpServer- no separate env API update()replaces the entire server including env atomically- Constraint: unique
nameacross all servers
§Example
ⓘ
// Insert a new server
let server = repo.insert(NewMcpServer::new_stdio("my-server", "npx", vec![])).await?;
// Get by ID
let found = repo.get_by_id(server.id).await?;
// List all servers
let all = repo.list().await?;Required Methods§
Sourcefn insert<'life0, 'async_trait>(
&'life0 self,
server: NewMcpServer,
) -> Pin<Box<dyn Future<Output = Result<McpServer, McpRepositoryError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn insert<'life0, 'async_trait>(
&'life0 self,
server: NewMcpServer,
) -> Pin<Box<dyn Future<Output = Result<McpServer, McpRepositoryError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Insert a new MCP server.
Returns the server with its assigned ID and timestamps.
§Errors
Conflictif a server with the same name already existsInternalfor storage errors
Sourcefn get_by_id<'life0, 'async_trait>(
&'life0 self,
id: i64,
) -> Pin<Box<dyn Future<Output = Result<McpServer, McpRepositoryError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_by_id<'life0, 'async_trait>(
&'life0 self,
id: i64,
) -> Pin<Box<dyn Future<Output = Result<McpServer, McpRepositoryError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get an MCP server by its database ID.
§Errors
NotFoundif no server with the given ID existsInternalfor storage errors
Sourcefn get_by_name<'life0, 'life1, 'async_trait>(
&'life0 self,
name: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<McpServer, McpRepositoryError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_by_name<'life0, 'life1, 'async_trait>(
&'life0 self,
name: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<McpServer, McpRepositoryError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get an MCP server by its unique name.
§Errors
NotFoundif no server with the given name existsInternalfor storage errors
Sourcefn list<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<McpServer>, McpRepositoryError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn list<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<McpServer>, McpRepositoryError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Sourcefn update<'life0, 'life1, 'async_trait>(
&'life0 self,
server: &'life1 McpServer,
) -> Pin<Box<dyn Future<Output = Result<(), McpRepositoryError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn update<'life0, 'life1, 'async_trait>(
&'life0 self,
server: &'life1 McpServer,
) -> Pin<Box<dyn Future<Output = Result<(), McpRepositoryError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Update an existing MCP server.
This atomically replaces the entire server including environment variables.
§Errors
NotFoundif no server with the given ID existsConflictif the new name conflicts with another serverInternalfor storage errors
Sourcefn delete<'life0, 'async_trait>(
&'life0 self,
id: i64,
) -> Pin<Box<dyn Future<Output = Result<(), McpRepositoryError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn delete<'life0, 'async_trait>(
&'life0 self,
id: i64,
) -> Pin<Box<dyn Future<Output = Result<(), McpRepositoryError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Delete an MCP server by its database ID.
§Errors
NotFoundif no server with the given ID existsInternalfor storage errors
Sourcefn update_last_connected<'life0, 'async_trait>(
&'life0 self,
id: i64,
) -> Pin<Box<dyn Future<Output = Result<(), McpRepositoryError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn update_last_connected<'life0, 'async_trait>(
&'life0 self,
id: i64,
) -> Pin<Box<dyn Future<Output = Result<(), McpRepositoryError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Update only the last_connected_at timestamp.
This is a narrow, first-class method for updating connection time without replacing the entire server.
§Errors
NotFoundif no server with the given ID existsInternalfor storage errors