Help us shape the future of Go! Take the 2026 Go Developer Survey

gateway

package
v1.151.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	DockerCatalogURL = "https://desktop.docker.com/mcp/catalog/v3/catalog.yaml"
)

Variables

This section is empty.

Functions

func ParseServerRef

func ParseServerRef(ref string) string

ParseServerRef strips the optional "docker:" prefix from a server reference.

func Prefetch added in v1.111.0

func Prefetch(ctx context.Context)

Prefetch starts resolving the catalog in the background so a later ServerSpec call finds the result memoized (or the fetch already in flight) instead of paying the network round-trip on the caller's critical path.

func WithLoader added in v1.92.0

func WithLoader(ctx context.Context, loader *Loader) context.Context

WithLoader returns a copy of ctx that carries loader, so calls to ServerSpec / RequiredEnvVars made with the returned context resolve against it instead of the shared [defaultLoader]. Tests use it together with NewStaticLoader to serve a fixed catalog without global state. A nil loader is ignored so callers fall back to the [defaultLoader].

Types

type Catalog

type Catalog map[string]Server

type Loader added in v1.92.0

type Loader struct {
	// contains filtered or unexported fields
}

Loader fetches and memoizes the MCP catalog. A single Loader fetches the catalog at most once and reuses the memoized result for every later call, so callers should share one instance.

The zero value is not usable; construct with NewLoader (production, fetches from the network) or NewStaticLoader (tests, serves a fixed catalog with no network access). A Loader is carried on the context via WithLoader and retrieved with [loaderFrom]; call sites that don't inject one transparently use the shared [defaultLoader].

func NewLoader added in v1.92.0

func NewLoader() *Loader

NewLoader returns a Loader that fetches the catalog from the network (with on-disk cache fallback) on first use and memoizes the result.

func NewStaticLoader added in v1.92.0

func NewStaticLoader(catalog Catalog) *Loader

NewStaticLoader returns a Loader that always serves catalog without touching the network. It is the test seam that replaces the old global override: a test injects it via WithLoader so its goroutines never race a shared package-level variable.

type Remote

type Remote struct {
	URL           string `json:"url"`
	TransportType string `json:"transport_type"`
}

type Secret

type Secret struct {
	Name    string `json:"name"`
	Env     string `json:"env"`
	Example string `json:"example"`
}

func RequiredEnvVars

func RequiredEnvVars(ctx context.Context, serverName string) ([]Secret, error)

type Server

type Server struct {
	Type    string   `json:"type"`
	Secrets []Secret `json:"secrets,omitempty"`
	Remote  Remote   `json:"remote"`
}

func ServerSpec

func ServerSpec(ctx context.Context, serverName string) (Server, error)

Jump to

Keyboard shortcuts

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