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.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 origin for CORS allowlists:
The
domain format is host-specific. Check each host’s documentation for the expected format.CSP Reference
CSP is set in thecontents[] items returned by the read callback, not in the registerAppResource config.
| Field | CSP Directive | Purpose |
|---|---|---|
connectDomains | connect-src | fetch/XHR/WebSocket origins |
resourceDomains | img-src, script-src, style-src, font-src, media-src | Static resource origins |
frameDomains | frame-src | Nested iframe origins |
baseUriDomains | base-uri | Allowed base URIs |
Permissions Reference
| Field | Permission Policy | Purpose |
|---|---|---|
camera | camera | Camera access |
microphone | microphone | Microphone access |
geolocation | geolocation | Location access |
clipboardWrite | clipboard-write | Clipboard write access |
Other Resource Options
Visual boundary preference.
true requests a visible border and background from the host; false requests none. Omit to let the host decide.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 |