Skip to content

Commit 71590d7

Browse files
authored
Update UI resource format and metadata fields
Create a unified object of UIResourceMetadata, as agreed in the SEP doc: ``` interface UiResourceMeta { csp?: { connectDomains?: string[], resourceDomains?: string[], }, domain?: string, prefersBorder?: boolean, } ```
1 parent fd38d79 commit 71590d7

File tree

1 file changed

+33
-18
lines changed

1 file changed

+33
-18
lines changed

specification/draft/apps.mdx

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,23 @@ As an extension, MCP Apps is optional and must be explicitly negotiated between
5151

5252
UI resources are declared using the standard MCP resource pattern with specific conventions:
5353

54-
```typescript
54+
```
5555
interface UIResource {
5656
uri: string; // MUST start with 'ui://'
5757
name: string; // Human-readable identifier
5858
description?: string; // Description of the UI resource
59-
mimeType: string; // SHOULD be 'text/vnd.mcp.ui+html' in MVP
59+
mimeType: string; // SHOULD be 'text/html' in MVP
60+
_meta?: UIResourceMeta // Resource Metadata
61+
}
62+
```
63+
```
64+
interface UiResourceMeta {
65+
csp?: {
66+
connectDomains?: string[],
67+
resourceDomains?: string[],
68+
},
69+
domain?: string,
70+
prefersBorder?: boolean,
6071
}
6172
```
6273

@@ -71,12 +82,14 @@ The resource content is returned via `resources/read`:
7182
text?: string; // HTML content as string
7283
blob?: string; // OR base64-encoded HTML
7384
_meta?: {
74-
"ui/csp"?: {
75-
connect_domains?: string[]; // Origins for fetch/XHR/WebSocket
76-
resource_domains?: string[]; // Origins for images, scripts, styles
85+
"ui"?: {
86+
"csp"?: {
87+
connect_domains?: string[]; // Origins for fetch/XHR/WebSocket
88+
resource_domains?: string[]; // Origins for images, scripts, etc
89+
};
90+
"domain"?: string;
91+
"prefersBorder"?: boolean;
7792
};
78-
"ui/domain"?: string;
79-
"ui/prefersBorder"?: boolean;
8093
};
8194
}];
8295
}
@@ -91,7 +104,7 @@ The resource content is returned via `resources/read`:
91104

92105
#### Metadata Fields:
93106

94-
**`ui/csp` - Content Security Policy configuration**
107+
**`ui.csp` - Content Security Policy configuration**
95108

96109
Servers declare which external origins their UI needs to access. Hosts use this to enforce appropriate CSP headers.
97110

@@ -106,14 +119,14 @@ Servers declare which external origins their UI needs to access. Hosts use this
106119
- Wildcard subdomains supported: `https://*.example.com`
107120
- Maps to CSP `img-src`, `script-src`, `style-src`, `font-src` directives
108121

109-
**`ui/domain` - Dedicated origin for widget**
122+
**`ui.domain` - Dedicated origin for widget**
110123

111124
Optional domain for the widget's sandbox origin. Useful when widgets need dedicated origins for API key allowlists or cross-origin isolation.
112125

113126
- Example: `"https://weather-widget.example.com"`
114127
- If omitted, Host uses default sandbox origin
115128

116-
**`ui/prefersBorder` - Visual boundary preference**
129+
**`ui.prefersBorder` - Visual boundary preference**
117130

118131
Boolean indicating the UI prefers a visible border. Useful for widgets that might blend with host background.
119132

@@ -123,7 +136,7 @@ Boolean indicating the UI prefers a visible border. Useful for widgets that migh
123136
#### Host Behavior:
124137

125138
- **CSP Enforcement:** Host MUST construct CSP headers based on declared domains
126-
- **Restrictive Default:** If `ui/csp` is omitted, Host MUST use:
139+
- **Restrictive Default:** If `ui.csp` is omitted, Host MUST use:
127140

128141
```
129142
default-src 'none';
@@ -153,12 +166,14 @@ Example:
153166
"uri": "ui://weather-server/dashboard-template",
154167
"mimeType": "text/vnd.mcp.ui+html",
155168
"text": "<!DOCTYPE html><html>...</html>",
156-
"_meta": {
157-
"ui/csp": {
158-
"connect_domains": ["https://api.openweathermap.org"],
159-
"resource_domains": ["https://cdn.jsdelivr.net"]
160-
},
161-
"ui/prefersBorder": true
169+
_meta: {
170+
"ui" : {
171+
"csp": {
172+
connect_domains: ["https://api.openweathermap.org"],
173+
resource_domains: ["https://cdn.jsdelivr.net"]
174+
},
175+
"prefersBorder": true
176+
}
162177
}
163178
}]
164179
}
@@ -282,7 +297,7 @@ If the Host is a web page, it MUST wrap the Guest UI and communicate with it thr
282297
3. The Sandbox MUST send a `ui/sandbox-ready` notification to the host when it’s ready to process an `ui/sandbox-resource-ready` notification.
283298
4. Once the Sandbox is ready, the Host MUST send the raw HTML resource to load in a `ui/sandbox-resource-ready` notification.
284299
5. The Sandbox MUST load the raw HTML of the Guest UI with CSP settings that:
285-
- Enforce the domains declared in `ui/csp` metadata
300+
- Enforce the domains declared in `ui.csp` metadata
286301
- Prevent nested iframes (`frame-src 'none'`)
287302
- Block dangerous features (`object-src 'none'`, `base-uri 'self'`)
288303
- Apply restrictive defaults if no CSP metadata is provided

0 commit comments

Comments
 (0)