Skip to content

Commit 4953cd3

Browse files
authored
Add media-src to CSP for video and audio support (#109)
This adds the media-src directive to the Content Security Policy to enable MCP Apps to play video and audio content. Changes: - Add media-src to the restrictive default CSP in the spec - Add media-src to the CSP construction from metadata in the spec - Update resourceDomains documentation in spec to include media - Update resourceDomains JSDoc in src/types.ts to include media-src Fixes #106
1 parent e63f028 commit 4953cd3

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

specification/draft/apps.mdx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,11 @@ interface UIResourceMeta {
125125
*/
126126
connectDomains?: string[],
127127
/**
128-
* Origins for static resources (images, scripts, stylesheets, fonts)
128+
* Origins for static resources (images, scripts, stylesheets, fonts, media)
129129
*
130130
* - Empty or omitted = no external resources (secure default)
131131
* - Wildcard subdomains supported: `https://*.example.com`
132-
* - Maps to CSP `img-src`, `script-src`, `style-src`, `font-src` directives
132+
* - Maps to CSP `img-src`, `script-src`, `style-src`, `font-src`, `media-src` directives
133133
*
134134
* @example
135135
* ["https://cdn.jsdelivr.net", "https://*.cloudflare.com"]
@@ -202,6 +202,7 @@ The resource content is returned via `resources/read`:
202202
script-src 'self' 'unsafe-inline';
203203
style-src 'self' 'unsafe-inline';
204204
img-src 'self' data:;
205+
media-src 'self' data:;
205206
connect-src 'none';
206207
```
207208

@@ -1114,6 +1115,7 @@ const cspValue = `
11141115
connect-src 'self' ${csp?.connectDomains?.join(' ') || ''};
11151116
img-src 'self' data: ${csp?.resourceDomains?.join(' ') || ''};
11161117
font-src 'self' ${csp?.resourceDomains?.join(' ') || ''};
1118+
media-src 'self' data: ${csp?.resourceDomains?.join(' ') || ''};
11171119
frame-src 'none';
11181120
object-src 'none';
11191121
base-uri 'self';

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ type _VerifyInitializedNotification = VerifySchemaMatches<
872872
export const McpUiResourceCspSchema = z.object({
873873
/** Origins for network requests (fetch/XHR/WebSocket). Maps to CSP connect-src */
874874
connectDomains: z.array(z.string()).optional(),
875-
/** Origins for static resources (images, scripts, stylesheets, fonts). Maps to CSP img-src, script-src, style-src, font-src */
875+
/** Origins for static resources (images, scripts, stylesheets, fonts, media). Maps to CSP img-src, script-src, style-src, font-src, media-src */
876876
resourceDomains: z.array(z.string()).optional(),
877877
});
878878
export type McpUiResourceCsp = z.infer<typeof McpUiResourceCspSchema>;

0 commit comments

Comments
 (0)