Skip to content

Commit 9d9a02c

Browse files
authored
Database implementation cleanup (#335)
## Motivation and Context The database logic was getting a bit unwieldy and fragile - especially because business logic that should really have lived at the registry service level was being pushed into the persistence level. This PR tightens the interface, simplifies the code there, as well as rips out a bunch of mocks etc. we don't need. ## How Has This Been Tested? Locally everything works ## Breaking Changes The list endpoint was surprisingly always filtering for isLatest only, which seems like a bug? I have removed this filter.
1 parent 07d353b commit 9d9a02c

File tree

19 files changed

+669
-1280
lines changed

19 files changed

+669
-1280
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ publisher: ## Build the publisher tool
1414

1515
# Test targets
1616
test-unit: ## Run unit tests with coverage
17-
go test -v -race -coverprofile=coverage.out -covermode=atomic ./internal/...
17+
go test -v -race -coverprofile=coverage.out -covermode=atomic -coverpkg=./internal/... ./internal/...
1818
go tool cover -html=coverage.out -o coverage.html
1919
@echo "Coverage report generated: coverage.html"
2020

cmd/registry/main.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ import (
1414
"github.com/modelcontextprotocol/registry/internal/api"
1515
"github.com/modelcontextprotocol/registry/internal/config"
1616
"github.com/modelcontextprotocol/registry/internal/database"
17+
"github.com/modelcontextprotocol/registry/internal/importer"
1718
"github.com/modelcontextprotocol/registry/internal/service"
1819
"github.com/modelcontextprotocol/registry/internal/telemetry"
19-
apiv0 "github.com/modelcontextprotocol/registry/pkg/api/v0"
2020
)
2121

2222
func main() {
@@ -46,7 +46,7 @@ func main() {
4646
// Initialize services based on environment
4747
switch cfg.DatabaseType {
4848
case config.DatabaseTypeMemory:
49-
db = database.NewMemoryDB(map[string]*apiv0.ServerJSON{})
49+
db = database.NewMemoryDB()
5050
registryService = service.NewRegistryServiceWithDB(db)
5151
case config.DatabaseTypePostgreSQL:
5252
// Use PostgreSQL for real registry service
@@ -84,7 +84,8 @@ func main() {
8484
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
8585
defer cancel()
8686

87-
if err := db.ImportSeed(ctx, cfg.SeedFrom); err != nil {
87+
importerService := importer.NewService(db)
88+
if err := importerService.ImportFromPath(ctx, cfg.SeedFrom); err != nil {
8889
log.Printf("Failed to import seed data: %v", err)
8990
} else {
9091
log.Println("Data import completed successfully")

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ require (
3838
github.com/prometheus/common v0.65.0 // indirect
3939
github.com/prometheus/otlptranslator v0.0.0-20250717125610-8549f4ab4f8f // indirect
4040
github.com/prometheus/procfs v0.17.0 // indirect
41-
github.com/stretchr/objx v0.5.2 // indirect
4241
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
4342
go.opentelemetry.io/otel/trace v1.37.0 // indirect
4443
golang.org/x/crypto v0.41.0 // indirect

0 commit comments

Comments
 (0)