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
- func ContentHash(text string) string
- func NewEmbeddedHTMLResource(uri, html string, annotations *schema.Annotations, ui metaui.ResourceUI) (*schema.EmbeddedResource, error)
- func NewHTMLContents(uri, html string, ui metaui.ResourceUI) (*schema.TextResourceContents, error)
- func NewHTMLResource(uri, name string, description, title *string, annotations *schema.Annotations, ...) (*schema.Resource, error)
- func NewReadResultHTMLContents(uri, html string, ui metaui.ResourceUI) (*schema.ReadResourceResultContentsElem, error)
- type UIURI
Constants ¶
const ( KindDemo = "demo" KindView = "view" KindFeed = "feed" KindWidget = "widget" )
Resource-kind enumeration recognized by Phase 1.
const Scheme = "ui"
Scheme is the URI scheme of all MCP UI resources.
Variables ¶
This section is empty.
Functions ¶
func ContentHash ¶
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 ¶
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 ¶
MustValidateUIURI is the panicking variant of ValidateUIURI for use in tests and package-level initializers that must be statically valid.
func ValidateUIURI ¶
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.