How modelcontextprotocol/registry works
Project Type and Purpose
• This is a backend-only, RESTful registry service written in Go.
• It exposes HTTP endpoints (health, ping, servers, publish) for managing metadata about MCP servers.
• It supports both MongoDB and in-memory stores, uses GitHub for authentication, and provides a CLI “publisher” tool to push entries.
Top‐Level Components
a. API Server Container (Go service)
b. Database (MongoDB or in-memory)
c. External Auth Service (GitHub OAuth)
d. CLI Publisher Tool
e. Utility Scripts (for testing)
f. Docker Compose/Container Orchestration
• Configuration (internal/config)
• HTTP Server & Router (internal/api/server.go + internal/api/router)
• Handlers (internal/api/handlers/v0)
• Business Logic / Services (internal/service)
• Data Layer / Repositories (internal/database + internal/model)
• Auth Module (internal/auth)
Relationships & Data Flow
1) Client → HTTP(S) → API Server
2) Router dispatches to v0 handlers
3) Handlers call Service layer
4) Service layer uses Database interface (Mongo or Memory)
5) Service layer calls Auth module for “publish” endpoints (GitHub client)
6) Database persists/fetches data
7) CLI Publisher → HTTP POST /v0/publish → API Server
8) Docker Compose orchestrates API + MongoDB + seed import
Architectural Patterns & Principles
• Hexagonal / Clean Architecture: clear separation between API adapters, business logic, persistence interfaces, and external clients.
• Dependency Injection via interfaces (database, auth).
• Layered approach: Router → Handlers → Services → Repositories.
• Pluggable data store (memory or Mongo) via strategy pattern.
Technologies & Frameworks
• Go modules, Go 1.18+
• Gin or built-in net/http (internal/api/router)
• MongoDB driver (internal/database/mongo)
• Docker & Docker Compose
• OpenAPI/Swagger (api/openapi.yaml, internal/docs)
• GitHub OAuth (internal/auth/github.go)
b. Within the registry container, subdivide into:
• Config Module
• HTTP Server & Router
• Handlers (v0)
• Services (registry_service, fake_service)
• Database Abstraction (memory, mongo)
• Auth Module
e. Outside the Docker boundary, place “Client” (web or CLI) and show HTTP calls (GET /v0/servers, POST /v0/publish).