registries

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 3, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package registries holds the per-registry validators that confirm a package exists in its upstream registry and carries an ownership annotation matching the resource's expected server name. Each validator (OCI, NPM, PyPI) is a standalone function consumed by Dispatcher via the v1alpha1.RegistryValidatorFunc type.

Index

Constants

View Source
const (
	DefaultURLNPM  = "https://registry.npmjs.org"
	DefaultURLPyPI = "https://pypi.org"
)

Canonical public registry base URLs the validators fall back to when MCPPackageOriginNPM.Mirror / MCPPackageOriginPyPI.Mirror is empty. These are validator-side concerns: the API types in pkg/api/v1alpha1 don't reference them. Operators retargeting the validators at a private mirror (Verdaccio for npm, devpi for PyPI) only touch this file. An explicit Mirror on a package is honored as-is and used to drive the upstream HTTP probe; non-empty values are treated as overrides, not violations.

Variables

View Source
var (
	ErrMissingIdentifierForNPM = errors.New("package identifier is required for NPM packages")
	ErrMissingVersionForNPM    = errors.New("package version is required for NPM packages")
)
View Source
var (
	ErrMissingIdentifierForOCI = errors.New("package identifier is required for OCI packages")
	ErrUnsupportedRegistry     = errors.New("unsupported OCI registry")
)
View Source
var (
	ErrMissingIdentifierForPyPI = errors.New("package identifier is required for PyPI packages")
	ErrMissingVersionForPyPi    = errors.New("package version is required for PyPI packages")
)
View Source
var ErrRateLimited = errors.New("rate limited by registry")

ErrRateLimited is returned when a registry rate limits our requests

Functions

func Dispatcher

func Dispatcher(ctx context.Context, origin v1alpha1.MCPPackageOrigin, objectName string) error

Dispatcher is the v1alpha1-native RegistryValidatorFunc. It fans (ctx, origin, objectName) out to the appropriate per-registry validator based on which Origin sub-struct is non-nil. An origin with no sub-struct set — or with the wrong sub-struct for its Type — returns a 400-style error.

Use it directly as the v argument to obj.ValidateRegistries:

err := v1alpha1.ValidateObjectRegistries(ctx, obj, registries.Dispatcher)

Callers that want to disable a subset of registries (e.g. unit tests, offline imports, air-gapped deployments) can wrap this with their own RegistryValidatorFunc that filters on origin.Type before delegating.

func ValidateNPM

func ValidateNPM(ctx context.Context, origin v1alpha1.MCPPackageOrigin, serverName string) error

ValidateNPM validates that an NPM package contains the correct MCP server name.

func ValidateOCI

func ValidateOCI(ctx context.Context, origin v1alpha1.MCPPackageOrigin, serverName string) error

ValidateOCI validates that an OCI image contains the correct MCP server name annotation.

Supported reference forms (Identifier must include an explicit tag or digest):

  • registry/namespace/image:tag
  • registry/namespace/image@sha256:digest
  • registry/namespace/image:tag@sha256:digest
  • namespace/image:tag (defaults to docker.io)

Supported registries:

  • Docker Hub (docker.io)
  • GitHub Container Registry (ghcr.io)
  • Google Artifact Registry (*.pkg.dev)

func ValidatePyPI

func ValidatePyPI(ctx context.Context, origin v1alpha1.MCPPackageOrigin, serverName string) error

ValidatePyPI validates that a PyPI package contains the correct MCP server name.

Types

type NPMPackageResponse

type NPMPackageResponse struct {
	MCPName string `json:"mcpName"`
}

NPMPackageResponse represents the structure returned by the NPM registry API

type PyPIPackageResponse

type PyPIPackageResponse struct {
	Info struct {
		Description string `json:"description"`
	} `json:"info"`
}

PyPIPackageResponse represents the structure returned by the PyPI JSON API

Directories

Path Synopsis
internal
testutil
Package testutil provides shared helpers for the registries package tests.
Package testutil provides shared helpers for the registries package tests.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL