MCPcopy Index your code
hub / github.com/modelcontextprotocol/registry / ValidatePackage

Function ValidatePackage

internal/validators/package.go:14–29  ·  view source on GitHub ↗

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

(ctx context.Context, pkg model.Package, serverName string)

Source from the content-addressed store, hash-verified

12// 1. allowed on the official registry (based on registry base url); and
13// 2. owned by the publisher, by checking for a matching server name in the package metadata
14func ValidatePackage(ctx context.Context, pkg model.Package, serverName string) error {
15 switch pkg.RegistryType {
16 case model.RegistryTypeNPM:
17 return registries.ValidateNPM(ctx, pkg, serverName)
18 case model.RegistryTypePyPI:
19 return registries.ValidatePyPI(ctx, pkg, serverName)
20 case model.RegistryTypeNuGet:
21 return registries.ValidateNuGet(ctx, pkg, serverName)
22 case model.RegistryTypeOCI:
23 return registries.ValidateOCI(ctx, pkg, serverName)
24 case model.RegistryTypeMCPB:
25 return registries.ValidateMCPB(ctx, pkg, serverName)
26 default:
27 return fmt.Errorf("unsupported registry type: %s", pkg.RegistryType)
28 }
29}

Callers 1

Calls 5

ValidateNPMFunction · 0.92
ValidatePyPIFunction · 0.92
ValidateNuGetFunction · 0.92
ValidateOCIFunction · 0.92
ValidateMCPBFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…