Skip to content

Commit 56d1a0d

Browse files
authored
Merge branch 'main' into use-model-types
2 parents e9420e8 + bdda82a commit 56d1a0d

File tree

12 files changed

+112
-109
lines changed

12 files changed

+112
-109
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525

2626
- name: Install golangci-lint
2727
run: |
28-
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.61.0
28+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.3.1
2929
3030
- name: Run golangci-lint
3131
run: golangci-lint run --timeout=5m

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build/*
44
.mcpregistry*
55
**/bin
66
cmd/registry/registry
7-
publisher
7+
.DS_Store
88
validate-examples
99
validate-schemas
1010
.idea/

.golangci.yml

Lines changed: 67 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
11
# GolangCI-Lint configuration
22
# See: https://golangci-lint.run/usage/configuration/
33

4+
version: "2"
45
run:
5-
timeout: 5m
66
modules-download-mode: readonly
7-
87
linters:
98
enable:
10-
- errcheck
11-
- gosimple
12-
- govet
13-
- ineffassign
14-
- staticcheck
15-
- typecheck
16-
- unused
179
- asasalint
1810
- asciicheck
1911
- bidichk
@@ -28,14 +20,11 @@ linters:
2820
- exhaustive
2921
- forbidigo
3022
- funlen
31-
- gci
3223
- gocognit
3324
- goconst
3425
- gocritic
3526
- gocyclo
3627
- godox
37-
- gofmt
38-
- goimports
3928
- gomoddirectives
4029
- gomodguard
4130
- goprintffuncname
@@ -59,8 +48,7 @@ linters:
5948
- revive
6049
- rowserrcheck
6150
- sqlclosecheck
62-
- stylecheck
63-
- tenv
51+
- staticcheck
6452
- testpackage
6553
- thelper
6654
- tparallel
@@ -69,55 +57,69 @@ linters:
6957
- usestdlibvars
7058
- wastedassign
7159
- whitespace
72-
73-
linters-settings:
74-
revive:
60+
settings:
61+
cyclop:
62+
max-complexity: 50
63+
funlen:
64+
lines: 150
65+
statements: 150
66+
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
84+
nestif:
85+
min-complexity: 8
86+
exclusions:
87+
generated: lax
88+
presets:
89+
- comments
90+
- common-false-positives
91+
- legacy
92+
- std-error-handling
7593
rules:
76-
- name: use-any
77-
disabled: false
78-
severity: error
79-
cyclop:
80-
max-complexity: 50
81-
funlen:
82-
lines: 150
83-
statements: 150
84-
gocognit:
85-
min-complexity: 50
86-
gocyclo:
87-
min-complexity: 25
88-
goconst:
89-
min-len: 3
90-
min-occurrences: 3
91-
mnd:
92-
checks:
93-
- argument
94-
- case
95-
- condition
96-
- operation
97-
- return
98-
lll:
99-
line-length: 150
100-
misspell:
101-
locale: US
102-
nestif:
103-
min-complexity: 8
104-
105-
issues:
106-
exclude-rules:
107-
# Exclude some linters from running on tests files.
108-
- path: _test\.go
109-
linters:
110-
- mnd
111-
- funlen
112-
- gocyclo
113-
- errcheck
114-
- dupl
115-
- gosec
116-
# Ignore long lines in generated code
117-
- path: docs/
118-
linters:
119-
- lll
120-
# Allow local replacement directives in go.mod
121-
- path: go\.mod
122-
linters:
123-
- gomoddirectives
94+
- linters:
95+
- dupl
96+
- errcheck
97+
- funlen
98+
- gocyclo
99+
- gosec
100+
- mnd
101+
path: _test\.go
102+
- linters:
103+
- lll
104+
path: docs/
105+
- linters:
106+
- mnd
107+
path: integrationtests/
108+
- linters:
109+
- gomoddirectives
110+
path: go\.mod
111+
paths:
112+
- third_party$
113+
- builtin$
114+
- examples$
115+
formatters:
116+
enable:
117+
- gci
118+
- gofmt
119+
- goimports
120+
exclusions:
121+
generated: lax
122+
paths:
123+
- third_party$
124+
- builtin$
125+
- examples$

CLAUDE.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ MCP Registry is a community-driven registry service for Model Context Protocol (
1010
### Prerequisites
1111
- **Go 1.23.x** - The project requires this specific version (check with `go version`)
1212
- Consider using a Go version manager like `g` or `gvm` if you work on multiple projects
13-
- **golangci-lint v1.61.0** - Install with:
13+
- **golangci-lint v2.3.1** - Install with:
1414
```bash
15-
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.61.0
15+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.3.1
1616
```
1717

1818
### Git Hooks (Optional)
@@ -72,7 +72,7 @@ gofmt -s -l .
7272
gofmt -s -w .
7373
```
7474

75-
**Note**: The project uses golangci-lint v1.61.0 with 62 enabled linters. Always run linting locally before pushing to avoid CI failures.
75+
**Note**: The project uses golangci-lint v2.3.1 with 62 enabled linters. Always run linting locally before pushing to avoid CI failures.
7676

7777
## Architecture Overview
7878

Dockerfile

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,22 @@ RUN go build ${GO_BUILD_TAGS:+-tags="$GO_BUILD_TAGS"} -o /build/registry ./cmd/r
77
FROM alpine:latest
88
WORKDIR /app
99
COPY --from=builder /build/registry .
10-
COPY --from=builder /app/data/seed_2025_05_16.json /app/data/seed.json
10+
COPY --from=builder /app/data/seed.json /app/data/seed.json
1111
COPY --from=builder /app/internal/docs/swagger.yaml /app/internal/docs/swagger.yaml
12+
13+
# Create a non-privileged user that the app will run under.
14+
# See https://docs.docker.com/go/dockerfile-user-best-practices/
15+
ARG UID=10001
16+
RUN adduser \
17+
--disabled-password \
18+
--gecos "" \
19+
--home "/nonexistent" \
20+
--shell "/sbin/nologin" \
21+
--no-create-home \
22+
--uid "${UID}" \
23+
appuser
24+
25+
USER appuser
1226
EXPOSE 8080
1327

1428
ENTRYPOINT ["./registry"]

README.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,18 @@ The MCP Registry service provides a centralized repository for MCP server entrie
2929
- Docker (optional, but recommended for development)
3030

3131
For development:
32-
- golangci-lint v1.61.0 - Install with:
32+
- golangci-lint v2.3.1 - Install with:
3333
```bash
34-
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.61.0
34+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.3.1
3535
```
3636

3737
## Running
3838

3939
The easiest way to get the registry running is to use `docker compose`. This will setup the MCP Registry service, import the seed data and run MongoDB in a local Docker environment.
4040

4141
```bash
42-
# Build the Docker image
43-
docker build -t registry .
44-
4542
# Run the registry and MongoDB with docker compose
46-
docker compose up
43+
docker compose up --build
4744
```
4845

4946
This will start the MCP Registry service and MongoDB with Docker, exposing it on port 8080.
File renamed without changes.

docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ services:
22
registry:
33
image: registry
44
container_name: registry
5-
links:
6-
- mongodb
5+
build:
6+
dockerfile: Dockerfile
77
depends_on:
88
- mongodb
99
environment:

internal/api/handlers/v0/publish_test.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,17 @@ type MockRegistryService struct {
2323
}
2424

2525
func (m *MockRegistryService) List(cursor string, limit int) ([]model.Server, string, error) {
26-
args := m.Mock.Called(cursor, limit)
26+
args := m.Called(cursor, limit)
2727
return args.Get(0).([]model.Server), args.String(1), args.Error(2)
2828
}
2929

3030
func (m *MockRegistryService) GetByID(id string) (*model.ServerDetail, error) {
31-
args := m.Mock.Called(id)
31+
args := m.Called(id)
3232
return args.Get(0).(*model.ServerDetail), args.Error(1)
3333
}
3434

3535
func (m *MockRegistryService) Publish(serverDetail *model.ServerDetail) error {
36-
args := m.Mock.Called(serverDetail)
36+
args := m.Called(serverDetail)
3737
return args.Error(0)
3838
}
3939

@@ -45,17 +45,17 @@ type MockAuthService struct {
4545
func (m *MockAuthService) StartAuthFlow(
4646
ctx context.Context, method model.AuthMethod, repoRef string,
4747
) (map[string]string, string, error) {
48-
args := m.Mock.Called(ctx, method, repoRef)
48+
args := m.Called(ctx, method, repoRef)
4949
return args.Get(0).(map[string]string), args.String(1), args.Error(2)
5050
}
5151

5252
func (m *MockAuthService) CheckAuthStatus(ctx context.Context, statusToken string) (string, error) {
53-
args := m.Mock.Called(ctx, statusToken)
53+
args := m.Called(ctx, statusToken)
5454
return args.String(0), args.Error(1)
5555
}
5656

5757
func (m *MockAuthService) ValidateAuth(ctx context.Context, authentication model.Authentication) (bool, error) {
58-
args := m.Mock.Called(ctx, authentication)
58+
args := m.Called(ctx, authentication)
5959
return args.Bool(0), args.Error(1)
6060
}
6161

@@ -416,8 +416,8 @@ func TestPublishHandler(t *testing.T) {
416416
}
417417

418418
// Assert that all expectations were met
419-
mockRegistry.Mock.AssertExpectations(t)
420-
mockAuthService.Mock.AssertExpectations(t)
419+
mockRegistry.AssertExpectations(t)
420+
mockAuthService.AssertExpectations(t)
421421
})
422422
}
423423
}
@@ -487,7 +487,7 @@ func TestPublishHandlerBearerTokenParsing(t *testing.T) {
487487
handler.ServeHTTP(rr, req)
488488

489489
assert.Equal(t, http.StatusCreated, rr.Code)
490-
mockAuthService.Mock.AssertExpectations(t)
490+
mockAuthService.AssertExpectations(t)
491491
})
492492
}
493493
}
@@ -552,7 +552,7 @@ func TestPublishHandlerAuthMethodSelection(t *testing.T) {
552552
handler.ServeHTTP(rr, req)
553553

554554
assert.Equal(t, http.StatusCreated, rr.Code)
555-
mockAuthService.Mock.AssertExpectations(t)
555+
mockAuthService.AssertExpectations(t)
556556
})
557557
}
558558
}
@@ -639,9 +639,9 @@ func TestPublishIntegration(t *testing.T) {
639639
// Verify the server was actually published by retrieving it
640640
publishedServer, err := registryService.GetByID(response["id"])
641641
require.NoError(t, err)
642-
assert.Equal(t, publishReq.ServerDetail.Name, publishedServer.Name)
643-
assert.Equal(t, publishReq.ServerDetail.Description, publishedServer.Description)
644-
assert.Equal(t, publishReq.ServerDetail.VersionDetail.Version, publishedServer.VersionDetail.Version)
642+
assert.Equal(t, publishReq.Name, publishedServer.Name)
643+
assert.Equal(t, publishReq.Description, publishedServer.Description)
644+
assert.Equal(t, publishReq.VersionDetail.Version, publishedServer.VersionDetail.Version)
645645
assert.Len(t, publishedServer.Packages, 1)
646646
assert.Len(t, publishedServer.Remotes, 1)
647647
})

internal/api/handlers/v0/servers.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,8 @@ func ServersHandler(registry service.RegistryService) http.HandlerFunc {
6060
return
6161
}
6262

63-
if parsedLimit > 100 {
64-
// Cap maximum limit to prevent excessive queries
65-
limit = 100
66-
} else {
67-
limit = parsedLimit
68-
}
63+
// Cap maximum limit to prevent excessive queries
64+
limit = min(parsedLimit, 100)
6965
}
7066

7167
// Use the GetAll method to get paginated results

0 commit comments

Comments
 (0)