MCPcopy Index your code
hub / github.com/modelcontextprotocol/registry / Database

Interface Database

internal/database/database.go:35–71  ·  view source on GitHub ↗

Database defines the interface for database operations

Source from the content-addressed store, hash-verified

33
34// Database defines the interface for database operations
35type Database interface {
36 // CreateServer inserts a new server version with official metadata
37 CreateServer(ctx context.Context, tx pgx.Tx, serverJSON *apiv0.ServerJSON, officialMeta *apiv0.RegistryExtensions) (*apiv0.ServerResponse, error)
38 // UpdateServer updates an existing server record
39 UpdateServer(ctx context.Context, tx pgx.Tx, serverName, version string, serverJSON *apiv0.ServerJSON) (*apiv0.ServerResponse, error)
40 // SetServerStatus updates the status of a specific server version
41 SetServerStatus(ctx context.Context, tx pgx.Tx, serverName, version string, status model.Status, statusMessage *string) (*apiv0.ServerResponse, error)
42 // SetAllVersionsStatus updates the status of all versions of a server in a single query
43 SetAllVersionsStatus(ctx context.Context, tx pgx.Tx, serverName string, status model.Status, statusMessage *string) ([]*apiv0.ServerResponse, error)
44 // ListServers retrieve server entries with optional filtering
45 ListServers(ctx context.Context, tx pgx.Tx, filter *ServerFilter, cursor string, limit int) ([]*apiv0.ServerResponse, string, error)
46 // GetServerByName retrieve a single server by its name
47 GetServerByName(ctx context.Context, tx pgx.Tx, serverName string, includeDeleted bool) (*apiv0.ServerResponse, error)
48 // GetServerByNameAndVersion retrieve specific version of a server by server name and version
49 GetServerByNameAndVersion(ctx context.Context, tx pgx.Tx, serverName string, version string, includeDeleted bool) (*apiv0.ServerResponse, error)
50 // GetAllVersionsByServerName retrieve all versions of a server by server name
51 GetAllVersionsByServerName(ctx context.Context, tx pgx.Tx, serverName string, includeDeleted bool) ([]*apiv0.ServerResponse, error)
52 // GetCurrentLatestVersion retrieve the current latest version of a server by server name
53 GetCurrentLatestVersion(ctx context.Context, tx pgx.Tx, serverName string) (*apiv0.ServerResponse, error)
54 // CountServerVersions count the number of versions for a server
55 CountServerVersions(ctx context.Context, tx pgx.Tx, serverName string) (int, error)
56 // CheckVersionExists check if a specific version exists for a server
57 CheckVersionExists(ctx context.Context, tx pgx.Tx, serverName, version string) (bool, error)
58 // UnmarkAsLatest marks the current latest version of a server as no longer latest
59 UnmarkAsLatest(ctx context.Context, tx pgx.Tx, serverName string) error
60 // SetLatestVersion sets is_latest=true on the given version and false on all other
61 // versions of the same server. Passing an empty version clears is_latest for all rows.
62 // Callers must hold the per-server publish lock to avoid races.
63 SetLatestVersion(ctx context.Context, tx pgx.Tx, serverName, version string) error
64 // AcquirePublishLock acquires an exclusive advisory lock for publishing a server
65 // This prevents race conditions when multiple versions are published concurrently
66 AcquirePublishLock(ctx context.Context, tx pgx.Tx, serverName string) error
67 // InTransaction executes a function within a database transaction
68 InTransaction(ctx context.Context, fn func(ctx context.Context, tx pgx.Tx) error) error
69 // Close closes the database connection
70 Close() error
71}
72
73// InTransactionT is a generic helper that wraps InTransaction for functions returning a value
74// This exists because Go does not support generic methods on interfaces - only the Database interface

Implementers 1

PostgreSQLinternal/database/postgres.go

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…