9
9
"github.com/modelcontextprotocol/registry/internal/auth"
10
10
"github.com/modelcontextprotocol/registry/internal/model"
11
11
"github.com/modelcontextprotocol/registry/internal/service"
12
+ "github.com/modelcontextprotocol/registry/internal/validators"
12
13
)
13
14
14
15
// PublishServerInput represents the input for publishing a server
@@ -17,7 +18,6 @@ type PublishServerInput struct {
17
18
Body model.PublishRequest
18
19
}
19
20
20
-
21
21
// RegisterPublishEndpoint registers the publish endpoint
22
22
func RegisterPublishEndpoint (api huma.API , registry service.RegistryService , authService auth.Service ) {
23
23
huma .Register (api , huma.Operation {
@@ -42,13 +42,10 @@ func RegisterPublishEndpoint(api huma.API, registry service.RegistryService, aut
42
42
// Convert PublishRequest body to ServerDetail
43
43
serverDetail := input .Body .ServerDetail
44
44
45
- // Huma handles validation automatically based on struct tags
46
- // But we can add custom validation if needed
47
- if serverDetail .Name == "" {
48
- return nil , huma .Error400BadRequest ("Name is required" )
49
- }
50
- if serverDetail .VersionDetail .Version == "" {
51
- return nil , huma .Error400BadRequest ("Version is required" )
45
+ // Validate the server detail
46
+ validator := validators .NewServerValidator ()
47
+ if err := validator .Validate (& serverDetail .Server ); err != nil {
48
+ return nil , huma .Error400BadRequest (err .Error ())
52
49
}
53
50
54
51
// Determine authentication method based on server name prefix
0 commit comments