-
Notifications
You must be signed in to change notification settings - Fork 797
Expand file tree
/
Copy pathpackage.go
More file actions
31 lines (28 loc) · 1.13 KB
/
package.go
File metadata and controls
31 lines (28 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package validators
import (
"context"
"fmt"
"github.com/modelcontextprotocol/registry/internal/validators/registries"
"github.com/modelcontextprotocol/registry/pkg/model"
)
// ValidatePackage validates that the package referenced in the server configuration is:
// 1. allowed on the official registry (based on registry base url); and
// 2. owned by the publisher, by checking for a matching server name in the package metadata
func ValidatePackage(ctx context.Context, pkg model.Package, serverName string) error {
switch pkg.RegistryType {
case model.RegistryTypeNPM:
return registries.ValidateNPM(ctx, pkg, serverName)
case model.RegistryTypePyPI:
return registries.ValidatePyPI(ctx, pkg, serverName)
case model.RegistryTypeNuGet:
return registries.ValidateNuGet(ctx, pkg, serverName)
case model.RegistryTypeOCI:
return registries.ValidateOCI(ctx, pkg, serverName)
case model.RegistryTypeMCPB:
return registries.ValidateMCPB(ctx, pkg, serverName)
case model.RegistryTypeScrapeGraphAI:
return registries.ValidateScrapeGraphAI(ctx, pkg, serverName)
default:
return fmt.Errorf("unsupported registry type: %s", pkg.RegistryType)
}
}