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
- func BrandIcon(rawURL string) string
- func Forget(key string)
- func FromDataURI(src string) (string, error)
- func IsBrandIcon(uri string) bool
- func Lookup(key string) (string, bool)
- func Record(key string, impl mcp.Implementation)
- func Select(icons []mcp.Icon) (mcp.Icon, bool)
- func SetOnChange(fn func(key string))
- type Store
Constants ¶
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 ¶
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 FromDataURI ¶
FromDataURI validates a data: URI icon and returns it in the canonical base64 form.
func IsBrandIcon ¶
IsBrandIcon reports whether uri is one of the built-in brand icons.
func Lookup ¶
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 Select ¶
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.