Skip to content

Commit 0fc9d9e

Browse files
authored
Merge branch 'main' into bug/docker-compose--links-deprecated-#107
2 parents a2d06ec + 26b85d7 commit 0fc9d9e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+2473
-3728
lines changed

.githooks/pre-commit

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
3+
# Pre-commit hook for MCP Registry
4+
# Runs linting and formatting checks before allowing commits
5+
6+
set -e
7+
8+
echo "Running pre-commit checks..."
9+
10+
# Check if golangci-lint is installed
11+
if ! command -v golangci-lint &> /dev/null; then
12+
echo "❌ golangci-lint is not installed!"
13+
echo "See README.md Prerequisites section for installation instructions."
14+
exit 1
15+
fi
16+
17+
# Run golangci-lint
18+
echo "Running golangci-lint..."
19+
if ! golangci-lint run --timeout=5m; then
20+
echo "❌ Linting failed! Please fix the issues above."
21+
exit 1
22+
fi
23+
24+
# Check formatting
25+
echo "Checking Go formatting..."
26+
UNFORMATTED=$(gofmt -s -l .)
27+
if [ -n "$UNFORMATTED" ]; then
28+
echo "❌ The following files need formatting:"
29+
echo "$UNFORMATTED"
30+
echo ""
31+
echo "Run 'gofmt -s -w .' to fix formatting issues."
32+
exit 1
33+
fi
34+
35+
echo "✅ All pre-commit checks passed!"

.github/workflows/ci.yml

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -141,20 +141,8 @@ jobs:
141141

142142
- name: Run integration tests
143143
run: |
144-
chmod +x ./integrationtests/run_tests.sh
145-
./integrationtests/run_tests.sh
146-
147-
- name: Run integration tests with coverage
148-
run: |
149-
go test -v -race -coverprofile=integration-coverage.out -covermode=atomic ./integrationtests/...
150-
151-
- name: Upload integration coverage to Codecov
152-
uses: codecov/codecov-action@v4
153-
with:
154-
file: ./integration-coverage.out
155-
flags: integrationtests
156-
name: codecov-integration
157-
fail_ci_if_error: false
144+
chmod +x ./tests/integration/run.sh
145+
./tests/integration/run.sh
158146
159147
# Overall status check
160148
test-summary:

.github/workflows/integration-tests.yml

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -48,27 +48,5 @@ jobs:
4848
- name: Run integration tests
4949
run: |
5050
# Run integration tests using the existing script
51-
chmod +x ./integrationtests/run_tests.sh
52-
./integrationtests/run_tests.sh
53-
54-
- name: Run integration tests with coverage
55-
run: |
56-
# Also run integration tests with Go test for coverage
57-
go test -v -race -coverprofile=integration-coverage.out -covermode=atomic ./integrationtests/...
58-
59-
- name: Generate integration test coverage report
60-
run: go tool cover -html=integration-coverage.out -o integration-coverage.html
61-
62-
- name: Upload integration coverage to Codecov
63-
uses: codecov/codecov-action@v4
64-
with:
65-
file: ./integration-coverage.out
66-
flags: integrationtests
67-
name: codecov-integration
68-
fail_ci_if_error: false
69-
70-
- name: Upload integration coverage artifact
71-
uses: actions/upload-artifact@v4
72-
with:
73-
name: integration-coverage-report
74-
path: integration-coverage.html
51+
chmod +x ./tests/integration/run.sh
52+
./tests/integration/run.sh

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@ build/*
44
.mcpregistry*
55
**/bin
66
cmd/registry/registry
7-
publisher
7+
validate-examples
8+
validate-schemas
9+
.idea/

.golangci.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ linters:
7171
- whitespace
7272

7373
linters-settings:
74+
revive:
75+
rules:
76+
- name: use-any
77+
disabled: false
78+
severity: error
7479
cyclop:
7580
max-complexity: 50
7681
funlen:
@@ -112,10 +117,6 @@ issues:
112117
- path: docs/
113118
linters:
114119
- lll
115-
# Ignore magic numbers in test files
116-
- path: integrationtests/
117-
linters:
118-
- mnd
119120
# Allow local replacement directives in go.mod
120121
- path: go\.mod
121122
linters:

CLAUDE.md

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Overview
6+
MCP Registry is a community-driven registry service for Model Context Protocol (MCP) servers. It provides a centralized repository for discovering and managing MCP implementations.
7+
8+
## Development Setup
9+
10+
### Prerequisites
11+
- **Go 1.23.x** - The project requires this specific version (check with `go version`)
12+
- Consider using a Go version manager like `g` or `gvm` if you work on multiple projects
13+
- **golangci-lint v1.61.0** - Install with:
14+
```bash
15+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.61.0
16+
```
17+
18+
### Git Hooks (Optional)
19+
To run linting automatically before commits:
20+
```bash
21+
git config core.hooksPath .githooks
22+
```
23+
24+
## Common Development Commands
25+
26+
### Build
27+
```bash
28+
# Build the registry application
29+
go build ./cmd/registry
30+
31+
# Build with Docker
32+
docker build -t registry .
33+
34+
# Build the publisher tool
35+
cd tools/publisher && ./build.sh
36+
```
37+
38+
### Run
39+
```bash
40+
# Development with Docker Compose (recommended)
41+
docker compose up
42+
43+
# Direct execution
44+
go run cmd/registry/main.go
45+
```
46+
47+
### Test
48+
```bash
49+
# Unit tests
50+
go test -v -race -coverprofile=coverage.out -covermode=atomic ./internal/...
51+
52+
# Integration tests
53+
./tests/integration/run.sh
54+
55+
# Test API endpoints
56+
./scripts/test_endpoints.sh
57+
58+
# Test publish endpoint (requires GitHub token)
59+
export BEARER_TOKEN=your_github_token_here
60+
./scripts/test_publish.sh
61+
```
62+
63+
### Lint
64+
```bash
65+
# Run linting (same as CI)
66+
golangci-lint run --timeout=5m
67+
68+
# Check formatting
69+
gofmt -s -l .
70+
71+
# Fix formatting issues
72+
gofmt -s -w .
73+
```
74+
75+
**Note**: The project uses golangci-lint v1.61.0 with 62 enabled linters. Always run linting locally before pushing to avoid CI failures.
76+
77+
## Architecture Overview
78+
79+
The codebase follows a clean architecture pattern:
80+
81+
### Core Layers
82+
- **API Layer** (`internal/api/`) - HTTP handlers and routing
83+
- **Service Layer** (`internal/service/`) - Business logic implementation
84+
- **Database Layer** (`internal/database/`) - Data persistence abstraction with MongoDB and in-memory implementations
85+
- **Domain Models** (`internal/model/`) - Core data structures
86+
- **Authentication** (`internal/auth/`) - GitHub OAuth integration
87+
88+
### Request Flow
89+
1. HTTP requests enter through router (`internal/api/router/`)
90+
2. Handlers in `internal/api/handlers/v0/` validate and process requests
91+
3. Service layer executes business logic
92+
4. Database interface handles persistence
93+
5. JSON responses returned to clients
94+
95+
### Key Interfaces
96+
- **Database Interface** (`internal/database/database.go`) - Abstracts data persistence with MongoDB and memory implementations
97+
- **RegistryService** (`internal/service/service.go`) - Business logic abstraction over database
98+
- **Auth Service** (`internal/auth/auth.go`) - GitHub OAuth token validation
99+
100+
### Authentication Flow
101+
Publishing requires GitHub OAuth validation:
102+
1. Extract bearer token from Authorization header
103+
2. Validate token with GitHub API
104+
3. Verify repository ownership matches token owner
105+
4. Check organization membership if applicable
106+
107+
### Design Patterns
108+
- **Factory Pattern** for service creation with dependency injection
109+
- **Repository Pattern** for database abstraction
110+
- **Context Pattern** for timeout management (5-second DB operations)
111+
- **Cursor-based Pagination** using UUIDs for stateless pagination
112+
113+
## Environment Variables
114+
Key configuration for development:
115+
- `MCP_REGISTRY_DATABASE_URL` (default: `mongodb://localhost:27017`)
116+
- `MCP_REGISTRY_GITHUB_CLIENT_ID`
117+
- `MCP_REGISTRY_GITHUB_CLIENT_SECRET`
118+
- `MCP_REGISTRY_LOG_LEVEL` (default: `info`)
119+
- `MCP_REGISTRY_SERVER_ADDRESS` (default: `:8080`)
120+
- `MCP_REGISTRY_SEED_IMPORT` (default: `true`)
121+
- `MCP_REGISTRY_SEED_FILE_PATH` (default: `data/seed.json`)

Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
FROM golang:1.23-alpine AS builder
22
WORKDIR /app
33
COPY . .
4-
RUN go build -o /build/registry ./cmd/registry
4+
ARG GO_BUILD_TAGS
5+
RUN go build ${GO_BUILD_TAGS:+-tags="$GO_BUILD_TAGS"} -o /build/registry ./cmd/registry
56

67
FROM alpine:latest
78
WORKDIR /app
89
COPY --from=builder /build/registry .
9-
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
1011
COPY --from=builder /app/internal/docs/swagger.yaml /app/internal/docs/swagger.yaml
1112
EXPOSE 8080
1213

README.md

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,23 @@ The MCP Registry service provides a centralized repository for MCP server entrie
2424

2525
### Prerequisites
2626

27-
- Go 1.18 or later
27+
- Go 1.23.x (required - check with `go version`)
2828
- MongoDB
2929
- Docker (optional, but recommended for development)
3030

31+
For development:
32+
- golangci-lint v1.61.0 - Install with:
33+
```bash
34+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.61.0
35+
```
36+
3137
## Running
3238

3339
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.
3440

3541
```bash
36-
# Build the Docker image
37-
docker build -t registry .
38-
3942
# Run the registry and MongoDB with docker compose
40-
docker compose up
43+
docker compose up --build
4144
```
4245

4346
This will start the MCP Registry service and MongoDB with Docker, exposing it on port 8080.
@@ -54,6 +57,33 @@ This will create the `registry` binary in the current directory. You'll need to
5457

5558
By default, the service will run on `http://localhost:8080`.
5659

60+
## Development
61+
62+
### Linting
63+
64+
The project uses golangci-lint with extensive checks. Always run linting before pushing:
65+
66+
```bash
67+
# Run all linters (same as CI)
68+
golangci-lint run --timeout=5m
69+
70+
# Check formatting
71+
gofmt -s -l .
72+
73+
# Fix formatting
74+
gofmt -s -w .
75+
```
76+
77+
### Git Hooks (Optional)
78+
79+
To automatically run linting before commits:
80+
81+
```bash
82+
git config core.hooksPath .githooks
83+
```
84+
85+
This will prevent commits that fail linting or have formatting issues.
86+
5787
## Project Structure
5888

5989
```

0 commit comments

Comments
 (0)