Documentation
¶
Index ¶
- type APIStore
- func (s *APIStore) Create(_ context.Context, server *config.MCPConfig) error
- func (s *APIStore) Delete(_ context.Context, tenant, name string) error
- func (s *APIStore) DeleteVersion(_ context.Context, tenant, name string, version int) error
- func (s *APIStore) Get(_ context.Context, tenant, name string, includeDeleted ...bool) (*config.MCPConfig, error)
- func (s *APIStore) GetVersion(_ context.Context, tenant, name string, version int) (*config.MCPConfigVersion, error)
- func (s *APIStore) List(_ context.Context, _ ...bool) ([]*config.MCPConfig, error)
- func (s *APIStore) ListUpdated(_ context.Context, since time.Time) ([]*config.MCPConfig, error)
- func (s *APIStore) ListVersions(_ context.Context, tenant, name string) ([]*config.MCPConfigVersion, error)
- func (s *APIStore) SetActiveVersion(_ context.Context, tenant, name string, version int) error
- func (s *APIStore) Update(_ context.Context, _ *config.MCPConfig) error
- type ActiveVersion
- type DBStore
- func (s *DBStore) Create(_ context.Context, server *config.MCPConfig) error
- func (s *DBStore) Delete(ctx context.Context, tenant, name string) error
- func (s *DBStore) DeleteVersion(ctx context.Context, tenant, name string, version int) error
- func (s *DBStore) Get(_ context.Context, tenant, name string, includeDeleted ...bool) (*config.MCPConfig, error)
- func (s *DBStore) GetVersion(ctx context.Context, tenant, name string, version int) (*config.MCPConfigVersion, error)
- func (s *DBStore) List(_ context.Context, includeDeleted ...bool) ([]*config.MCPConfig, error)
- func (s *DBStore) ListUpdated(_ context.Context, since time.Time) ([]*config.MCPConfig, error)
- func (s *DBStore) ListVersions(ctx context.Context, tenant, name string) ([]*config.MCPConfigVersion, error)
- func (s *DBStore) SetActiveVersion(ctx context.Context, tenant, name string, version int) error
- func (s *DBStore) Update(ctx context.Context, server *config.MCPConfig) error
- type DatabaseType
- type DiskStore
- func (s *DiskStore) Create(_ context.Context, server *config.MCPConfig) error
- func (s *DiskStore) Delete(_ context.Context, tenant, name string) error
- func (s *DiskStore) DeleteVersion(_ context.Context, tenant, name string, version int) error
- func (s *DiskStore) Get(_ context.Context, tenant, name string, includeDeleted ...bool) (*config.MCPConfig, error)
- func (s *DiskStore) GetActiveVersion(_ context.Context, tenant, name string) (*config.MCPConfig, error)
- func (s *DiskStore) GetVersion(_ context.Context, tenant, name string, version int) (*config.MCPConfigVersion, error)
- func (s *DiskStore) List(_ context.Context, _ ...bool) ([]*config.MCPConfig, error)
- func (s *DiskStore) ListUpdated(_ context.Context, since time.Time) ([]*config.MCPConfig, error)
- func (s *DiskStore) ListVersions(_ context.Context, tenant, name string) ([]*config.MCPConfigVersion, error)
- func (s *DiskStore) SetActiveVersion(_ context.Context, tenant, name string, version int) error
- func (s *DiskStore) Update(_ context.Context, server *config.MCPConfig) error
- type MCPConfig
- type MCPConfigVersion
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIStore ¶
type APIStore struct {
// contains filtered or unexported fields
}
APIStore implements the Store interface using the remote http server
func NewAPIStore ¶
func NewAPIStore(logger *zap.Logger, url string, configJSONPath string, timeout time.Duration) (*APIStore, error)
NewAPIStore creates a new api-based store
func (*APIStore) DeleteVersion ¶
DeleteVersion implements Store.DeleteVersion
func (*APIStore) Get ¶
func (s *APIStore) Get(_ context.Context, tenant, name string, includeDeleted ...bool) (*config.MCPConfig, error)
Get implements Store.Get
func (*APIStore) GetVersion ¶
func (s *APIStore) GetVersion(_ context.Context, tenant, name string, version int) (*config.MCPConfigVersion, error)
GetVersion implements Store.GetVersion
func (*APIStore) ListUpdated ¶
ListUpdated implements Store.ListUpdated
func (*APIStore) ListVersions ¶
func (s *APIStore) ListVersions(_ context.Context, tenant, name string) ([]*config.MCPConfigVersion, error)
ListVersions implements Store.ListVersions
func (*APIStore) SetActiveVersion ¶
SetActiveVersion implements Store.SetActiveVersion
type ActiveVersion ¶
type ActiveVersion struct {
ID uint `gorm:"primarykey"`
Tenant string `gorm:"type:varchar(50);not null;uniqueIndex:idx_tenant_name,priority:1"`
Name string `gorm:"type:varchar(50);not null;uniqueIndex:idx_tenant_name,priority:2"`
Version int `gorm:"not null"`
UpdatedAt time.Time `gorm:"not null"`
DeletedAt gorm.DeletedAt `gorm:"index"`
}
ActiveVersion represents the currently active version of an MCP configuration
type DBStore ¶
type DBStore struct {
// contains filtered or unexported fields
}
DBStore implements the Store interface using a database
func NewDBStore ¶
NewDBStore creates a new database-based store
func (*DBStore) DeleteVersion ¶
DeleteVersion deletes a specific version
func (*DBStore) Get ¶
func (s *DBStore) Get(_ context.Context, tenant, name string, includeDeleted ...bool) (*config.MCPConfig, error)
Get implements Store.Get
func (*DBStore) GetVersion ¶
func (s *DBStore) GetVersion(ctx context.Context, tenant, name string, version int) (*config.MCPConfigVersion, error)
GetVersion gets a specific version of the configuration
func (*DBStore) ListUpdated ¶
ListUpdated implements Store.ListUpdated
func (*DBStore) ListVersions ¶
func (s *DBStore) ListVersions(ctx context.Context, tenant, name string) ([]*config.MCPConfigVersion, error)
ListVersions lists all versions of a configuration
func (*DBStore) SetActiveVersion ¶
SetActiveVersion sets a specific version as the active version
type DatabaseType ¶
type DatabaseType string
DatabaseType represents the type of database
const ( PostgreSQL DatabaseType = "postgres" MySQL DatabaseType = "mysql" SQLite DatabaseType = "sqlite" )
type DiskStore ¶
type DiskStore struct {
// contains filtered or unexported fields
}
func NewDiskStore ¶
NewDiskStore creates a new disk-based store
func (*DiskStore) DeleteVersion ¶
func (*DiskStore) GetActiveVersion ¶
func (*DiskStore) GetVersion ¶
func (*DiskStore) ListUpdated ¶
ListUpdated implements Store.ListUpdated
func (*DiskStore) ListVersions ¶
func (*DiskStore) SetActiveVersion ¶
type MCPConfig ¶
type MCPConfig struct {
ID int64 `gorm:"primaryKey;autoIncrement"`
Name string `gorm:"column:name; type:varchar(50); uniqueIndex:idx_name_tenant,priority:2"`
Tenant string `gorm:"column:tenant; type:varchar(50); default:''; uniqueIndex:idx_name_tenant,priority:1"`
CreatedAt time.Time
UpdatedAt time.Time
Routers string `gorm:"type:text; column:routers"`
Servers string `gorm:"type:text; column:servers"`
Tools string `gorm:"type:text; column:tools"`
McpServers string `gorm:"type:text; column:mcp_servers"`
DeletedAt gorm.DeletedAt `gorm:"index"`
}
MCPConfig represents the database model for MCPConfig
func FromMCPConfig ¶
FromMCPConfig converts MCPConfig to database model
func (*MCPConfig) BeforeCreate ¶
BeforeCreate is a GORM hook that sets timestamps
func (*MCPConfig) BeforeUpdate ¶
BeforeUpdate is a GORM hook that updates the UpdatedAt timestamp
type MCPConfigVersion ¶
type MCPConfigVersion struct {
ID int64 `gorm:"primaryKey;autoIncrement"`
Name string `gorm:"column:name;type:varchar(50);index:idx_name_tenant_version,uniqueIndex"`
Tenant string `gorm:"column:tenant;type:varchar(50);index:idx_name_tenant_version,uniqueIndex"`
Version int `gorm:"column:version;index:idx_name_tenant_version,uniqueIndex"`
ActionType cnst.ActionType `gorm:"column:action_type;not null"` // Create, Update, Delete, Revert
CreatedBy string `gorm:"column:created_by"`
CreatedAt time.Time `gorm:"column:created_at;"`
Routers string `gorm:"type:text;column:routers"`
Servers string `gorm:"type:text;column:servers"`
Tools string `gorm:"type:text;column:tools"`
McpServers string `gorm:"type:text;column:mcp_servers"`
Hash string `gorm:"column:hash;not null"` // hash of the configuration content
DeletedAt gorm.DeletedAt `gorm:"index"`
}
MCPConfigVersion represents the database model for MCPConfigVersion
func FromMCPConfigVersion ¶
func FromMCPConfigVersion(cfg *config.MCPConfig, version int, createdBy string, actionType cnst.ActionType) (*MCPConfigVersion, error)
FromMCPConfigVersion converts MCPConfig to database model
func (*MCPConfigVersion) ToConfigVersion ¶
func (m *MCPConfigVersion) ToConfigVersion() *config.MCPConfigVersion
func (*MCPConfigVersion) ToMCPConfig ¶
func (m *MCPConfigVersion) ToMCPConfig() (*config.MCPConfig, error)
ToMCPConfig converts the database model to MCPConfig
type Store ¶
type Store interface {
// Create creates a new MCP configuration
Create(ctx context.Context, cfg *config.MCPConfig) error
// Get gets an MCP configuration by tenant and name
Get(ctx context.Context, tenant, name string, includeDeleted ...bool) (*config.MCPConfig, error)
// List lists all MCP configurations
// includeDeleted: if true, includes soft deleted records
List(ctx context.Context, includeDeleted ...bool) ([]*config.MCPConfig, error)
// ListUpdated lists all MCP configurations updated since a given time
ListUpdated(ctx context.Context, since time.Time) ([]*config.MCPConfig, error)
// Update updates an existing MCP configuration
Update(ctx context.Context, cfg *config.MCPConfig) error
// Delete deletes an MCP configuration by tenant and name
Delete(ctx context.Context, tenant, name string) error
// GetVersion gets a specific version of the configuration by tenant and name
GetVersion(ctx context.Context, tenant, name string, version int) (*config.MCPConfigVersion, error)
// ListVersions lists all versions of a configuration by tenant and name
ListVersions(ctx context.Context, tenant, name string) ([]*config.MCPConfigVersion, error)
// DeleteVersion deletes a specific version by tenant and name
DeleteVersion(ctx context.Context, tenant, name string, version int) error
// SetActiveVersion sets a specific version as the active version by tenant and name
SetActiveVersion(ctx context.Context, tenant, name string, version int) error
}
Store defines the interface for MCP configuration storage