Overview
registerAppResource is a convenience wrapper around the MCP SDK’s server.registerResource() that defaults the MIME type to RESOURCE_MIME_TYPE ("text/html;profile=mcp-app"). Use it to register the HTML resources that your tools reference via _meta.ui.resourceUri.
Signature
Parameters
The MCP server instance.
Human-readable resource name.
Resource URI. Should match the
_meta.ui.resourceUri in your tool config.Resource configuration extending MCP SDK’s
ResourceMetadata.Human-readable resource description.
MIME type. Defaults to
RESOURCE_MIME_TYPE if omitted.Optional UI metadata for the resource listing (returned in
resources/list). You can also set _meta.ui on individual contents[] items returned by the read callback — content-item values take precedence. See _meta Reference below for all fields.Callback that returns the resource contents. The
contents[] items can include _meta.ui for per-read security configuration.Usage
Basic resource
With CSP configuration
Declare network domains your View needs in_meta.ui.csp on the contents[] items:
With permissions
Request browser capabilities like camera, microphone, geolocation, or clipboard access:With stable origin (domain)
Use_meta.ui.domain to give your View a stable sandbox origin for CORS allowlists. The value is a subdomain within the host’s domain space, not your own domain. See Resource _meta > domain for details.
_meta Reference
See Resource _meta for the complete reference on CSP (connectDomains, resourceDomains, frameDomains, baseUriDomains), sandbox permissions (camera, microphone, geolocation, clipboardWrite), stable domain origins, prefersBorder, and listing-level vs content-item precedence.
Constants
| Constant | Value | Description |
|---|---|---|
RESOURCE_MIME_TYPE | "text/html;profile=mcp-app" | MIME type for MCP App UI resources |
RESOURCE_URI_META_KEY | "ui/resourceUri" | Deprecated metadata key for tool-resource linkage |