Skip to main content
MCP Apps SDK

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

server
McpServer
required
The MCP server instance.
name
string
required
Human-readable resource name.
uri
string
required
Resource URI. Should match the _meta.ui.resourceUri in your tool config.
config
McpUiAppResourceConfig
required
Resource configuration extending MCP SDK’s ResourceMetadata.
description
string
Human-readable resource description.
mimeType
string
MIME type. Defaults to RESOURCE_MIME_TYPE if omitted.
_meta
object
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.
readCallback
McpUiReadResourceCallback
required
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

In the sunpeak framework, resources are co-located with tools and auto-discovered. See the Tool File Reference.