McpServerRepository

Trait McpServerRepository 

Source
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 name across 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§

Source

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
  • Conflict if a server with the same name already exists
  • Internal for storage errors
Source

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
  • NotFound if no server with the given ID exists
  • Internal for storage errors
Source

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
  • NotFound if no server with the given name exists
  • Internal for storage errors
Source

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,

List all MCP servers.

§Errors
  • Internal for storage errors
Source

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
  • NotFound if no server with the given ID exists
  • Conflict if the new name conflicts with another server
  • Internal for storage errors
Source

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
  • NotFound if no server with the given ID exists
  • Internal for storage errors
Source

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
  • NotFound if no server with the given ID exists
  • Internal for storage errors

Implementors§