retriever

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package retriever contains logic for fetching or building MCP servers.

Index

Constants

View Source
const (
	// VerifyImageWarn prints a warning when image validation fails.
	VerifyImageWarn = "warn"
	// VerifyImageEnabled treats validation failure as a fatal error.
	VerifyImageEnabled = "enabled"
	// VerifyImageDisabled turns off validation.
	VerifyImageDisabled = "disabled"
)

Variables

View Source
var (
	// ErrBadProtocolScheme is returned when the provided serverOrImage is not a valid protocol scheme.
	ErrBadProtocolScheme = httperr.WithCode(
		errors.New("invalid protocol scheme provided for MCP server"),
		http.StatusBadRequest,
	)
	// ErrImageNotFound is returned when the specified image is not found in the registry.
	ErrImageNotFound = httperr.WithCode(
		errors.New("image not found in registry, please check the image name or tag"),
		http.StatusNotFound,
	)
	// ErrInvalidRunConfig is returned when the run configuration built by RunConfigBuilder is invalid
	ErrInvalidRunConfig = httperr.WithCode(
		errors.New("invalid run configuration provided"),
		http.StatusBadRequest,
	)
)

Functions

func EnforcePolicyAndPullImage added in v0.18.0

func EnforcePolicyAndPullImage(
	ctx context.Context,
	runConfig *runner.RunConfig,
	serverMetadata types.ServerMetadata,
	imageURL string,
	puller ImagePuller,
	pullTimeout time.Duration,
	locallyBuilt bool,
) error

EnforcePolicyAndPullImage checks the runner policy gate and, for non-remote local workloads, pulls the container image. The policy check runs before the pull so that a rejected server fails fast without downloading the image. In Kubernetes mode the pull is skipped because the kubelet handles it.

When locallyBuilt is true the image was already built by a protocol-scheme handler (npx://, uvx://, go://) and exists locally, so the pull is skipped to avoid an unnecessary Docker daemon connection.

When pullTimeout is positive a child context with that deadline is used for the pull; otherwise ctx is forwarded as-is.

The puller parameter controls how the image is fetched; pass PullMCPServerImage for production use or a no-op for tests.

func PullMCPServerImage added in v0.18.0

func PullMCPServerImage(ctx context.Context, imageURL string) error

PullMCPServerImage ensures the resolved image is available locally by pulling it from a remote registry if necessary. For images that already exist locally (e.g. built from a protocol scheme) this is a no-op.

func ResolveMCPServer added in v0.18.0

func ResolveMCPServer(
	ctx context.Context,
	serverOrImage string,
	rawCACertPath string,
	verificationType string,
	groupName string,
	runtimeOverride *templates.RuntimeConfig,
) (string, types.ServerMetadata, error)

ResolveMCPServer resolves the MCP server definition from the registry without pulling the image. For protocol schemes (npx://, uvx://, go://) this still builds the image since the built image name is needed for configuration. For registry servers this only performs the lookup and verification (fast).

Call PullMCPServerImage afterwards to ensure the image is available locally.

Types

type ImagePuller added in v0.18.0

type ImagePuller func(ctx context.Context, imageURL string) error

ImagePuller pulls a resolved container image so that it is available locally.

type Retriever added in v0.3.0

Retriever is a function that retrieves the MCP server definition from the registry.

Jump to

Keyboard shortcuts

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