Skip to content

Conversation

@antonpk1
Copy link
Collaborator

@antonpk1 antonpk1 commented Dec 2, 2025

Summary

Add Zod schemas and TypeScript types for _meta.ui field from resources/read responses:

  • McpUiResourceCspSchema / McpUiResourceCsp - CSP domain declarations
  • McpUiResourceMetaSchema / McpUiResourceMeta - Full UI resource metadata

Why

The spec defines these types in UIResourceMeta but they weren't implemented in the SDK. Hosts need these to:

  1. Construct CSP headers from connectDomains (fetch/XHR/WebSocket) and resourceDomains (scripts/images/fonts)
  2. Configure iframe sandboxing with optional dedicated domain for API key allowlists
  3. Apply visual styling based on prefersBorder preference

🤖 Generated with Claude Code

Add types for parsing `_meta.ui` field from resources/read responses:

- McpUiResourceCspSchema: CSP domain declarations (connectDomains for
  fetch/XHR/WebSocket, resourceDomains for scripts/images/fonts)
- McpUiResourceMetaSchema: Full metadata including CSP, dedicated domain
  for widget sandbox, and border preference

Hosts need these to construct CSP headers and configure iframe sandboxing.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@antonpk1 antonpk1 force-pushed the feat/add-ui-resource-meta-types branch from 181a4dc to 98464a4 Compare December 2, 2025 12:06
* Servers declare which external origins their UI needs to access.
* Hosts use this to enforce appropriate CSP headers.
*/
export const McpUiResourceCspSchema = z.object({
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@antonpk1 What do you think about add describes to the fields?

Copy link
Collaborator

@ochafik ochafik Dec 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note I've been toying w/ generating the zod schemas (in this branch), I think we should focus on clean types and automate the rest. (I wouldn't even put comments on the schemas to stay consistent w/ current state of this file, to avoid comment duplication)

@ochafik ochafik merged commit 781adf1 into main Dec 3, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants