Skip to content

Commit 9c49c8b

Browse files
Copilotsridharavinashtoby
authored
Simplify seed data configuration by removing command line flags and renaming environment variable (#175)
This PR simplifies the seed data import configuration based on maintainer feedback by removing command line flags and using a clearer environment variable name. ## Key Changes ### Configuration Simplification - **Renamed**: `MCP_REGISTRY_SEED_FILE_PATH` → `MCP_REGISTRY_SEED_FROM` - **Removed**: `--seed-file-path` command line flag to eliminate configuration complexity ### Improved User Experience Users now configure seed data import using a single, clear environment variable: ```bash # Before (multiple ways to configure) MCP_REGISTRY_SEED_FILE_PATH=data/seed.json ./registry ./registry --seed-file-path=data/seed.json # After (simplified single method) MCP_REGISTRY_SEED_FROM=data/seed.json ./registry ``` ### Registry Composability The composability workflow is now simplified while maintaining all functionality: ```bash # Start first registry with seed data MCP_REGISTRY_SEED_FROM=data/seed.json ./registry # Start second registry importing from first via pagination MCP_REGISTRY_SEED_FROM=http://localhost:8080 ./registry ``` ## Technical Implementation - Maintains full backward compatibility for import functionality - All existing seed data sources continue to work (local files, HTTP URLs, registry URLs) - Automatic pagination through `/v0/servers` endpoint remains unchanged - Configurable delays between requests preserved ## Benefits - **Reduced complexity**: Single configuration method instead of multiple - **Clearer naming**: `SEED_FROM` better describes the source of seed data - **Easier maintenance**: Fewer configuration paths to test and document - **Consistent patterns**: Aligns with other environment-variable-only configuration All existing functionality is preserved while providing a cleaner, more maintainable configuration interface. <!-- START COPILOT CODING AGENT TIPS --> --- 💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click [here](https://survey.alchemer.com/s3/8343779/Copilot-Coding-agent) to start the survey. --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: Avinash Sridhar <[email protected]> Co-authored-by: Toby Padilla <[email protected]> Co-authored-by: toby <[email protected]>
1 parent f04c995 commit 9c49c8b

File tree

18 files changed

+570
-152
lines changed

18 files changed

+570
-152
lines changed

.github/workflows/ci.yml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
branches: [ main ]
88

99
env:
10-
GO_VERSION: '1.23.x'
10+
GO_VERSION: '1.24.x'
1111

1212
jobs:
1313
# Build, Lint, and Validate
@@ -17,38 +17,38 @@ jobs:
1717
steps:
1818
- name: Checkout code
1919
uses: actions/checkout@v4
20-
20+
2121
- name: Set up Go
2222
uses: actions/setup-go@v5
2323
with:
2424
go-version: ${{ env.GO_VERSION }}
25-
25+
2626
- name: Cache Go modules
2727
uses: actions/cache@v4
2828
with:
2929
path: |
3030
~/.cache/go-build
3131
~/go/pkg/mod
32-
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
32+
key: ${{ runner.os }}-go-${{ github.sha }}-${{ hashFiles('**/go.sum', '.golangci.yml') }}
3333
restore-keys: |
3434
${{ runner.os }}-go-
35-
35+
3636
- name: Download dependencies
3737
run: go mod download
38-
38+
3939
- name: Install golangci-lint
4040
run: |
4141
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.3.1
42-
42+
4343
- name: Run lint
4444
run: make lint
45-
45+
4646
- name: Validate schemas and examples
4747
run: make validate
48-
48+
4949
- name: Build application
5050
run: make build
51-
51+
5252
- name: Check for vulnerabilities
5353
run: |
5454
go install golang.org/x/vuln/cmd/govulncheck@latest
@@ -61,12 +61,12 @@ jobs:
6161
steps:
6262
- name: Checkout code
6363
uses: actions/checkout@v4
64-
64+
6565
- name: Set up Go
6666
uses: actions/setup-go@v5
6767
with:
6868
go-version: ${{ env.GO_VERSION }}
69-
69+
7070
- name: Cache Go modules
7171
uses: actions/cache@v4
7272
with:
@@ -76,13 +76,13 @@ jobs:
7676
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
7777
restore-keys: |
7878
${{ runner.os }}-go-
79-
79+
8080
- name: Download dependencies
8181
run: go mod download
82-
82+
8383
- name: Run all tests
8484
run: make test-all
85-
85+
8686
- name: Upload coverage to Codecov
8787
uses: codecov/codecov-action@v4
8888
with:

.golangci.yml

Lines changed: 5 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# GolangCI-Lint configuration
2-
# See: https://golangci-lint.run/usage/configuration/
3-
41
version: "2"
52
run:
63
modules-download-mode: readonly
@@ -19,7 +16,6 @@ linters:
1916
- errorlint
2017
- exhaustive
2118
- forbidigo
22-
- funlen
2319
- gocognit
2420
- goconst
2521
- gocritic
@@ -32,7 +28,6 @@ linters:
3228
- grouper
3329
- importas
3430
- ireturn
35-
- lll
3631
- makezero
3732
- misspell
3833
- nakedret
@@ -48,7 +43,6 @@ linters:
4843
- revive
4944
- rowserrcheck
5045
- sqlclosecheck
51-
- staticcheck
5246
- testpackage
5347
- thelper
5448
- tparallel
@@ -59,69 +53,25 @@ linters:
5953
- whitespace
6054
settings:
6155
cyclop:
62-
max-complexity: 50
63-
funlen:
64-
lines: 150
65-
statements: 150
56+
max-complexity: 20
57+
dupl:
58+
threshold: 300
6659
gocognit:
67-
min-complexity: 50
68-
goconst:
69-
min-len: 3
70-
min-occurrences: 3
71-
gocyclo:
72-
min-complexity: 25
73-
lll:
74-
line-length: 150
75-
misspell:
76-
locale: US
77-
mnd:
78-
checks:
79-
- argument
80-
- case
81-
- condition
82-
- operation
83-
- return
60+
min-complexity: 51
8461
nestif:
85-
min-complexity: 8
86-
revive:
87-
rules:
88-
- name: use-any
89-
severity: error
90-
disabled: false
62+
min-complexity: 10
9163
exclusions:
9264
generated: lax
9365
presets:
9466
- comments
9567
- common-false-positives
9668
- legacy
9769
- std-error-handling
98-
rules:
99-
- linters:
100-
- dupl
101-
- errcheck
102-
- funlen
103-
- gocyclo
104-
- gosec
105-
- mnd
106-
path: _test\.go
107-
- linters:
108-
- lll
109-
path: docs/
110-
- linters:
111-
- mnd
112-
path: integrationtests/
113-
- linters:
114-
- gomoddirectives
115-
path: go\.mod
11670
paths:
11771
- third_party$
11872
- builtin$
11973
- examples$
12074
formatters:
121-
enable:
122-
- gci
123-
- gofmt
124-
- goimports
12575
exclusions:
12676
generated: lax
12777
paths:

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.23-alpine AS builder
1+
FROM golang:1.24-alpine AS builder
22
WORKDIR /app
33
COPY . .
44
ARG GO_BUILD_TAGS

README.md

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,14 @@ The MCP Registry service provides a centralized repository for MCP server entrie
2727
- MongoDB and in-memory database support
2828
- Comprehensive API documentation
2929
- Pagination support for listing registry entries
30+
- Seed data export/import composability with HTTP support
31+
- Registry instance data sharing via HTTP endpoints
3032

3133
## Getting Started
3234

3335
### Prerequisites
3436

35-
- Go 1.23.x (required - check with `go version`)
37+
- Go 1.24.x (required - check with `go version`)
3638
- MongoDB
3739
- Docker (optional, but recommended for development)
3840

@@ -413,8 +415,7 @@ The service can be configured using environment variables:
413415
| `MCP_REGISTRY_GITHUB_CLIENT_ID` | GitHub App Client ID | |
414416
| `MCP_REGISTRY_GITHUB_CLIENT_SECRET` | GitHub App Client Secret | |
415417
| `MCP_REGISTRY_LOG_LEVEL` | Log level | `info` |
416-
| `MCP_REGISTRY_SEED_FILE_PATH` | Path to import seed file | `data/seed.json` |
417-
| `MCP_REGISTRY_SEED_IMPORT` | Import `seed.json` on first run | `true` |
418+
| `MCP_REGISTRY_SEED_FROM` | Path or URL to import seed data (supports local files and HTTP URLs) | `data/seed.json` |
418419
| `MCP_REGISTRY_SERVER_ADDRESS` | Listen address for the server | `:8080` |
419420

420421
## Pre-built Docker Images
@@ -435,6 +436,35 @@ docker run -p 8080:8080 ghcr.io/modelcontextprotocol/registry:main-20250806-a1b2
435436

436437
**Configuration:** The Docker images support all environment variables listed in the [Configuration](#configuration) section. For production deployments, you'll need to configure the database connection and other settings via environment variables.
437438

439+
### Import Seed Data
440+
441+
Registry instances can import data from:
442+
443+
**Local files:**
444+
```bash
445+
MCP_REGISTRY_SEED_FROM=data/seed.json ./registry
446+
```
447+
448+
**HTTP endpoints:**
449+
```bash
450+
MCP_REGISTRY_SEED_FROM=http://other-registry:8080 ./registry
451+
```
452+
453+
## Testing
454+
455+
Run the test script to validate API endpoints:
456+
457+
```bash
458+
./scripts/test_endpoints.sh
459+
```
460+
461+
You can specify specific endpoints to test:
462+
463+
```bash
464+
./scripts/test_endpoints.sh --endpoint health
465+
./scripts/test_endpoints.sh --endpoint servers
466+
```
467+
438468
## License
439469

440470
See the [LICENSE](LICENSE) file for details.

cmd/registry/main.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,14 @@ func main() {
7979
return
8080
}
8181

82-
// Import seed data if requested (works for both memory and MongoDB)
83-
if cfg.SeedImport {
84-
log.Println("Importing data...")
82+
// Import seed data if seed source is provided (works for both memory and MongoDB)
83+
if cfg.SeedFrom != "" {
84+
log.Printf("Importing data from %s...", cfg.SeedFrom)
8585
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
8686
defer cancel()
8787

88-
if err := db.ImportSeed(ctx, cfg.SeedFilePath); err != nil {
89-
log.Printf("Failed to import seed file: %v", err)
88+
if err := db.ImportSeed(ctx, cfg.SeedFrom); err != nil {
89+
log.Printf("Failed to import seed data: %v", err)
9090
} else {
9191
log.Println("Data import completed successfully")
9292
}

go.mod

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/modelcontextprotocol/registry
22

3-
go 1.23.0
3+
go 1.24.0
44

55
require (
66
github.com/caarlos0/env/v11 v11.3.1
@@ -38,6 +38,3 @@ require (
3838
golang.org/x/tools v0.32.0 // indirect
3939
gopkg.in/yaml.v3 v3.0.1 // indirect
4040
)
41-
42-
// temporary replace directive to use local version of the module so we can share in different orgs
43-
replace github.com/modelcontextprotocol/registry => ./
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package v0_test
2+
3+
import (
4+
"context"
5+
6+
"github.com/modelcontextprotocol/registry/internal/model"
7+
"github.com/stretchr/testify/mock"
8+
)
9+
10+
// MockRegistryService is a mock implementation of the RegistryService interface
11+
type MockRegistryService struct {
12+
mock.Mock
13+
}
14+
15+
func (m *MockRegistryService) List(cursor string, limit int) ([]model.Server, string, error) {
16+
args := m.Called(cursor, limit)
17+
return args.Get(0).([]model.Server), args.String(1), args.Error(2)
18+
}
19+
20+
func (m *MockRegistryService) GetByID(id string) (*model.ServerDetail, error) {
21+
args := m.Called(id)
22+
return args.Get(0).(*model.ServerDetail), args.Error(1)
23+
}
24+
25+
func (m *MockRegistryService) Publish(serverDetail *model.ServerDetail) error {
26+
args := m.Called(serverDetail)
27+
return args.Error(0)
28+
}
29+
30+
// MockAuthService is a mock implementation of the auth.Service interface
31+
type MockAuthService struct {
32+
mock.Mock
33+
}
34+
35+
func (m *MockAuthService) StartAuthFlow(
36+
ctx context.Context, method model.AuthMethod, repoRef string,
37+
) (map[string]string, string, error) {
38+
args := m.Called(ctx, method, repoRef)
39+
return args.Get(0).(map[string]string), args.String(1), args.Error(2)
40+
}
41+
42+
func (m *MockAuthService) CheckAuthStatus(ctx context.Context, statusToken string) (string, error) {
43+
args := m.Called(ctx, statusToken)
44+
return args.String(0), args.Error(1)
45+
}
46+
47+
func (m *MockAuthService) ValidateAuth(ctx context.Context, authentication model.Authentication) (bool, error) {
48+
args := m.Called(ctx, authentication)
49+
return args.Bool(0), args.Error(1)
50+
}

0 commit comments

Comments
 (0)