Documentation
¶
Overview ¶
Package service provides the business logic for the MCP registry API
Package service provides the business logic for the MCP registry API ¶
Package service provides the business logic for the MCP registry API ¶
Package service provides the business logic for the MCP registry API
Index ¶
- Variables
- type DeleteServerVersionOptions
- type DeployedServer
- type GetServerVersionOptions
- type ListServerVersionsOptions
- type ListServersOptions
- type Option
- func WithCursor(cursor string) Option[ListServersOptions]
- func WithLimit[T ListServersOptions | ListServerVersionsOptions](limit int) Option[T]
- func WithName[...](name string) Option[T]
- func WithNext(next time.Time) Option[ListServerVersionsOptions]
- func WithPrev(prev time.Time) Option[ListServerVersionsOptions]
- func WithRegistryName[T ...](registryName string) Option[T]
- func WithSearch(search string) Option[ListServersOptions]
- func WithServerData(serverData *upstreamv0.ServerJSON) Option[PublishServerVersionOptions]
- func WithUpdatedSince(updatedSince time.Time) Option[ListServersOptions]
- func WithVersion[T ListServersOptions | GetServerVersionOptions | DeleteServerVersionOptions](version string) Option[T]
- type PublishServerVersionOptions
- type RegistryDataProvider
- type RegistryProviderFactory
- type RegistryService
Constants ¶
This section is empty.
Variables ¶
var ( // ErrServerNotFound is returned when a server is not found ErrServerNotFound = errors.New("server not found") // ErrNotImplemented is returned when a feature is not implemented ErrNotImplemented = errors.New("not implemented") // ErrRegistryNotFound is returned when a registry is not found ErrRegistryNotFound = errors.New("registry not found") // ErrNotManagedRegistry is returned when attempting write operations on a non-managed registry ErrNotManagedRegistry = errors.New("registry is not managed") // ErrVersionAlreadyExists is returned when attempting to publish a version that already exists ErrVersionAlreadyExists = errors.New("version already exists") )
Functions ¶
This section is empty.
Types ¶
type DeleteServerVersionOptions ¶ added in v0.3.0
DeleteServerVersionOptions is the options for the DeleteServerVersion operation
type DeployedServer ¶
type DeployedServer struct {
Name string `json:"name"`
Namespace string `json:"namespace"`
Status string `json:"status"`
Image string `json:"image"`
Transport string `json:"transport"`
Ready bool `json:"ready"`
EndpointURL string `json:"endpoint_url,omitempty"`
}
DeployedServer represents a deployed MCP server in Kubernetes
type GetServerVersionOptions ¶ added in v0.3.0
GetServerVersionOptions is the options for the GetServerVersion operation
type ListServerVersionsOptions ¶ added in v0.3.0
type ListServerVersionsOptions struct {
RegistryName *string
Name string
Next *time.Time
Prev *time.Time
Limit int
}
ListServerVersionsOptions is the options for the ListServerVersions operation
type ListServersOptions ¶ added in v0.3.0
type ListServersOptions struct {
RegistryName *string
Cursor string
Limit int
Search string
UpdatedSince time.Time
Version string
}
ListServersOptions is the options for the ListServers operation
type Option ¶
type Option[ T ListServersOptions | ListServerVersionsOptions | GetServerVersionOptions | PublishServerVersionOptions | DeleteServerVersionOptions, ] func(*T) error
Option is a function that sets an option for the ListServersOptions, ListServerVersionsOptions, GetServerVersionOptions, PublishServerVersionOptions, or DeleteServerVersionOptions
func WithCursor ¶ added in v0.3.0
func WithCursor(cursor string) Option[ListServersOptions]
WithCursor sets the cursor for the ListServers operation
func WithLimit ¶ added in v0.3.0
func WithLimit[T ListServersOptions | ListServerVersionsOptions](limit int) Option[T]
WithLimit sets the limit for the ListServers or ListServerVersions operation
func WithName ¶ added in v0.3.0
func WithName[T ListServerVersionsOptions | GetServerVersionOptions | DeleteServerVersionOptions](name string) Option[T]
WithName sets the name for the ListServerVersions, GetServerVersion, or DeleteServerVersion operation
func WithNext ¶ added in v0.3.0
func WithNext(next time.Time) Option[ListServerVersionsOptions]
WithNext sets the next time for the ListServerVersions operation
func WithPrev ¶ added in v0.3.0
func WithPrev(prev time.Time) Option[ListServerVersionsOptions]
WithPrev sets the prev time for the ListServerVersions operation
func WithRegistryName ¶ added in v0.3.0
func WithRegistryName[ T ListServersOptions | ListServerVersionsOptions | GetServerVersionOptions | PublishServerVersionOptions | DeleteServerVersionOptions, ]( registryName string, ) Option[T]
WithRegistryName sets the registry name for the ListServers, ListServerVersions, GetServerVersion, PublishServerVersion, or DeleteServerVersion operation
func WithSearch ¶ added in v0.3.0
func WithSearch(search string) Option[ListServersOptions]
WithSearch sets the search for the ListServers operation
func WithServerData ¶ added in v0.3.0
func WithServerData(serverData *upstreamv0.ServerJSON) Option[PublishServerVersionOptions]
WithServerData sets the server data for the PublishServerVersion operation
func WithUpdatedSince ¶ added in v0.3.0
func WithUpdatedSince(updatedSince time.Time) Option[ListServersOptions]
WithUpdatedSince sets the updated since for the ListServers operation
func WithVersion ¶ added in v0.3.0
func WithVersion[T ListServersOptions | GetServerVersionOptions | DeleteServerVersionOptions](version string) Option[T]
WithVersion sets the version for the ListServers, GetServerVersion, or DeleteServerVersion operation
type PublishServerVersionOptions ¶ added in v0.3.0
type PublishServerVersionOptions struct {
RegistryName string
ServerData *upstreamv0.ServerJSON
}
PublishServerVersionOptions is the options for the PublishServerVersion operation
type RegistryDataProvider ¶
type RegistryDataProvider interface {
// GetRegistryData fetches the current registry data.
// Returns the registry data and any error encountered.
GetRegistryData(ctx context.Context) (*toolhivetypes.UpstreamRegistry, error)
// GetSource returns a descriptive string about where the registry data comes from.
// Examples: "file:/path/to/registry.json", "remote:https://example.com/registry"
GetSource() string
// GetRegistryName returns the registry name/identifier for this provider.
// This name is used for business logic such as finding related Kubernetes resources.
GetRegistryName() string
}
RegistryDataProvider abstracts the source of registry data. This interface follows the Go principle of small, focused interfaces and enables easy testing and multiple implementations.
func NewFileRegistryDataProvider ¶
func NewFileRegistryDataProvider(storageManager sources.StorageManager, cfg *config.Config) RegistryDataProvider
NewFileRegistryDataProvider creates a new file-based registry data provider. It accepts a StorageManager to delegate file operations and a Config for registry metadata. This design eliminates code duplication and improves testability through dependency injection.
type RegistryProviderFactory ¶
type RegistryProviderFactory interface {
// CreateProvider creates a registry data provider based on the provided configuration
CreateProvider(cfg *config.Config) (RegistryDataProvider, error)
}
RegistryProviderFactory creates registry data providers based on configuration
func NewRegistryProviderFactory ¶
func NewRegistryProviderFactory(storageManager sources.StorageManager) RegistryProviderFactory
NewRegistryProviderFactory creates a new default registry provider factory
type RegistryService ¶
type RegistryService interface {
// CheckReadiness checks if the regSvc is ready to serve requests
CheckReadiness(ctx context.Context) error
// GetRegistry returns the registry data with metadata
GetRegistry(ctx context.Context) (*toolhivetypes.UpstreamRegistry, string, error) // returns registry, source, error
// ListServers returns all servers in the registry
ListServers(ctx context.Context, opts ...Option[ListServersOptions]) ([]*upstreamv0.ServerJSON, error)
// ListServerVersions returns all versions of a specific server
ListServerVersions(ctx context.Context, opts ...Option[ListServerVersionsOptions]) ([]*upstreamv0.ServerJSON, error)
// GetServer returns a specific server by name
GetServerVersion(ctx context.Context, opts ...Option[GetServerVersionOptions]) (*upstreamv0.ServerJSON, error)
// PublishServerVersion publishes a server version to a managed registry
PublishServerVersion(ctx context.Context, opts ...Option[PublishServerVersionOptions]) (*upstreamv0.ServerJSON, error)
// DeleteServerVersion removes a server version from a managed registry
DeleteServerVersion(ctx context.Context, opts ...Option[DeleteServerVersionOptions]) error
}
RegistryService defines the interface for registry operations
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package database provides a database-backed implementation of the RegistryService interface
|
Package database provides a database-backed implementation of the RegistryService interface |
|
Package inmemory provides an in-memory implementation of the RegistryService interface
|
Package inmemory provides an in-memory implementation of the RegistryService interface |
|
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |