MCPcopy
hub / github.com/modelcontextprotocol/registry / CountServerVersions

Method CountServerVersions

internal/database/postgres.go:849–865  ·  view source on GitHub ↗

CountServerVersions counts the number of versions for a server

(ctx context.Context, tx pgx.Tx, serverName string)

Source from the content-addressed store, hash-verified

847
848// CountServerVersions counts the number of versions for a server
849func (db *PostgreSQL) CountServerVersions(ctx context.Context, tx pgx.Tx, serverName string) (int, error) {
850 if ctx.Err() != nil {
851 return 0, ctx.Err()
852 }
853
854 executor := db.getExecutor(tx)
855
856 query := `SELECT COUNT(*) FROM servers WHERE server_name = $1`
857
858 var count int
859 err := executor.QueryRow(ctx, query, serverName).Scan(&count)
860 if err != nil {
861 return 0, fmt.Errorf("failed to count server versions: %w", err)
862 }
863
864 return count, nil
865}
866
867// CheckVersionExists checks if a specific version exists for a server
868func (db *PostgreSQL) CheckVersionExists(ctx context.Context, tx pgx.Tx, serverName, version string) (bool, error) {

Callers

nothing calls this directly

Calls 2

getExecutorMethod · 0.95
QueryRowMethod · 0.80

Tested by

no test coverage detected