servericon

package
v5.62.5 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: Apache-2.0 Imports: 24 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package servericon keeps the icon each MCP server declares in its initialize result, as a data: URI the MCPServer status carries (status.icon). It picks one of the server's icons, validates a data: URI or fetches an https one behind an SSRF guard, sanitises SVG with an allowlist, and tells the reconciler when a server's icon changed. It also holds the built-in brand icons used when a server has none of its own.

Index

Constants

View Source
const MaxEncodedLen = 64 << 10

MaxEncodedLen caps the whole data: URI written to status.icon at 65536 characters; the CRD enforces the same MaxLength.

Variables

This section is empty.

Functions

func BrandIcon

func BrandIcon(rawURL string) string

BrandIcon returns the built-in icon of the brand rawURL points at, or "". On a public host that is the brand whose domain the host is, or a subdomain of. On an in-cluster host (ending in .svc or .cluster.local, or whose last label is no public TLD) it is the brand one of whose in-cluster names equals the service name (first label), the namespace (second label) or the first path segment. Only exact domains and names count, never a word in the host.

func Forget

func Forget(key string)

Forget drops what the store knows of a server.

func FromDataURI

func FromDataURI(src string) (string, error)

FromDataURI validates a data: URI icon and returns it in the canonical base64 form.

func IsBrandIcon

func IsBrandIcon(uri string) bool

IsBrandIcon reports whether uri is one of the built-in brand icons.

func Lookup

func Lookup(key string) (string, bool)

Lookup returns the server's icon, "" when it sent no usable one; ok is false while muster has not learned it.

func Record

func Record(key string, impl mcp.Implementation)

Record takes the server info of a completed handshake; the icon is resolved in the background. Never blocks on the network.

func RecordClient

func RecordClient(key string, client any)

RecordClient records the server info of a client that exposes it.

func Select

func Select(icons []mcp.Icon) (mcp.Icon, bool)

Select picks the icon to show: one for a light background (no theme or "light") over a dark one, an SVG over a raster, and among rasters the largest at or under 256px, else the smallest above. Icons whose declared MIME type is not allowed are skipped.

func SetOnChange

func SetOnChange(fn func(key string))

SetOnChange sets the function told about a server whose icon changed.

Types

type Store

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

Store holds each server's icon by server key (api.MCPServerKey) and resolves icons by src once.

func (*Store) Forget

func (s *Store) Forget(key string)

func (*Store) Lookup

func (s *Store) Lookup(key string) (string, bool)

func (*Store) Record

func (s *Store) Record(key string, impl mcp.Implementation)

func (*Store) SetOnChange

func (s *Store) SetOnChange(fn func(key string))

Jump to

Keyboard shortcuts

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