resource

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package resource provides `ui://...` resource builders for the MCP UI extension proposed by SEP-1865 (MCP Apps).

All MIME and `_meta` values are sourced byte-for-byte from the upstream MCP Apps spec commit pinned in the module README. Validation is explicit and identity-based; no heuristics or fallback guesses.

Index

Constants

View Source
const (
	KindDemo   = "demo"
	KindView   = "view"
	KindFeed   = "feed"
	KindWidget = "widget"
)

Resource-kind enumeration recognized by Phase 1.

View Source
const Scheme = "ui"

Scheme is the URI scheme of all MCP UI resources.

Variables

This section is empty.

Functions

func ContentHash

func ContentHash(text string) string

ContentHash returns the canonical UI resource content hash for the supplied text payload.

func NewEmbeddedHTMLResource

func NewEmbeddedHTMLResource(uri, html string, annotations *schema.Annotations, ui metaui.ResourceUI) (*schema.EmbeddedResource, error)

NewEmbeddedHTMLResource constructs an embedded HTML UI resource for optional compatibility flows.

func NewHTMLContents

func NewHTMLContents(uri, html string, ui metaui.ResourceUI) (*schema.TextResourceContents, error)

NewHTMLContents constructs a text resource contents entry for HTML UI.

func NewHTMLResource

func NewHTMLResource(uri, name string, description, title *string, annotations *schema.Annotations, ui metaui.ResourceUI) (*schema.Resource, error)

NewHTMLResource constructs a UI resource declaration for a `ui://...` HTML resource.

func NewReadResultHTMLContents

func NewReadResultHTMLContents(uri, html string, ui metaui.ResourceUI) (*schema.ReadResourceResultContentsElem, error)

NewReadResultHTMLContents constructs a resources/read payload element for HTML UI content.

Types

type UIURI

type UIURI struct {
	Raw         string
	ServerScope string
	Kind        string
	ResourceID  string
}

UIURI is the parsed form of a `ui://<server-scope>/<resource-kind>/<resource-id>` URI. The original textual form is preserved as Raw.

func MustValidateUIURI

func MustValidateUIURI(raw string) UIURI

MustValidateUIURI is the panicking variant of ValidateUIURI for use in tests and package-level initializers that must be statically valid.

func ValidateUIURI

func ValidateUIURI(raw string) (UIURI, error)

ValidateUIURI parses and validates a `ui://...` resource URI according to the grammar documented in the enhancement plan:

ui://<server-scope>/<resource-kind>/<resource-id>

Rules enforced:

  • scheme MUST be `ui`
  • exactly three non-empty path segments
  • resource-kind MUST be one of demo/view/feed/widget
  • no query string and no fragment are allowed
  • server-scope and resource-id MUST be non-empty

Validation is exact; there is no fuzzy matching and no fallback guessing.

Jump to

Keyboard shortcuts

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